1/*  varargs.h for SPUR */
2
3/* NB.  This is NOT the definition needed for the new ANSI proposed
4   standard */
5
6
7struct __va_struct { char __regs[20]; };
8
9#define va_alist __va_regs, __va_stack
10
11/* In GCC version 2, we want an ellipsis at the end of the declaration
12   of the argument list.  GCC version 1 can't parse it.  */
13
14#if __GNUC__ > 1
15#define __va_ellipsis ...
16#else
17#define __va_ellipsis
18#endif
19
20/* The ... causes current_function_varargs to be set in cc1.  */
21#define va_dcl struct __va_struct __va_regs; int __va_stack;
22
23typedef struct {
24    int __pnt;
25    char *__regs;
26    char *__stack;
27} va_list;
28
29#define va_start(pvar) \
30     ((pvar).__pnt = 0, (pvar).__regs = __va_regs.__regs, \
31      (pvar).__stack = (char *) &__va_stack)
32#define va_end(pvar)	((void)0)
33
34/* Avoid errors if compiling GCC v2 with GCC v1.  */
35#if __GNUC__ == 1
36#define __extension__
37#endif
38
39#define va_arg(pvar,type)  \
40__extension__ \
41    (*({  type *__va_result; \
42        if ((pvar).__pnt >= 20) { \
43           __va_result = ( (type *) ((pvar).__stack + (pvar).__pnt - 20)); \
44	   (pvar).__pnt += (sizeof(type) + 7) & ~7; \
45	} \
46	else if ((pvar).__pnt + sizeof(type) > 20) { \
47	   __va_result = (type *) (pvar).__stack; \
48	   (pvar).__pnt = 20 + ( (sizeof(type) + 7) & ~7); \
49	} \
50	else if (sizeof(type) == 8) { \
51	   union {double d; int i[2];} __u; \
52	   __u.i[0] = *(int *) ((pvar).__regs + (pvar).__pnt); \
53	   __u.i[1] = *(int *) ((pvar).__regs + (pvar).__pnt + 4); \
54	   __va_result = (type *) &__u; \
55	   (pvar).__pnt += 8; \
56	} \
57	else { \
58	   __va_result = (type *) ((pvar).__regs + (pvar).__pnt); \
59	   (pvar).__pnt += (sizeof(type) + 3) & ~3; \
60	} \
61	__va_result; }))
62
63/* Copy __gnuc_va_list into another variable of this type.  */
64#define __va_copy(dest, src) (dest) = (src)
65