|
|
1.1 root 1: /* GNU C varargs support for the Motorola 88100 */
2:
1.1.1.2 ! root 3: /* Define __gnuc_va_list. */
! 4:
! 5: #ifndef __GNUC_VA_LIST
! 6: #define __GNUC_VA_LIST
1.1 root 7:
8: typedef struct
9: {
10: int __va_arg; /* argument number */
11: int *__va_stk; /* start of args passed on stack */
12: int *__va_reg; /* start of args passed in regs */
1.1.1.2 ! root 13: } __gnuc_va_list;
! 14: #endif /* not __GNUC_VA_LIST */
1.1 root 15:
1.1.1.2 ! root 16: /* If this is for internal libc use, don't define anything but
! 17: __gnuc_va_list. */
! 18: #if defined (_STDARG_H) || defined (_VARARGS_H)
1.1 root 19:
20: #ifdef _STDARG_H /* stdarg.h support */
21:
22: #if __GNUC__ > 1 /* GCC 2.0 and beyond */
1.1.1.2 ! root 23: #define va_start(AP,LASTARG) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
1.1 root 24: #else
25: #define va_start(AP,LASTARG) \
26: ( (AP).__va_reg = (int *) __builtin_saveregs2(0), \
27: (AP).__va_stk = (int *) __builtin_argptr(), \
28: (AP).__va_arg = (int) (__builtin_argsize() + 3) / 4 )
29: #endif
30:
31: #else /* varargs.h support */
32:
33: #if __GNUC__ > 1 /* GCC 2.0 and beyond */
1.1.1.2 ! root 34: #define va_start(AP) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
1.1 root 35: #else
36: #define va_start(AP) \
37: ( (AP).__va_reg = (int *) __builtin_saveregs2(1), \
38: (AP).__va_stk = (int *) __builtin_argptr(), \
39: (AP).__va_arg = (int) (__builtin_argsize() - 4 + 3) / 4 )
40: #endif
41: #define va_alist __va_1st_arg
42: #define va_dcl register int va_alist;
43:
44: #endif /* _STDARG_H */
45:
1.1.1.2 ! root 46: /* Avoid trouble between this file and _int_varargs.h under DG/UX. This file
! 47: can be included by <stdio.h> and others and provides definitions of
! 48: __va_size and __va_reg_p and a va_list typedef. Avoid defining va_list
! 49: again with _VA_LIST. */
! 50: #ifdef __INT_VARARGS_H
! 51: #undef __va_size
! 52: #undef __va_reg_p
! 53: #define __gnuc_va_list va_list
! 54: #define _VA_LIST
! 55: #else
! 56: /* Similarly, if this gets included first, do nothing in _int_varargs.h. */
! 57: #define __INT_VARARGS_H
! 58: #endif
! 59:
1.1 root 60: #define __va_reg_p(TYPE) \
61: (__builtin_classify_type(*(TYPE *)0) < 12 \
62: ? sizeof(TYPE) <= 8 : sizeof(TYPE) == 4 && __alignof__(TYPE) == 4)
63:
64: #define __va_size(TYPE) ((sizeof(TYPE) + 3) >> 2)
65:
1.1.1.2 ! root 66: /* We cast to void * and then to TYPE * because this avoids
! 67: a warning about increasing the alignment requirement. */
! 68: #define va_arg(AP,TYPE) \
1.1 root 69: ( (AP).__va_arg = (((AP).__va_arg + (1 << (__alignof__(TYPE) >> 3)) - 1) \
1.1.1.2 ! root 70: & ~((1 << (__alignof__(TYPE) >> 3)) - 1)) \
! 71: + __va_size(TYPE), \
! 72: *((TYPE *) (void *) ((__va_reg_p(TYPE) \
! 73: && (AP).__va_arg < 8 + __va_size(TYPE) \
! 74: ? (AP).__va_reg : (AP).__va_stk) \
! 75: + ((AP).__va_arg - __va_size(TYPE)))))
1.1 root 76:
77: #define va_end(AP)
1.1.1.2 ! root 78:
! 79: #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.