Initial revision
[official-gcc.git] / gcc / ginclude / va-spur.h
blob912a23987108d893939bbf239d11d16b9cc9d4fc
1 /* varargs.h for SPUR */
3 /* NB. This is NOT the definition needed for the new ANSI proposed
4 standard */
7 struct __va_struct { char __regs[20]; };
9 #define va_alist __va_regs, __va_stack
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. */
14 #if __GNUC__ > 1
15 #define __va_ellipsis ...
16 #else
17 #define __va_ellipsis
18 #endif
20 /* The ... causes current_function_varargs to be set in cc1. */
21 #define va_dcl struct __va_struct __va_regs; int __va_stack;
23 typedef struct {
24 int __pnt;
25 char *__regs;
26 char *__stack;
27 } va_list;
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)
34 #define va_arg(pvar,type) \
35 ({ type __va_result; \
36 if ((pvar).__pnt >= 20) { \
37 __va_result = *( (type *) ((pvar).__stack + (pvar).__pnt - 20)); \
38 (pvar).__pnt += (sizeof(type) + 7) & ~7; \
39 } \
40 else if ((pvar).__pnt + sizeof(type) > 20) { \
41 __va_result = * (type *) (pvar).__stack; \
42 (pvar).__pnt = 20 + ( (sizeof(type) + 7) & ~7); \
43 } \
44 else if (sizeof(type) == 8) { \
45 union {double d; int i[2];} __u; \
46 __u.i[0] = *(int *) ((pvar).__regs + (pvar).__pnt); \
47 __u.i[1] = *(int *) ((pvar).__regs + (pvar).__pnt + 4); \
48 __va_result = * (type *) &__u; \
49 (pvar).__pnt += 8; \
50 } \
51 else { \
52 __va_result = * (type *) ((pvar).__regs + (pvar).__pnt); \
53 (pvar).__pnt += (sizeof(type) + 3) & ~3; \
54 } \
55 __va_result; })