Add definition of __va_copy.
[gcc.git] / gcc / ginclude / va-alpha.h
1 /* GNU C varargs and stdargs support for the DEC Alpha. */
2
3 /* Note: We must use the name __builtin_savregs. GCC attaches special
4 significance to that name. In particular, regardless of where in a
5 function __builtin_saveregs is called, GCC moves the call up to the
6 very start of the function. */
7
8 /* Define __gnuc_va_list. */
9
10 #ifndef __GNUC_VA_LIST
11 #define __GNUC_VA_LIST
12
13
14 /* In VMS, __gnuc_va_list is simply char *; on OSF, it's a structure. */
15
16 #ifdef __VMS__
17 typedef char *__gnuc_va_list;
18 #else
19
20 typedef struct {
21 char *__base; /* Pointer to first integer register. */
22 int __offset; /* Byte offset of args so far. */
23 } __gnuc_va_list;
24 #endif
25
26 #endif /* not __GNUC_VA_LIST */
27
28 /* If this is for internal libc use, don't define anything but
29 __gnuc_va_list. */
30 #if defined (_STDARG_H) || defined (_VARARGS_H)
31
32 #define va_list __gnuc_va_list
33 #define _VA_LIST
34 #define _VA_LIST_
35
36 #if !defined(_STDARG_H)
37
38 /* varargs support */
39 #define va_alist __builtin_va_alist
40 #define va_dcl int __builtin_va_alist;...
41 #ifdef __VMS__
42 #define va_start(pvar) ((pvar) = __builtin_saveregs ())
43 #else
44 #define va_start(pvar) ((pvar) = * (__gnuc_va_list *) __builtin_saveregs ())
45 #endif
46
47 #else /* STDARG.H */
48
49 /* ANSI alternative. */
50
51 /* Call __builtin_next_arg even though we aren't using its value, so that
52 we can verify that firstarg is correct. */
53
54 #ifdef __VMS__
55 #define va_start(pvar, firstarg) \
56 (__builtin_next_arg (firstarg), \
57 (pvar) = __builtin_saveregs ())
58 #else
59 #define va_start(pvar, firstarg) \
60 (__builtin_next_arg (firstarg), \
61 (pvar) = *(__gnuc_va_list *) __builtin_saveregs ())
62 #endif
63
64 #endif /* _STDARG_H */
65
66 #ifndef va_end
67
68 #define va_end(__va) ((void) 0)
69
70 /* Values returned by __builtin_classify_type. */
71
72 enum {
73 __no_type_class = -1,
74 __void_type_class,
75 __integer_type_class,
76 __char_type_class,
77 __enumeral_type_class,
78 __boolean_type_class,
79 __pointer_type_class,
80 __reference_type_class,
81 __offset_type_class,
82 __real_type_class,
83 __complex_type_class,
84 __function_type_class,
85 __method_type_class,
86 __record_type_class,
87 __union_type_class,
88 __array_type_class,
89 __string_type_class,
90 __set_type_class,
91 __file_type_class,
92 __lang_type_class
93 };
94
95 #endif
96
97 /* Note that parameters are always aligned at least to a word boundary
98 (when passed) regardless of what GCC's __alignof__ operator says. */
99
100 /* Avoid errors if compiling GCC v2 with GCC v1. */
101 #if __GNUC__ == 1
102 #define __extension__
103 #endif
104
105 /* Get the size of a type in bytes, rounded up to an integral number
106 of words. */
107
108 #define __va_tsize(__type) \
109 (((sizeof (__type) + __extension__ sizeof (long long) - 1) \
110 / __extension__ sizeof (long long)) * __extension__ sizeof (long long))
111
112 #ifdef __VMS__
113 #define va_arg(__va, __type) \
114 (*(((__va) += __va_tsize (__type)), \
115 (__type *)(void *)((__va) - __va_tsize (__type))))
116
117 #else
118
119 #define va_arg(__va, __type) \
120 (*(((__va).__offset += __va_tsize (__type)), \
121 (__type *)(void *)((__va).__base + (__va).__offset \
122 - (((__builtin_classify_type (* (__type *) 0) \
123 == __real_type_class) && (__va).__offset <= (6 * 8)) \
124 ? (6 * 8) + 8 : __va_tsize (__type)))))
125 #endif
126
127 /* Copy __gnuc_va_list into another variable of this type. */
128 #define __va_copy(dest, src) (dest) = (src)
129
130 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
131