6 #include <exec/types.h>
7 #include <exec/initializers.h>
9 #include <exec/resident.h>
11 #include <proto/exec.h>
12 #include <proto/iconobject.h>
18 //----------------------------------------------------------------------------
20 // defined in pminit.c
21 extern struct ExecBase
*SysBase
;
25 //----------------------------------------------------------------------------
26 // Standard library functions
28 static LIB_SAVEDS(struct Library
*) LIB_ASM LIB_INTERRUPT
Initlib(LIB_REG(d0
, struct Library
*libbase
),
29 LIB_REG(a0
, struct SegList
*seglist
), LIB_REG(a6
, struct ExecBase
*sysbase
));
31 static LIBFUNC_PROTO(Openlib
, libbase
, struct Library
*);
32 static LIBFUNC_PROTO(Closelib
, libbase
, struct SegList
*);
33 static LIBFUNC_PROTO(Expungelib
, libbase
, struct SegList
*);
34 static LIBFUNC_PROTO(Extfunclib
, libbase
, ULONG
);
36 //----------------------------------------------------------------------------
38 // defined in pmversion.c
41 //----------------------------------------------------------------------------
43 SAVEDS(LONG
) ASM
Libstart(void)
50 static APTR functable
[] =
53 (APTR
) FUNCARRAY_32BIT_NATIVE
,
70 LIBPM_OBSOLETEFilterIMsgA
,
73 LIBPM_InsertMenuItemA
,
84 /* Init table used in library initialization. */
85 static ULONG inittab
[] =
87 sizeof(struct PopupMenuBase
),
95 struct Resident ALIGNED romtag
=
101 RTF_PPC
| RTF_AUTOINIT
,
117 //----------------------------------------------------------------------------
119 static LIB_SAVEDS(struct Library
*) LIB_ASM LIB_INTERRUPT
Initlib(LIB_REG(d0
, struct Library
*libbase
),
120 LIB_REG(a0
, struct SegList
*seglist
), LIB_REG(a6
, struct ExecBase
*sysbase
))
122 struct PopupMenuBase
*PopupMenuBase
= (struct PopupMenuBase
*) libbase
;
126 PopupMenuBase
->pmb_ExecBase
= (struct Library
*) SysBase
;
127 PopupMenuBase
->pmb_Library
.lib_Revision
= POPUPMENU_REVISION
;
128 PopupMenuBase
->pmb_SegList
= (ULONG
) seglist
;
131 if (!IconObjectInit(PopupMenuBase
))
133 CALLLIBFUNC(Expungelib
, &PopupMenuBase
->pmb_Library
);
134 PopupMenuBase
= NULL
;
138 d1(KPrintF(__FILE__
"/" __FUNC__
"/%ld PopupMenuBase=%08lx\n", __LINE__
, PopupMenuBase
));
140 return PopupMenuBase
? &PopupMenuBase
->pmb_Library
: NULL
;
144 static LIBFUNC(Openlib
, libbase
, struct Library
*)
146 struct PopupMenuBase
*PopupMenuBase
= (struct PopupMenuBase
*) libbase
;
148 PopupMenuBase
->pmb_Library
.lib_OpenCnt
++;
149 PopupMenuBase
->pmb_Library
.lib_Flags
&= ~LIBF_DELEXP
;
151 if (!PMLibInit(PopupMenuBase
))
153 d1(KPrintF(__FILE__
"/" __FUNC__
"/%ld fail\n", __LINE__
));
154 CALLLIBFUNC(Closelib
, &PopupMenuBase
->pmb_Library
);
158 d1(KPrintF(__FILE__
"/" __FUNC__
"/%ld success\n", __LINE__
));
160 return &PopupMenuBase
->pmb_Library
;
165 static LIBFUNC(Closelib
, libbase
, struct SegList
*)
167 struct PopupMenuBase
*PopupMenuBase
= (struct PopupMenuBase
*) libbase
;
169 d1(KPrintF(__FILE__
"/" __FUNC__
"/%ld OpenCnt=%lu\n", __LINE__
, PopupMenuBase
->pmb_Library
.lib_OpenCnt
));
171 PopupMenuBase
->pmb_Library
.lib_OpenCnt
--;
173 if (0 == PopupMenuBase
->pmb_Library
.lib_OpenCnt
)
175 if (PopupMenuBase
->pmb_Library
.lib_Flags
& LIBF_DELEXP
)
177 return CALLLIBFUNC(Expungelib
, &PopupMenuBase
->pmb_Library
);
186 static LIBFUNC(Expungelib
, libbase
, struct SegList
*)
188 struct PopupMenuBase
*PopupMenuBase
= (struct PopupMenuBase
*) libbase
;
190 d1(KPrintF(__FILE__
"/" __FUNC__
"/%ld OpenCnt=%lu\n", __LINE__
, PopupMenuBase
->pmb_Library
.lib_OpenCnt
));
192 if (0 == PopupMenuBase
->pmb_Library
.lib_OpenCnt
)
194 ULONG size
= PopupMenuBase
->pmb_Library
.lib_NegSize
+ PopupMenuBase
->pmb_Library
.lib_PosSize
;
195 UBYTE
*ptr
= (UBYTE
*) PopupMenuBase
- PopupMenuBase
->pmb_Library
.lib_NegSize
;
196 struct SegList
*libseglist
= (struct SegList
*) PopupMenuBase
->pmb_SegList
;
198 Remove((struct Node
*) PopupMenuBase
);
199 PMLibCleanup(PopupMenuBase
);
205 PopupMenuBase
->pmb_Library
.lib_Flags
|= LIBF_DELEXP
;
212 static LIBFUNC(Extfunclib
, libbase
, ULONG
)