1 #ifndef CLIB_ALIB_PROTOS_H
2 #define CLIB_ALIB_PROTOS_H
5 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
8 Desc: Prototypes for amiga.lib
12 #if defined(RT_ENABLE) && RT_ENABLE
16 #include <aros/asmcall.h>
17 #include <devices/inputevent.h>
18 #include <devices/keymap.h>
19 #include <intuition/classes.h>
20 #include <intuition/classusr.h>
21 #include <intuition/intuition.h>
22 #include <intuition/screens.h>
23 #include <libraries/commodities.h>
24 #include <libraries/gadtools.h>
25 #include <rexx/storage.h>
26 #include <utility/hooks.h>
38 IPTR
CallHookA (struct Hook
* hook
, APTR obj
, APTR param
);
39 IPTR
CallHook (struct Hook
* hook
, APTR obj
, ...) __stackparm
;
40 UBYTE
* ACrypt(UBYTE
* buffer
, const UBYTE
* password
, const UBYTE
* user
);
43 BPTR
ErrorOutput(void);
44 BPTR
SelectErrorOutput(BPTR fh
);
47 VOID
BeginIO (struct IORequest
*ioReq
);
48 struct IORequest
* CreateExtIO (struct MsgPort
* port
, ULONG iosize
);
49 struct IOStdReq
* CreateStdIO (struct MsgPort
* port
);
50 void DeleteExtIO (struct IORequest
* ioreq
);
51 void DeleteStdIO (struct IOStdReq
* ioreq
);
52 struct Task
* CreateTask (STRPTR name
, LONG pri
, APTR initpc
, ULONG stacksize
);
53 void DeleteTask (struct Task
* task
);
54 void NewList (struct List
*);
55 #if !defined(ENABLE_RT) || !ENABLE_RT
56 struct MsgPort
* CreatePort (STRPTR name
, LONG pri
);
57 void DeletePort (struct MsgPort
* mp
);
61 extern ULONG RangeSeed
;
62 ULONG
RangeRand (ULONG maxValue
);
63 ULONG
FastRand (ULONG seed
);
64 LONG
TimeDelay (LONG unit
, ULONG secs
, ULONG microsecs
);
65 void waitbeam (LONG pos
);
66 void __sprintf(UBYTE
*buffer
, const UBYTE
*format
, ...);
67 STRPTR
StrDup(CONST_STRPTR str
);
69 void MergeSortList(struct MinList
*l
, int (*compare
)(struct MinNode
*n1
, struct MinNode
*n2
, void *data
), void *data
);
72 CxObj
*HotKey (STRPTR description
, struct MsgPort
*port
, LONG id
);
73 VOID
FreeIEvents (struct InputEvent
*events
);
74 UBYTE
**ArgArrayInit(ULONG argc
, UBYTE
**argv
);
75 VOID
ArgArrayDone(VOID
);
76 LONG
ArgInt(UBYTE
**tt
, STRPTR entry
, LONG defaultVal
);
77 STRPTR
ArgString(UBYTE
**tt
, STRPTR entry
, STRPTR defaultstring
);
78 struct InputEvent
*InvertString(STRPTR str
, struct KeyMap
*km
);
79 struct InputEvent
*InvertStringForwd(STRPTR str
, struct KeyMap
*km
);
83 LONG
ObtainBestPen( struct ColorMap
* cm
, ULONG r
, ULONG g
, ULONG b
, Tag tag1
, ...) __stackparm
;
87 void GetRPAttrs( struct RastPort
* rp
, Tag tag1
, ...) __stackparm
;
90 BOOL
AndRectRect(struct Rectangle
*rect1
, struct Rectangle
*rect2
, struct Rectangle
*intersect
);
91 struct Region
*CopyRegion(struct Region
*region
);
92 struct Region
*NewRectRegion(WORD MinX
, WORD MinY
, WORD MaxX
, WORD MaxY
);
95 #ifndef SetWindowPointer
96 void SetWindowPointer( struct Window
* window
, ULONG tag1
, ...) __stackparm
;
100 IPTR
DoMethodA (Object
* obj
, Msg message
);
101 IPTR
DoMethod (Object
* obj
, STACKULONG MethodID
, ...) __stackparm
;
102 IPTR
DoSuperMethodA (Class
* cl
, Object
* obj
, Msg message
);
103 IPTR
DoSuperMethod (Class
* cl
, Object
* obj
, STACKULONG MethodID
, ...) __stackparm
;
104 IPTR
CoerceMethodA (Class
* cl
, Object
* obj
, Msg message
);
105 IPTR
CoerceMethod (Class
* cl
, Object
* obj
, STACKULONG MethodID
, ...) __stackparm
;
106 IPTR
DoSuperNewTagList(Class
*CLASS
, Object
*object
, struct GadgetInfo
*gadgetInfo
, struct TagItem
*tags
);
107 IPTR
DoSuperNewTags(Class
*CLASS
, Object
*object
, struct GadgetInfo
*gadgetInfo
, Tag tag1
, ...) __stackparm
;
108 IPTR
SetSuperAttrs (Class
* cl
, Object
* obj
, Tag tag1
, ...) __stackparm
;
112 struct Catalog
*OpenCatalog(const struct Locale
* locale
,
119 APTR
LibCreatePool (ULONG requirements
, ULONG puddleSize
, ULONG threshSize
);
120 void LibDeletePool (APTR poolHeader
);
121 APTR
LibAllocPooled (APTR poolHeader
, ULONG memSize
);
122 void LibFreePooled (APTR poolHeader
, APTR memory
, ULONG memSize
);
125 APTR
LibAllocAligned (IPTR memSize
, ULONG requirements
, IPTR alignBytes
);
128 AROS_UFP3(IPTR
, HookEntry
,
129 AROS_UFPA(struct Hook
*, hook
, A0
),
130 AROS_UFPA(APTR
, obj
, A2
),
131 AROS_UFPA(APTR
, param
, A1
)
134 #ifndef AROS_METHODRETURNTYPE
135 # define AROS_METHODRETURNTYPE IPTR
138 #ifdef AROS_SLOWSTACKMETHODS
139 Msg
GetMsgFromStack (IPTR MethodID
, va_list args
);
140 void FreeMsgFromStack (Msg msg
);
142 # define AROS_NR_SLOWSTACKMETHODS_PRE(arg) \
146 va_start (args, arg); \
148 if ((msg = GetMsgFromStack (arg, args))) \
151 # define AROS_SLOWSTACKMETHODS_PRE_AS(arg, type) \
157 va_start (args, arg); \
159 if ((msg = GetMsgFromStack (arg, args))) \
162 # define AROS_SLOWSTACKMETHODS_PRE(arg) \
163 AROS_SLOWSTACKMETHODS_PRE_AS(arg, AROS_METHODRETURNTYPE)
165 # define AROS_SLOWSTACKMETHODS_ARG(arg) msg
167 # define AROS_SLOWSTACKMETHODS_POST \
168 FreeMsgFromStack (msg); \
171 retval = (AROS_METHODRETURNTYPE)0L; \
177 # define AROS_NR_SLOWSTACKMETHODS_POST \
178 FreeMsgFromStack (msg); \
183 # define AROS_NR_SLOWSTACKMETHODS_PRE(arg)
184 # define AROS_SLOWSTACKMETHODS_PRE(arg) AROS_METHODRETURNTYPE retval;
185 # define AROS_SLOWSTACKMETHODS_PRE_AS(arg, type) type retval;
186 # define AROS_SLOWSTACKMETHODS_ARG(arg) ((Msg)&(arg))
187 # define AROS_SLOWSTACKMETHODS_POST return retval;
188 # define AROS_NR_SLOWSTACKMETHODS_POST
189 #endif /* AROS_SLOWSTACKMETHODS */
191 #ifdef AROS_SLOWSTACKTAGS
192 struct TagItem
* GetTagsFromStack (IPTR firstTag
, va_list args
);
193 void FreeTagsFromStack (struct TagItem
* tags
);
194 #endif /* AROS_SLOWSTACKTAGS */
196 #ifndef AROS_HOOKRETURNTYPE
197 # define AROS_HOOKRETURNTYPE IPTR
200 #ifdef AROS_SLOWSTACKHOOKS
201 APTR
GetParamsFromStack (va_list args
);
202 void FreeParamsFromStack (APTR params
);
204 # define AROS_NR_SLOWSTACKHOOKS_PRE(arg) \
208 va_start (args, arg); \
210 if ((params = GetParamsFromStack (args))) \
213 # define AROS_SLOWSTACKHOOKS_PRE(arg) \
214 AROS_HOOKRETURNTYPE retval; \
219 va_start (args, arg); \
221 if ((params = GetParamsFromStack (args))) \
224 # define AROS_SLOWSTACKHOOKS_ARG(arg) params
226 # define AROS_SLOWSTACKHOOKS_POST \
227 FreeParamsFromStack (params); \
230 retval = (AROS_HOOKRETURNTYPE)0L; \
236 # define AROS_NR_SLOWSTACKHOOKS_POST \
237 FreeParamsFromStack (params); \
242 # define AROS_NR_SLOWSTACKHOOKS_PRE(arg)
243 # define AROS_SLOWSTACKHOOKS_PRE(arg) AROS_HOOKRETURNTYPE retval;
244 # define AROS_SLOWSTACKHOOKS_ARG(arg) ((IPTR*)&(arg)+1)
245 # define AROS_SLOWSTACKHOOKS_POST return retval;
246 # define AROS_NR_SLOWSTACKHOOKS_POST
247 #endif /* AROS_SLOWSTACKHOOKS */
251 void GetDataStreamFromFormat(CONST_STRPTR format
, va_list args
,
252 RAWARG dataStream
, ULONG
*dataSize
,
253 ULONG
*indexStream
, ULONG
*indexSize
);
255 #ifdef AROS_SLOWSTACKFORMAT
256 #include <aros/posixc/alloca.h>
258 # define AROS_SLOWSTACKFORMAT_PRE_USING(last, format) { \
261 ULONG _datasize = 0; \
263 ULONG _indexsize = 0; \
265 va_start(_args, last); \
266 GetDataStreamFromFormat (format, _args, NULL, NULL, NULL, &_indexsize); \
267 _index = (ULONG *)alloca(_indexsize); \
268 GetDataStreamFromFormat (format, _args, NULL, &_datasize, _index, &_indexsize); \
269 _data = (RAWARG)alloca(_datasize); \
270 GetDataStreamFromFormat (format, _args, _data, &_datasize, _index, &_indexsize); \
273 # define AROS_SLOWSTACKFORMAT_PRE(format) \
274 AROS_SLOWSTACKFORMAT_PRE_USING(format, format)
275 # define AROS_SLOWSTACKFORMAT_ARG(format) \
277 # define AROS_SLOWSTACKFORMAT_POST(format) \
280 /* We 'mark' functions that use these macros as non-inlineable
281 * to gcc by using the va_start()/va_end() macro pairs.
283 * This prevents the optimizer from breaking the '&(last)+1'
284 * trick to access the datastream after the last argument.
287 # define AROS_SLOWSTACKFORMAT_PRE_USING(last, format) { \
289 RAWARG _data = (RAWARG)(&(last)+1); \
290 va_start(_list, last);
291 # define AROS_SLOWSTACKFORMAT_PRE(format) \
292 AROS_SLOWSTACKFORMAT_PRE_USING(format, format)
293 # define AROS_SLOWSTACKFORMAT_ARG(format) \
295 # define AROS_SLOWSTACKFORMAT_POST(format) \
298 #endif /* AROS_SLOWSTACKFORMAT */
302 BOOL
CheckRexxMsg(struct RexxMsg
*);
303 LONG
SetRexxVar(struct RexxMsg
*, CONST_STRPTR var
, char *value
, ULONG length
);
304 LONG
GetRexxVar(struct RexxMsg
*, CONST_STRPTR var
, char **value
);
306 /* Inline versions of varargs functions */
307 #if !defined(ALIB_NO_INLINE_STDARG) && !defined(NO_INLINE_STDARG)
309 # define SetSuperAttrsA(cl, object, attrs) \
311 struct opSet __ops; \
313 __ops.MethodID = OM_SET; \
314 __ops.ops_AttrList = (attrs); \
315 __ops.ops_GInfo = NULL; \
317 DoSuperMethodA((cl), (object), (Msg) &__ops.MethodID); \
319 # define SetSuperAttrs(cl, object, args...) \
321 IPTR __args[] = { AROS_PP_VARIADIC_CAST2IPTR(args) }; \
322 SetSuperAttrsA((cl), (object), (struct TagItem *) __args); \
324 # define DoMethodA(object, message) \
330 (struct Hook *) OCLASS((object)), (object), (message) \
337 # define DoMethod(object, methodid, args...) \
339 IPTR __args[] = {methodid, AROS_PP_VARIADIC_CAST2IPTR(args)}; \
340 DoMethodA((object), __args); \
343 # define DoSuperMethodA(cl, object, message) \
345 ((cl) != NULL && (object) != NULL) ? \
348 (struct Hook *) ((Class *) (cl))->cl_Super, \
349 (object), (message) \
355 # define DoSuperMethod(cl, object, methodid, args...) \
357 IPTR __args[] = {methodid, AROS_PP_VARIADIC_CAST2IPTR(args)}; \
358 DoSuperMethodA((cl), (object), __args); \
361 # define CoerceMethodA(cl, object, message) \
363 ((cl) != NULL && (object) != NULL) ? \
364 CALLHOOKPKT((struct Hook *) (cl), (object), (message)) \
369 # define CoerceMethod(cl, object, methodid, args...) \
371 IPTR __args[] = {methodid, AROS_PP_VARIADIC_CAST2IPTR(args)}; \
372 CoerceMethodA((cl), (object), __args); \
374 # define DoSuperNewTagList(cl, object, gadgetinfo, tags) \
376 struct opSet __ops; \
378 __ops.MethodID = OM_NEW; \
379 __ops.ops_AttrList = (tags); \
380 __ops.ops_GInfo = (gadgetinfo); \
382 (cl) != NULL && (object) != NULL ? \
383 DoSuperMethodA((cl), (object), (Msg)&__ops.MethodID) \
388 # define DoSuperNewTags(cl, object, gadgetinfo, args...) \
390 IPTR __args[] = {AROS_PP_VARIADIC_CAST2IPTR(args)}; \
393 (cl), (object), (gadgetinfo), (struct TagItem *) __args \
397 #define CallHook(hook, object, args...) \
399 IPTR __args[] = {AROS_PP_VARIADIC_CAST2IPTR(args)}; \
400 CallHookA((hook), (object), __args); \
403 #endif /* !ALIB_NO_INLINE_STDARG && !NO_INLINE_STDARG */
407 #endif /* CLIB_ALIB_PROTOS_H */