home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum7.lzh
/
RICO
/
C
/
LIBSOURCE
/
ARGPROC
/
varargs.h
< prev
Wrap
Text File
|
2009-11-06
|
1KB
|
52 lines
/* OS9 variable arguments passing functions,
recommended use:
function(<known args>, va_alist)
<known args declarations>
va_dcl
{ <local var declarations>
va_list va;
va_start(&va);
<arg1> = va_arg(&va,<arg1 type>);
<arg2> = va_arg(&va,<arg2 type>);
...
va_end(&va);
<rest of function>
}
Any arguments of integral type (integers, pointers ...) and
doubles are accessible. */
/* item - basic argument type passed on the stack */
typedef unsigned long int item;
/* va_list - information necessary to access arguments */
typedef struct { short int num, cont1, cont2;
item *next, *arg1, *args; } va_list;
/* OS9 Microware C passes the first 2 arguments in registers,
so we have to handle them separately */
#define va_alist _arg0_,_arg1_,_args_
#define va_dcl item _arg0_,_arg1_,_args_;
/* necessary(type) - how many items are necessary for type ? */
#define necessary(type) ((sizeof(type)+sizeof(item)-1)/sizeof(item))
#define _LITTLE_ necessary(item)
#define _BIG_ (_LITTLE_+_LITTLE_)
/* va_start(va) - initialize va to the first argument */
/* if _arg0_,_arg1_ and _args_ have subsequent adresses,
no special handling is necessary */
#define va_start(va) _va_init(va,&_arg0_,&_arg1_,&_args_)
/* va_arg(va,type) - get next argument of type */
#define va_arg(va,type) *(type *)_va_get(va,necessary(type))
/* va_end(va) - end of argument parsing */
#define va_end(va)