forwarding a patch that uses the fetch macros to pull in acpica and build it (NicJA).
[AROS.git] / compiler / include / clib / alib_protos.h
blobad66fd09f367b997330a827ef801fa02914a96ca
1 #ifndef CLIB_ALIB_PROTOS_H
2 #define CLIB_ALIB_PROTOS_H
4 /*
5 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Prototypes for amiga.lib
9 Lang: english
12 #if defined(RT_ENABLE) && RT_ENABLE
13 #include <aros/rt.h>
14 #endif
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>
28 __BEGIN_DECLS
30 struct MsgPort;
31 struct IORequest;
32 struct Task;
33 struct InputEvent;
34 struct Locale;
36 Prototypes
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);
42 /* Dos support */
43 BPTR ErrorOutput(void);
44 BPTR SelectErrorOutput(BPTR fh);
46 /* Exec support */
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);
58 #endif
60 /* Extra */
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);
71 /* Commodities */
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);
81 /* Graphics */
82 #ifndef ObtainBestPen
83 LONG ObtainBestPen( struct ColorMap * cm, ULONG r, ULONG g, ULONG b, Tag tag1, ...) __stackparm;
84 #endif
86 #ifndef GetRPAttrs
87 void GetRPAttrs( struct RastPort * rp, Tag tag1, ...) __stackparm;
88 #endif
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);
94 /* Intuition */
95 #ifndef SetWindowPointer
96 void SetWindowPointer( struct Window * window, ULONG tag1, ...) __stackparm;
97 #endif
99 /* BOOPSI */
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;
110 /* Locale */
111 #ifndef OpenCatalog
112 struct Catalog *OpenCatalog(const struct Locale * locale,
113 CONST_STRPTR name,
114 Tag tag1,
115 ...) __stackparm;
116 #endif
118 /* Pools */
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);
124 /* Aligned */
125 APTR LibAllocAligned (IPTR memSize, ULONG requirements, IPTR alignBytes);
127 /* Hook Support */
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
136 #endif
138 #ifdef AROS_SLOWSTACKMETHODS
139 Msg GetMsgFromStack (IPTR MethodID, va_list args);
140 void FreeMsgFromStack (Msg msg);
142 # define AROS_NR_SLOWSTACKMETHODS_PRE(arg) \
143 va_list args; \
144 Msg msg; \
146 va_start (args, arg); \
148 if ((msg = GetMsgFromStack (arg, args))) \
151 # define AROS_SLOWSTACKMETHODS_PRE_AS(arg, type) \
152 type retval; \
154 va_list args; \
155 Msg msg; \
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); \
170 else \
171 retval = (AROS_METHODRETURNTYPE)0L; \
173 va_end (args); \
175 return retval;
177 # define AROS_NR_SLOWSTACKMETHODS_POST \
178 FreeMsgFromStack (msg); \
181 va_end (args);
182 #else
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
198 #endif
200 #ifdef AROS_SLOWSTACKHOOKS
201 APTR GetParamsFromStack (va_list args);
202 void FreeParamsFromStack (APTR params);
204 # define AROS_NR_SLOWSTACKHOOKS_PRE(arg) \
205 va_list args; \
206 APTR params; \
208 va_start (args, arg); \
210 if ((params = GetParamsFromStack (args))) \
213 # define AROS_SLOWSTACKHOOKS_PRE(arg) \
214 AROS_HOOKRETURNTYPE retval; \
216 va_list args; \
217 APTR params; \
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); \
229 else \
230 retval = (AROS_HOOKRETURNTYPE)0L; \
232 va_end (args); \
234 return retval;
236 # define AROS_NR_SLOWSTACKHOOKS_POST \
237 FreeParamsFromStack (params); \
240 va_end (args);
241 #else
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 */
249 #include <stdarg.h>
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) { \
259 va_list _args; \
260 RAWARG _data; \
261 ULONG _datasize = 0; \
262 ULONG * _index; \
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); \
271 va_end (_args);
273 # define AROS_SLOWSTACKFORMAT_PRE(format) \
274 AROS_SLOWSTACKFORMAT_PRE_USING(format, format)
275 # define AROS_SLOWSTACKFORMAT_ARG(format) \
276 _data
277 # define AROS_SLOWSTACKFORMAT_POST(format) \
279 #else
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.
286 #include <stdarg.h>
287 # define AROS_SLOWSTACKFORMAT_PRE_USING(last, format) { \
288 va_list _list; \
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) \
294 _data
295 # define AROS_SLOWSTACKFORMAT_POST(format) \
296 va_end(_list); \
298 #endif /* AROS_SLOWSTACKFORMAT */
301 /* Rexx support */
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) \
310 ({ \
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...) \
320 ({ \
321 IPTR __args[] = { AROS_PP_VARIADIC_CAST2IPTR(args) }; \
322 SetSuperAttrsA((cl), (object), (struct TagItem *) __args); \
324 # define DoMethodA(object, message) \
325 ({ \
326 (object) != NULL ? \
327 ({ \
328 CALLHOOKPKT \
330 (struct Hook *) OCLASS((object)), (object), (message) \
331 ); \
332 }) \
337 # define DoMethod(object, methodid, args...) \
338 ({ \
339 IPTR __args[] = {methodid, AROS_PP_VARIADIC_CAST2IPTR(args)}; \
340 DoMethodA((object), __args); \
343 # define DoSuperMethodA(cl, object, message) \
344 ({ \
345 ((cl) != NULL && (object) != NULL) ? \
346 CALLHOOKPKT \
348 (struct Hook *) ((Class *) (cl))->cl_Super, \
349 (object), (message) \
355 # define DoSuperMethod(cl, object, methodid, args...) \
356 ({ \
357 IPTR __args[] = {methodid, AROS_PP_VARIADIC_CAST2IPTR(args)}; \
358 DoSuperMethodA((cl), (object), __args); \
361 # define CoerceMethodA(cl, object, message) \
362 ({ \
363 ((cl) != NULL && (object) != NULL) ? \
364 CALLHOOKPKT((struct Hook *) (cl), (object), (message)) \
369 # define CoerceMethod(cl, object, methodid, args...) \
370 ({ \
371 IPTR __args[] = {methodid, AROS_PP_VARIADIC_CAST2IPTR(args)}; \
372 CoerceMethodA((cl), (object), __args); \
374 # define DoSuperNewTagList(cl, object, gadgetinfo, tags) \
375 ({ \
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...) \
389 ({ \
390 IPTR __args[] = {AROS_PP_VARIADIC_CAST2IPTR(args)}; \
391 DoSuperNewTagList \
393 (cl), (object), (gadgetinfo), (struct TagItem *) __args \
394 ); \
397 #define CallHook(hook, object, args...) \
398 ({ \
399 IPTR __args[] = {AROS_PP_VARIADIC_CAST2IPTR(args)}; \
400 CallHookA((hook), (object), __args); \
403 #endif /* !ALIB_NO_INLINE_STDARG && !NO_INLINE_STDARG */
405 __END_DECLS
407 #endif /* CLIB_ALIB_PROTOS_H */