2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 Internal utility functions.
8 #include <aros/system.h>
9 #include "alib_intern.h"
11 #ifdef AROS_SLOWSTACKMETHODS
12 /******************************************************************************
22 Builds a message structure with the parameters which are passed on
23 the stack. This function is used on machines which have compilers
24 which don't pass the arguments to a varargs function unlike the
28 MethodID - This is the ID of the message
29 args - This has to be initialized by va_start()
30 firstlocal - The address of the first local function of the
31 function which wants to call GetMsgFromStack()
34 A message which can be passed to any function which expects the
35 structure which is defined for this MethodID or NULL if something
36 failed. This call may fail for different reasons on different
37 systems. On some systems, NULL indicates that there was not enough
38 memory, on others that the MethodID is unknown.
41 This function fails for structures with more than 20 fields.
48 NewObject(), SetAttrs(), GetAttr(), DisposeObject(), DoMethod(),
49 DoSuperMethod(), "Basic Object-Oriented Programming System for
50 Intuition" and the "boopsi Class Reference" Dokument.
53 HPPA: Allocate a structure which can contain all ULONGs between
54 the first argument of, for example, DoMethod() and its first local
55 variable. This will copy a bit too much memory but in the end, it
56 saves a lot of work, since it's not neccessary to register every
60 22.11.96 digulla created
62 ******************************************************************************/
64 #if !AROS_STACK_GROWS_DOWNWARDS
70 if ((msg
= AllocVec (size
* sizeof (ULONG
), MEMF_CLEAR
)))
72 ULONG
* ulptr
= (ULONG
* msg
);
78 *ulptr
++ = va_arg (args
, ULONG
);
86 } /* GetMsgFromStack */
88 /******************************************************************************
91 void FreeMsgFromStack (
97 Frees the memory occupied by the message which was created by
101 msg - The return value of GetMsgFromStack(). May be NULL.
116 22.11.96 digulla created
118 ******************************************************************************/
122 } /* FreeMsgFromStack */
124 #endif /* AROS_SLOWSTACKMETHODS */
126 #ifdef AROS_SLOWSTACKTAGS
127 /******************************************************************************
130 struct TagItem
* GetTagsFromStack (
137 Builds a tagitem array with the tags on the stack. This function is
138 used on machines which have compilers which don't pass the
139 arguments to a varargs function unlike the Amiga ones.
142 firstTag - This is the first tag passed to the function
143 args - This has to be initialized by va_start()
146 A TagItem array which can be passed to any function which expects
147 such an array or NULL if something failed. This call may fail for
148 different reasons on different systems. On some systems, NULL
149 indicates that there was not enough memory, on others that the
159 NewObject(), SetAttrs(), GetAttr(), DisposeObject(), DoMethod(),
160 DoSuperMethod(), "Basic Object-Oriented Programming System for
161 Intuition" and the "boopsi Class Reference" Dokument.
164 Allocate a structure which can contain all tags until the first
165 TAG_END. This takes into account TAG_MORE and the like. The code
166 will break if someone makes assumptions about the way taglists
167 are built in memory, ie. if he looks for the next TAG_MORE and
168 then simply skips it instead of following it.
171 22.11.96 digulla created
173 ******************************************************************************/
185 if (tag
== TAG_END
|| tag
== TAG_MORE
)
187 size
++; /* Copy this tag, too */
194 size
--; /* Don't copy this tag */
200 skip
= va_arg(args
, IPTR
);
204 (void) va_arg(args
, ULONG
);
205 (void) va_arg(args
, IPTR
);
211 (void) va_arg(args
, IPTR
);
214 tag
= va_arg (args
, ULONG
);
219 if ((msg
= AllocVec (size
*sizeof(TagItem
), MEMF_ANY
)))
223 ti
[size
].ti_Tag
= tag
;
227 else if (tag
== TAG_MORE
)
229 ti
[size
].ti_Data
= (IPTR
) va_arg (ap
, struct TagItem
*);
236 size
--; /* Don't copy this tag */
242 skip
= va_arg(ap
, IPTR
);
246 (void) va_arg(ap
, ULONG
);
247 (void) va_arg(ap
, IPTR
);
253 ti
[size
].ti_Data
= va_arg(ap
, IPTR
);
256 tag
= va_arg (ap
, ULONG
);
261 } /* GetTagsFromStack */
263 /******************************************************************************
266 void FreeTagsFromStack (
269 struct TagItem
* tags
)
272 Frees the memory occupied by the tagitems which were created by
276 tags - The return value of GetTagsFromStack(). May be NULL.
291 22.11.96 digulla created
293 ******************************************************************************/
297 } /* FreeTagsFromStack */
299 #endif /* AROS_SLOWSTACKTAGS */