revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / openlibrary.c
blob432a5a12ed6f8106f8fe3ad92b0550f908c46a16
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Open a library.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/execbase.h>
11 #include <exec/lists.h>
12 #include <exec/libraries.h>
13 #include <aros/libcall.h>
14 #include <proto/exec.h>
16 #include "exec_intern.h"
17 #include "exec_debug.h"
18 #include "exec_locks.h"
21 /*****************************************************************************
23 NAME */
25 AROS_LH2(struct Library *, OpenLibrary,
27 /* SYNOPSIS */
28 AROS_LHA(CONST_STRPTR, libName, A1),
29 AROS_LHA(ULONG, version, D0),
31 /* LOCATION */
32 struct ExecBase *, SysBase, 92, Exec)
34 /* FUNCTION
35 Opens a library given by name and revision. If the library does not
36 exist in the current system shared library list, the first the
37 system ROMTag module list is tried. If this fails, and the DOS is
38 running, then the library will be loaded from disk.
40 INPUTS
41 libName - Pointer to the library's name.
42 version - the library's version number.
44 RESULT
45 Pointer to library structure or NULL.
47 NOTES
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 CloseLibrary()
56 INTERNALS
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 struct Library * library;
64 DRAMLIB("OpenLibrary(\"%s\", %ld)", libName, version);
66 /* Arbitrate for the library list */
67 EXEC_LOCK_LIST_READ_AND_FORBID(&SysBase->LibList);
69 /* Look for the library in our list */
70 library = (struct Library *) FindName (&SysBase->LibList, libName);
72 EXEC_UNLOCK_LIST(&SysBase->LibList);
74 /* Something found ? */
75 if(library!=NULL)
77 /* Check version */
78 if(library->lib_Version>=version)
80 /* Call Open vector */
81 library=AROS_LVO_CALL1(struct Library *,
82 AROS_LCA(ULONG,version,D0),
83 struct Library *,library,1,lib
86 else
88 DRAMLIB("Version mismatch (have %ld, wanted %ld)", library->lib_Version, version);
89 library = NULL;
94 * We cannot handle loading libraries from disk. But this is taken
95 * care of by dos.library (well lddemon really) replacing this
96 * function with a SetFunction() call.
99 /* All done. */
100 Permit();
102 DRAMLIB("OpenLibrary(\"%s\", %ld) = %p", libName, version, library);
103 return library;
105 AROS_LIBFUNC_EXIT
106 } /* OpenLibrary */