]> gcc.gnu.org Git - gcc.git/blame - gcc/ginclude/va-m88k.h
Test _VA_LIST_DEFINED macro.
[gcc.git] / gcc / ginclude / va-m88k.h
CommitLineData
f451fe61
RS
1/* GNU C varargs support for the Motorola 88100 */
2
536bb15b
CH
3/* Define __gnuc_va_list. */
4
5#ifndef __GNUC_VA_LIST
6#define __GNUC_VA_LIST
f451fe61
RS
7
8typedef 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 */
536bb15b
CH
13} __gnuc_va_list;
14#endif /* not __GNUC_VA_LIST */
f451fe61 15
536bb15b
CH
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)
f451fe61
RS
19
20#ifdef _STDARG_H /* stdarg.h support */
21
a20dcf46
JW
22/* Call __builtin_next_arg even though we aren't using its value, so that
23 we can verify that LASTARG is correct. */
f451fe61 24#if __GNUC__ > 1 /* GCC 2.0 and beyond */
a20dcf46
JW
25#define va_start(AP,LASTARG) \
26 (__builtin_next_arg (LASTARG), \
27 (AP) = *(__gnuc_va_list *)__builtin_saveregs())
f451fe61
RS
28#else
29#define va_start(AP,LASTARG) \
30 ( (AP).__va_reg = (int *) __builtin_saveregs2(0), \
31 (AP).__va_stk = (int *) __builtin_argptr(), \
32 (AP).__va_arg = (int) (__builtin_argsize() + 3) / 4 )
33#endif
34
35#else /* varargs.h support */
36
37#if __GNUC__ > 1 /* GCC 2.0 and beyond */
536bb15b 38#define va_start(AP) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
f451fe61
RS
39#else
40#define va_start(AP) \
41 ( (AP).__va_reg = (int *) __builtin_saveregs2(1), \
42 (AP).__va_stk = (int *) __builtin_argptr(), \
43 (AP).__va_arg = (int) (__builtin_argsize() - 4 + 3) / 4 )
44#endif
45#define va_alist __va_1st_arg
bc97bfd8 46#define va_dcl register int va_alist;...
f451fe61
RS
47
48#endif /* _STDARG_H */
49
536bb15b
CH
50/* Avoid trouble between this file and _int_varargs.h under DG/UX. This file
51 can be included by <stdio.h> and others and provides definitions of
52 __va_size and __va_reg_p and a va_list typedef. Avoid defining va_list
53 again with _VA_LIST. */
54#ifdef __INT_VARARGS_H
55#undef __va_size
56#undef __va_reg_p
57#define __gnuc_va_list va_list
58#define _VA_LIST
550549f2 59#define _VA_LIST_
5c09c899
TW
60#else
61/* Similarly, if this gets included first, do nothing in _int_varargs.h. */
62#define __INT_VARARGS_H
536bb15b
CH
63#endif
64
f451fe61
RS
65#define __va_reg_p(TYPE) \
66 (__builtin_classify_type(*(TYPE *)0) < 12 \
67 ? sizeof(TYPE) <= 8 : sizeof(TYPE) == 4 && __alignof__(TYPE) == 4)
68
69#define __va_size(TYPE) ((sizeof(TYPE) + 3) >> 2)
70
7436f435
RS
71/* We cast to void * and then to TYPE * because this avoids
72 a warning about increasing the alignment requirement. */
73#define va_arg(AP,TYPE) \
f451fe61 74 ( (AP).__va_arg = (((AP).__va_arg + (1 << (__alignof__(TYPE) >> 3)) - 1) \
7436f435
RS
75 & ~((1 << (__alignof__(TYPE) >> 3)) - 1)) \
76 + __va_size(TYPE), \
77 *((TYPE *) (void *) ((__va_reg_p(TYPE) \
78 && (AP).__va_arg < 8 + __va_size(TYPE) \
79 ? (AP).__va_reg : (AP).__va_stk) \
80 + ((AP).__va_arg - __va_size(TYPE)))))
f451fe61
RS
81
82#define va_end(AP)
536bb15b
CH
83
84#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
This page took 0.239146 seconds and 5 git commands to generate.