]> gcc.gnu.org Git - gcc.git/blob - gcc/ginclude/va-sparc.h
(va_start): If __GCC_NEW_VARARGS__ not defined, use old definition.
[gcc.git] / gcc / ginclude / va-sparc.h
1 /* This is just like the default gvarargs.h
2 except for differences described below. */
3
4 /* Define __gnuc_va_list. */
5
6 #ifndef __GNUC_VA_LIST
7 #define __GNUC_VA_LIST
8
9 #ifndef __svr4__
10 /* This has to be a char * to be compatible with Sun.
11 i.e., we have to pass a `va_list' to vsprintf. */
12 typedef char * __gnuc_va_list;
13 #else
14 /* This has to be a void * to be compatible with Sun svr4.
15 i.e., we have to pass a `va_list' to vsprintf. */
16 typedef void * __gnuc_va_list;
17 #endif
18 #endif /* not __GNUC_VA_LIST */
19
20 /* If this is for internal libc use, don't define anything but
21 __gnuc_va_list. */
22 #if defined (_STDARG_H) || defined (_VARARGS_H)
23
24 #ifdef _STDARG_H
25
26 #ifdef __GCC_NEW_VARARGS__
27 #define va_start(AP, LASTARG) (AP = (char *) __builtin_saveregs ())
28 #else
29 #define va_start(AP, LASTARG) \
30 (__builtin_saveregs (), AP = ((char *) __builtin_next_arg ()))
31 #endif
32
33 #else
34
35 #define va_alist __builtin_va_alist
36 #define va_dcl
37
38 #ifdef __GCC_NEW_VARARGS__
39 #define va_start(AP) ((AP) = (char *) __builtin_saveregs ())
40 #else
41 #define va_start(AP) \
42 (__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
43 #endif
44
45 #endif
46
47 #ifndef va_end
48 void va_end (__gnuc_va_list); /* Defined in libgcc.a */
49 #endif
50 #define va_end(pvar)
51
52 #define __va_rounded_size(TYPE) \
53 (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
54
55 /* Avoid errors if compiling GCC v2 with GCC v1. */
56 #if __GNUC__ == 1
57 #define __extension__
58 #endif
59
60 /* RECORD_TYPE args passed using the C calling convention are
61 passed by invisible reference. ??? RECORD_TYPE args passed
62 in the stack are made to be word-aligned; for an aggregate that is
63 not word-aligned, we advance the pointer to the first non-reg slot. */
64 /* We don't declare the union member `d' to have type TYPE
65 because that would lose in C++ if TYPE has a constructor. */
66 /* We cast to void * and then to TYPE * because this avoids
67 a warning about increasing the alignment requirement. */
68 #define va_arg(pvar,TYPE) \
69 __extension__ \
70 ({ TYPE __va_temp; \
71 ((__builtin_classify_type (__va_temp) >= 12) \
72 ? ((pvar) += __va_rounded_size (TYPE *), \
73 **(TYPE **) (void *) ((pvar) - __va_rounded_size (TYPE *))) \
74 : __va_rounded_size (TYPE) == 8 \
75 ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \
76 __u.__i[0] = ((int *) (void *) (pvar))[0]; \
77 __u.__i[1] = ((int *) (void *) (pvar))[1]; \
78 (pvar) += 8; \
79 *(TYPE *) (void *) __u.__d; }) \
80 : ((pvar) += __va_rounded_size (TYPE), \
81 *((TYPE *) (void *) ((pvar) - __va_rounded_size (TYPE)))));})
82
83 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
84
This page took 0.043129 seconds and 6 git commands to generate.