2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <exec/types.h>
9 #include <exec/resident.h>
10 #include <proto/exec.h>
11 #include <aros/libcall.h>
13 # include "dummylib_gcc.h"
15 #include "initstruct.h"
19 extern const char name
[];
20 extern const char version
[];
21 extern const APTR inittabl
[4];
22 extern void *const functable
[];
23 extern const struct inittable datatable
;
24 extern struct dummybase
*AROS_SLIB_ENTRY(init
,dummy
)();
25 extern struct dummybase
*AROS_SLIB_ENTRY(open
,dummy
)();
26 extern BPTR
AROS_SLIB_ENTRY(close
,dummy
)();
27 extern BPTR
AROS_SLIB_ENTRY(expunge
,dummy
)();
28 extern int AROS_SLIB_ENTRY(null
,dummy
)();
29 extern ULONG
AROS_SLIB_ENTRY(add
,dummy
)();
30 extern ULONG
AROS_SLIB_ENTRY(asl
,dummy
)();
31 extern const char end
;
35 /* If the library was executed by accident return error code. */
39 const struct Resident resident
=
42 (struct Resident
*)&resident
,
53 const char name
[]="dummy.library";
55 const char version
[]="$VER: dummylib 41.1 (28.3.96)\n\015";
57 const APTR inittabl
[4]=
59 (APTR
)sizeof(struct dummybase
),
62 &AROS_SLIB_ENTRY(init
,dummy
)
65 void *const functable
[]=
67 &AROS_SLIB_ENTRY(open
,dummy
),
68 &AROS_SLIB_ENTRY(close
,dummy
),
69 &AROS_SLIB_ENTRY(expunge
,dummy
),
70 &AROS_SLIB_ENTRY(null
,dummy
),
71 &AROS_SLIB_ENTRY(add
,dummy
),
72 &AROS_SLIB_ENTRY(asl
,dummy
),
87 #define O(n) offsetof(struct dummybase,n)
89 const struct inittable datatable
=
91 { { I_CPYO(1,B
,O(library
.lib_Node
.ln_Type
)), { NT_LIBRARY
} } },
92 { { I_CPYO(1,L
,O(library
.lib_Node
.ln_Name
)), { (IPTR
)name
} } },
93 { { I_CPYO(1,B
,O(library
.lib_Flags
)), { LIBF_SUMUSED
|LIBF_CHANGED
} } },
94 { { I_CPYO(1,W
,O(library
.lib_Version
)), { 1 } } },
95 { { I_CPYO(1,W
,O(library
.lib_Revision
)), { 0 } } },
96 { { I_CPYO(1,L
,O(library
.lib_IdString
)), { (IPTR
)&version
[6] } } },
102 AROS_LH2(struct dummybase
*, init
,
103 AROS_LHA(struct dummybase
*, dummybase
, D0
),
104 AROS_LHA(BPTR
, segList
, A0
),
105 struct ExecBase
*, SysBase
, 0, dummy
)
108 /* This function is single-threaded by exec by calling Forbid. */
110 /* Store arguments */
111 dummybase
->sysbase
=SysBase
;
112 dummybase
->seglist
=segList
;
114 /* You would return NULL here if the init failed. */
119 /* Use This from now on */
123 #define SysBase dummybase->sysbase
125 AROS_LH1(struct dummybase
*, open
,
126 AROS_LHA(ULONG
, version
, D0
),
127 struct dummybase
*, dummybase
, 1, dummy
)
131 This function is single-threaded by exec by calling Forbid.
132 If you break the Forbid() another task may enter this function
133 at the same time. Take care.
136 /* Keep compiler happy */
139 /* I have one more opener. */
140 dummybase
->library
.lib_OpenCnt
++;
141 dummybase
->library
.lib_Flags
&=~LIBF_DELEXP
;
143 /* You would return NULL if the open failed. */
148 AROS_LH0(BPTR
, close
, struct dummybase
*, dummybase
, 2, dummy
)
152 This function is single-threaded by exec by calling Forbid.
153 If you break the Forbid() another task may enter this function
154 at the same time. Take care.
157 /* I have one fewer opener. */
158 if(!--dummybase
->library
.lib_OpenCnt
)
160 /* Delayed expunge pending? */
161 if(dummybase
->library
.lib_Flags
&LIBF_DELEXP
)
162 /* Then expunge the library */
169 AROS_LH0(BPTR
, expunge
, struct dummybase
*, dummybase
, 3, dummy
)
175 This function is single-threaded by exec by calling Forbid.
176 Never break the Forbid() or strange things might happen.
179 /* Test for openers. */
180 if(dummybase
->library
.lib_OpenCnt
)
182 /* Set the delayed expunge flag and return. */
183 dummybase
->library
.lib_Flags
|=LIBF_DELEXP
;
187 /* Get rid of the library. Remove it from the list. */
188 Remove(&dummybase
->library
.lib_Node
);
190 /* Get returncode here - FreeMem() will destroy the field. */
191 ret
=dummybase
->seglist
;
193 /* Free the memory. */
194 FreeMem((char *)dummybase
-dummybase
->library
.lib_NegSize
,
195 dummybase
->library
.lib_NegSize
+dummybase
->library
.lib_PosSize
);
200 AROS_LH0I(int, null
, struct dummybase
*, dummybase
, 4, dummy
)
207 AROS_LH2I(ULONG
, add
,
208 AROS_LHA(ULONG
,a
,D0
),
209 AROS_LHA(ULONG
,b
,D1
),
210 struct dummybase
*,dummybase
,5,dummy
)
217 AROS_LH2I(ULONG
, asl
,
218 AROS_LHA(ULONG
,a
,D0
),
219 AROS_LHA(ULONG
,b
,D1
),
220 struct dummybase
*,dummybase
,6,dummy
)