2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 /* Create a Library, add it to the system, and try to open it.
9 #define DUMMY_OPEN_BUG 1
10 #define INIT_DEBUG_BUG 0
11 #define REMOVE_DUMMY 1
13 #include <exec/types.h>
14 #include <exec/libraries.h>
15 #include <proto/exec.h>
17 #ifndef AROS_ASMCALL_H
18 # include <aros/asmcall.h>
23 struct Library library
;
24 struct ExecBase
*sysbase
;
28 #define SysBase (DummyBase->sysbase)
31 #include <aros/debug.h>
35 AROS_UFH3(struct DummyBase
*,LIB_init
,
36 AROS_LHA(struct DummyBase
*, DummyBase
, D0
),
37 AROS_LHA(ULONG
, seglist
, A0
),
38 AROS_LHA(struct ExecBase
*, sysbase
, A6
))
43 D(bug("in LIB_init a\n")); /* segfaults */
45 DummyBase
->sysbase
= sysbase
;
47 DummyBase
->library
.lib_Node
.ln_Type
= NT_LIBRARY
;
48 DummyBase
->library
.lib_Node
.ln_Name
= "dummy.library";
49 DummyBase
->library
.lib_Flags
= LIBF_SUMUSED
| LIBF_CHANGED
;
50 DummyBase
->library
.lib_Version
= 1;
51 DummyBase
->library
.lib_Revision
= 0;
52 DummyBase
->library
.lib_IdString
= "dummy.library";
54 D(bug("dummy.library: Init succesfull\n"));
62 AROS_LH1(struct DummyBase
*, LIB_open
,
63 AROS_LHA(ULONG
, version
, D0
),
64 struct DummyBase
*, DummyBase
, 1, Dummy
)
68 DummyBase
->library
.lib_OpenCnt
++;
69 DummyBase
->library
.lib_Flags
&= ~LIBF_DELEXP
;
77 AROS_UFH1(ULONG
,LIB_expunge
,
78 AROS_UFHA(struct DummyBase
*, DummyBase
, A6
))
82 if (DummyBase
->library
.lib_OpenCnt
== 0)
83 Remove((struct Node
*)DummyBase
);
85 DummyBase
->library
.lib_Flags
|= LIBF_DELEXP
;
93 AROS_UFH1(ULONG
,LIB_close
,
94 AROS_UFHA(struct DummyBase
*, DummyBase
, D0
))
100 DummyBase
->library
.lib_OpenCnt
--;
101 if (!DummyBase
->library
.lib_OpenCnt
)
102 if (DummyBase
->library
.lib_Flags
& LIBF_DELEXP
)
103 ret
= AROS_UFC1(ULONG
,LIB_expunge
,
104 AROS_UFCA(struct DummyBase
*, DummyBase
, A6
));
112 int LIB_reserved(void)
117 static struct Library
*dummylib
;
119 static void *function_array
[] =
121 AROS_SLIB_ENTRY(LIB_open
, Dummy
, 1),
128 /* Must use the global sysbase */
131 static struct Library
*dummy
= NULL
;
135 D(bug("*** at %s:%d\n", __FUNCTION__
, __LINE__
));
137 dummylib
= MakeLibrary(function_array
,NULL
,
138 (ULONG_FUNC
)LIB_init
,
139 sizeof(struct DummyBase
),BNULL
);
141 D(bug("*** at %s:%d\n", __FUNCTION__
, __LINE__
));
144 AddLibrary(dummylib
);
146 D(bug("%s: before OpenLibrary\n", __FUNCTION__
));
147 dummy
= OpenLibrary("dummy.library", 0); /* segfaults */
148 D(bug("%s: after OpenLibrary\n", __FUNCTION__
));
157 int RemoveDummy(void)
163 RemLibrary(dummylib
);
168 int __nocommandline
= 1;