2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: Add a library to the public list of libraries.
8 #include <aros/debug.h>
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
15 #include "exec_intern.h"
16 #include "exec_debug.h"
17 #include "exec_locks.h"
19 /*****************************************************************************
23 AROS_LH1(void, AddLibrary
,
26 AROS_LHA(struct Library
*, library
,A1
),
29 struct ExecBase
*, SysBase
, 66, Exec
)
32 Adds a given library to the system's library list after checksumming
33 the library vectors. This function is not for general use but
34 (of course) for building shared libraries that don't use exec's
35 MakeLibrary() mechanism.
38 library - Pointer to a ready for use library structure.
43 Some old Amiga software expects that AddLibrary returns the
44 library which was just added. When in binary compatibility mode
52 RemLibrary(), MakeLibrary(), MakeFunctions(), InitStruct(), SumLibrary()
56 ******************************************************************************/
60 ASSERT_VALID_PTR(library
);
62 /* Just in case the user forgot them */
63 library
->lib_Node
.ln_Type
=NT_LIBRARY
;
64 library
->lib_Flags
|=LIBF_CHANGED
;
66 /* Build checksum for library vectors */
69 /* Arbitrate for the library list */
70 EXEC_LOCK_LIST_WRITE_AND_FORBID(&SysBase
->LibList
);
71 /* And add the library */
72 Enqueue(&SysBase
->LibList
,&library
->lib_Node
);
73 /* We're done with midifying the LibList */
74 EXEC_UNLOCK_LIST_AND_PERMIT(&SysBase
->LibList
);
76 * When debug.library is added, open it and cache its base instantly.
77 * We do it because symbol lookup routines can be called in a system crash
78 * condition, where calling OpenLibrary() can be dangerous.
80 if (!strcmp(library
->lib_Node
.ln_Name
, "debug.library"))
82 /* Don't bother searching for just added library, just call open vector */
83 DebugBase
= AROS_LVO_CALL1(struct Library
*,
84 AROS_LCA(ULONG
, 0, D0
),
85 struct Library
*, library
, 1, lib
);
87 DINIT("%s added, base 0x%p", library
->lib_Node
.ln_Name
, DebugBase
);
90 AROS_COMPAT_SETD0(library
);