cleanup
[linux-2.4.21-pre4.git] / include / 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 /* In VMS, __gnuc_va_list is simply char *; on OSF, it's a structure.  */
14
15 #ifdef __VMS__
16 typedef char *__gnuc_va_list;
17 #else
18
19 typedef struct {
20   char *__base;                 /* Pointer to first integer register. */
21   int __offset;                 /* Byte offset of args so far. */
22 } __gnuc_va_list;
23 #endif
24
25 #endif /* __GNUC_VA_LIST */
26
27 /* If this is for internal libc use, don't define anything but
28    __gnuc_va_list.  */
29
30 #if !defined(__GNUC_VA_LIST_1) && (defined (_STDARG_H) || defined (_VARARGS_H))
31 #define __GNUC_VA_LIST_1
32
33 #define _VA_LIST
34 #define _VA_LIST_
35
36 typedef __gnuc_va_list va_list;
37
38 #if !defined(_STDARG_H)
39
40 /* varargs support */
41 #define va_alist __builtin_va_alist
42 #define va_dcl   int __builtin_va_alist;...
43 #ifdef __VMS__
44 #define va_start(pvar) ((pvar) = __builtin_saveregs ())
45 #else
46 #define va_start(pvar) ((pvar) = * (__gnuc_va_list *) __builtin_saveregs ())
47 #endif
48
49 #else /* STDARG.H */
50
51 /* ANSI alternative.  */
52
53 /* Call __builtin_next_arg even though we aren't using its value, so that
54    we can verify that firstarg is correct.  */
55
56 #ifdef __VMS__
57 #define va_start(pvar, firstarg)                                \
58   (__builtin_next_arg (firstarg),                               \
59    (pvar) = __builtin_saveregs ())
60 #else
61 #define va_start(pvar, firstarg)                                \
62   (__builtin_next_arg (firstarg),                               \
63    (pvar) = *(__gnuc_va_list *) __builtin_saveregs ())
64 #endif
65
66 #endif /* _STDARG_H */
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 /* Note that parameters are always aligned at least to a word boundary
96    (when passed) regardless of what GCC's __alignof__ operator says.  */
97
98 /* Avoid errors if compiling GCC v2 with GCC v1.  */
99 #if __GNUC__ == 1
100 #define __extension__
101 #endif
102
103 /* Get the size of a type in bytes, rounded up to an integral number
104    of words.  */
105
106 #define __va_tsize(__type)  \
107   (((sizeof (__type) + __extension__ sizeof (long long) - 1)   \
108     / __extension__ sizeof (long long)) * __extension__ sizeof (long long))
109
110 #ifdef __VMS__
111 #define va_arg(__va, __type)                                            \
112 (*(((__va) += __va_tsize (__type)),                                     \
113    (__type *)(void *)((__va) - __va_tsize (__type))))
114
115 #else
116
117 #define va_arg(__va, __type)                                            \
118 (*(((__va).__offset += __va_tsize (__type)),                            \
119    (__type *)(void *)((__va).__base + (__va).__offset                   \
120               - (((__builtin_classify_type (* (__type *) 0)             \
121                    == __real_type_class) && (__va).__offset <= (6 * 8)) \
122                  ? (6 * 8) + 8 : __va_tsize (__type)))))
123 #endif
124
125 /* Copy __gnuc_va_list into another variable of this type.  */
126 #define __va_copy(dest, src) (dest) = (src)
127
128 #endif /* __GNUC_VA_LIST_1 */