Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / exec / closelibrary.c
blobea76bdd7d45283e513998272e6b5cebea7ac01d0
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Close a library.
6 Lang: english
7 */
8 #include <aros/config.h>
9 #include <exec/execbase.h>
10 #include <dos/dos.h>
11 #include <aros/libcall.h>
12 #include <proto/exec.h>
14 #include "exec_debug.h"
15 #ifndef DEBUG_CloseLibrary
16 # define DEBUG_CloseLibrary 0
17 #endif
18 #undef DEBUG
19 #if DEBUG_CloseLibrary
20 # define DEBUG 1
21 #endif
22 #include <aros/debug.h>
23 #undef kprintf
25 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
26 # define NATIVE(x) x
27 #else
28 # define NATIVE(x) /* eps */
29 #endif
31 /*****************************************************************************
33 NAME */
35 AROS_LH1(void, CloseLibrary,
37 /* SYNOPSIS */
38 AROS_LHA(struct Library *, library, A1),
40 /* LOCATION */
41 struct ExecBase *, SysBase, 69, Exec)
43 /* FUNCTION
44 Closes a previously opened library. It is legal to call this function
45 with a NULL pointer.
47 INPUTS
48 library - Pointer to library structure or NULL.
50 RESULT
52 NOTES
54 EXAMPLE
56 BUGS
58 SEE ALSO
59 OpenLibrary().
61 INTERNALS
63 ******************************************************************************/
65 AROS_LIBFUNC_INIT
66 NATIVE(BPTR seglist;)
68 D(bug("CloseLibrary $%lx (\"%s\") by \"%s\"\n", library,
69 library ? library->lib_Node.ln_Name : "(null)",
70 SysBase->ThisTask->tc_Node.ln_Name));
72 /* Something to do? */
73 if(library!=NULL)
75 ASSERT_VALID_PTR(library);
77 /* Single-thread the close routine. */
78 Forbid();
80 /* Do the close */
81 NATIVE(seglist =) AROS_LVO_CALL0(BPTR,struct Library *,library,2,);
83 Normally you'd expect the library to be expunged if this returns
84 non-zero, but this is only exec which doesn't know anything about
85 seglists - therefore dos.library has to SetFunction() into this
86 vector for the additional functionality.
89 /* All done. */
90 Permit();
92 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
93 else
95 /* Local vars not guaranteed to be initialised to 0. I initialise
96 it here to save an assignment in case the close went ok (common
97 path optimization). */
98 seglist = 0;
102 Kludge to force the seglist to register d0. Ramlib patches this
103 vector for seglist expunge capability and expects the seglist in
104 d0 after it has called the original (this) function.
105 Also see CloseDevice().
108 /* Put the library base in register d0 */
109 register BPTR ret __asm("d0") = seglist;
111 /* Make sure the above assignment isn't optimized away */
112 asm volatile("": : "r" (ret));
114 #endif
116 AROS_LIBFUNC_EXIT
117 } /* CloseLibrary */