1 /* Create a Library, add it to the system, and try to open it.
4 #define DUMMY_OPEN_BUG 1
5 #define INIT_DEBUG_BUG 0
8 #include <exec/types.h>
9 #include <exec/libraries.h>
10 #include <proto/exec.h>
12 #ifndef AROS_ASMCALL_H
13 # include <aros/asmcall.h>
18 struct Library library
;
19 struct ExecBase
*sysbase
;
23 #define SysBase (DummyBase->sysbase)
26 #include <aros/debug.h>
30 AROS_UFH3(struct DummyBase
*,LIB_init
,
31 AROS_LHA(struct DummyBase
*, DummyBase
, D0
),
32 AROS_LHA(ULONG
, seglist
, A0
),
33 AROS_LHA(struct ExecBase
*, sysbase
, A6
))
38 D(bug("in LIB_init a\n")); /* segfaults */
40 DummyBase
->sysbase
= sysbase
;
42 DummyBase
->library
.lib_Node
.ln_Type
= NT_LIBRARY
;
43 DummyBase
->library
.lib_Node
.ln_Name
= "dummy.library";
44 DummyBase
->library
.lib_Flags
= LIBF_SUMUSED
| LIBF_CHANGED
;
45 DummyBase
->library
.lib_Version
= 1;
46 DummyBase
->library
.lib_Revision
= 0;
47 DummyBase
->library
.lib_IdString
= "dummy.library";
49 D(bug("dummy.library: Init succesfull\n"));
57 AROS_LH1(struct DummyBase
*, LIB_open
,
58 AROS_LHA(ULONG
, version
, D0
),
59 struct DummyBase
*, DummyBase
, 1, Dummy
)
63 DummyBase
->library
.lib_OpenCnt
++;
64 DummyBase
->library
.lib_Flags
&= ~LIBF_DELEXP
;
72 AROS_UFH1(ULONG
,LIB_expunge
,
73 AROS_LHA(struct DummyBase
*, DummyBase
, A6
))
77 if (DummyBase
->library
.lib_OpenCnt
== 0)
78 Remove((struct Node
*)DummyBase
);
80 DummyBase
->library
.lib_Flags
|= LIBF_DELEXP
;
88 AROS_UFH1(ULONG
,LIB_close
,
89 AROS_LHA(struct DummyBase
*, DummyBase
, D0
))
95 DummyBase
->library
.lib_OpenCnt
--;
96 if (!DummyBase
->library
.lib_OpenCnt
)
97 if (DummyBase
->library
.lib_Flags
& LIBF_DELEXP
)
98 ret
= LIB_expunge(DummyBase
);
106 int LIB_reserved(void)
111 static struct Library
*dummylib
;
113 static void *function_array
[] =
122 /* Must use the global sysbase */
125 static struct Library
*dummy
= NULL
;
129 D(bug("*** at %s:%d\n", __FUNCTION__
, __LINE__
));
131 dummylib
= MakeLibrary(function_array
,NULL
,
132 (ULONG (* const )())LIB_init
,
133 sizeof(struct DummyBase
),NULL
);
135 D(bug("*** at %s:%d\n", __FUNCTION__
, __LINE__
));
138 AddLibrary(dummylib
);
140 D(bug("%s: before OpenLibrary\n", __FUNCTION__
));
141 dummy
= OpenLibrary("dummy.library", 0); /* segfaults */
142 D(bug("%s: after OpenLibrary\n", __FUNCTION__
));
151 int RemoveDummy(void)
157 RemLibrary(dummylib
);
162 int __nocommandline
= 1;