revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / closelibrary.c
blob9bae735aaa8259388b357f803b68be5f22d6ca27
1 /*
2 Copyright © 1995-2007, 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 /*****************************************************************************
27 NAME */
29 AROS_LH1(void, CloseLibrary,
31 /* SYNOPSIS */
32 AROS_LHA(struct Library *, library, A1),
34 /* LOCATION */
35 struct ExecBase *, SysBase, 69, Exec)
37 /* FUNCTION
38 Closes a previously opened library. It is legal to call this function
39 with a NULL pointer.
41 INPUTS
42 library - Pointer to library structure or NULL.
44 RESULT
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 OpenLibrary()
55 INTERNALS
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
60 BPTR seglist;
62 D(bug("CloseLibrary $%lx (\"%s\") by \"%s\"\n", library,
63 library ? library->lib_Node.ln_Name : "(null)",
64 GET_THIS_TASK->tc_Node.ln_Name));
66 /* Something to do? */
67 if(library!=NULL)
69 ASSERT_VALID_PTR(library);
71 /* Single-thread the close routine. */
72 Forbid();
74 /* Do the close */
75 seglist = AROS_LVO_CALL0(BPTR,struct Library *,library,2,);
77 Normally you'd expect the library to be expunged if this returns
78 non-zero, but this is only exec which doesn't know anything about
79 seglists - therefore dos.library has to SetFunction() into this
80 vector for the additional functionality.
83 /* All done. */
84 Permit();
86 else
88 /* Local vars not guaranteed to be initialised to 0. I initialise
89 it here to save an assignment in case the close went ok (common
90 path optimization). */
91 seglist = 0;
94 AROS_COMPAT_SETD0(seglist);
95 AROS_LIBFUNC_EXIT
96 } /* CloseLibrary */