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_UFHA(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_UFHA(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
= AROS_UFC1(ULONG
,LIB_expunge
,
99 AROS_UFCA(struct DummyBase
*, DummyBase
, A6
));
107 int LIB_reserved(void)
112 static struct Library
*dummylib
;
114 static void *function_array
[] =
123 /* Must use the global sysbase */
126 static struct Library
*dummy
= NULL
;
130 D(bug("*** at %s:%d\n", __FUNCTION__
, __LINE__
));
132 dummylib
= MakeLibrary(function_array
,NULL
,
133 (ULONG (* const )())LIB_init
,
134 sizeof(struct DummyBase
),NULL
);
136 D(bug("*** at %s:%d\n", __FUNCTION__
, __LINE__
));
139 AddLibrary(dummylib
);
141 D(bug("%s: before OpenLibrary\n", __FUNCTION__
));
142 dummy
= OpenLibrary("dummy.library", 0); /* segfaults */
143 D(bug("%s: after OpenLibrary\n", __FUNCTION__
));
152 int RemoveDummy(void)
158 RemLibrary(dummylib
);
163 int __nocommandline
= 1;