2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
9 #include <exec/execbase.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
19 #if DEBUG_CloseLibrary
22 #include <aros/debug.h>
25 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
28 # define NATIVE(x) /* eps */
31 /*****************************************************************************
35 AROS_LH1(void, CloseLibrary
,
38 AROS_LHA(struct Library
*, library
, A1
),
41 struct ExecBase
*, SysBase
, 69, Exec
)
44 Closes a previously opened library. It is legal to call this function
48 library - Pointer to library structure or NULL.
63 ******************************************************************************/
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? */
75 ASSERT_VALID_PTR(library
);
77 /* Single-thread the close routine. */
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.
92 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
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). */
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
));