Minor fixes to comments.
[AROS.git] / rom / exec / addlibrary.c
blob42f929c87575821755187c632a0e6c51dd3b8117
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a library to the public list of libraries.
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 #include <string.h>
15 #include "exec_intern.h"
16 #include "exec_debug.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH1(void, AddLibrary,
24 /* SYNOPSIS */
25 AROS_LHA(struct Library *, library,A1),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 66, Exec)
30 /* FUNCTION
31 Adds a given library to the system's library list after checksumming
32 the library vectors. This function is not for general use but
33 (of course) for building shared libraries that don't use exec's
34 MakeLibrary() mechanism.
36 INPUTS
37 library - Pointer to a ready for use library structure.
39 RESULT
41 NOTES
42 Some old Amiga software expects that AddLibrary returns the
43 library which was just added. When in binary compatibility mode
44 AROS does this too.
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 RemLibrary(), MakeLibrary(), MakeFunctions(), InitStruct(), SumLibrary()
53 INTERNALS
55 ******************************************************************************/
57 AROS_LIBFUNC_INIT
59 ASSERT_VALID_PTR(library);
61 /* Just in case the user forgot them */
62 library->lib_Node.ln_Type=NT_LIBRARY;
63 library->lib_Flags|=LIBF_CHANGED;
65 /* Build checksum for library vectors */
66 SumLibrary(library);
68 /* Arbitrate for the library list */
69 Forbid();
71 /* And add the library */
72 Enqueue(&SysBase->LibList,&library->lib_Node);
74 /* All done. */
75 Permit();
78 * When debug.library is added, open it and cache its base instantly.
79 * We do it because symbol lookup routines can be called in a system crash
80 * condition, where calling OpenLibrary() can be dangerous.
82 if (!strcmp(library->lib_Node.ln_Name, "debug.library"))
84 /* Don't bother searching for just added library, just call open vector */
85 DebugBase = AROS_LVO_CALL1(struct Library *,
86 AROS_LCA(ULONG, 0, D0),
87 struct Library *, library, 1, lib);
89 DINIT("%s added, base 0x%p", library->lib_Node.ln_Name, DebugBase);
92 AROS_COMPAT_SETD0(library);
93 AROS_LIBFUNC_EXIT
94 } /* AddLibrary */