Import (slightly modified) ru.koi8-r.win.kbd:1.1 from FreeBSD (fjoe):
[dragonfly.git] / contrib / 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 #if ! defined (__svr4__) && ! defined (__linux__) && ! defined (__arch64__)
9 /* This has to be a char * to be compatible with Sun.
10    i.e., we have to pass a `va_list' to vsprintf.  */
11 typedef char * __gnuc_va_list;
12 #else
13 /* This has to be a void * to be compatible with Sun svr4.
14    i.e., we have to pass a `va_list' to vsprintf.  */
15 typedef void * __gnuc_va_list;
16 #endif
17 #endif /* not __GNUC_VA_LIST */
18
19 /* If this is for internal libc use, don't define anything but
20    __gnuc_va_list.  */
21 #if defined (_STDARG_H) || defined (_VARARGS_H)
22
23 #ifdef _STDARG_H
24
25 /* Call __builtin_next_arg even though we aren't using its value, so that
26    we can verify that LASTARG is correct.  */
27 #if defined (__GCC_NEW_VARARGS__) || defined (__arch64__)
28 #define va_start(AP, LASTARG) \
29   (__builtin_next_arg (LASTARG), AP = (char *) __builtin_saveregs ())
30 #else
31 #define va_start(AP, LASTARG)                                   \
32   (__builtin_saveregs (), AP = ((char *) __builtin_next_arg (LASTARG)))
33 #endif
34
35 #else
36
37 #define va_alist  __builtin_va_alist
38 #define va_dcl    int __builtin_va_alist;...
39
40 #if defined (__GCC_NEW_VARARGS__) || defined (__arch64__)
41 #define va_start(AP)    ((AP) = (char *) __builtin_saveregs ())
42 #else
43 #define va_start(AP) \
44   (__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
45 #endif
46
47 #endif
48
49 #ifndef va_end
50 void va_end (__gnuc_va_list);           /* Defined in libgcc.a */
51
52 /* Values returned by __builtin_classify_type.  */
53
54 enum __va_type_classes {
55   __no_type_class = -1,
56   __void_type_class,
57   __integer_type_class,
58   __char_type_class,
59   __enumeral_type_class,
60   __boolean_type_class,
61   __pointer_type_class,
62   __reference_type_class,
63   __offset_type_class,
64   __real_type_class,
65   __complex_type_class,
66   __function_type_class,
67   __method_type_class,
68   __record_type_class,
69   __union_type_class,
70   __array_type_class,
71   __string_type_class,
72   __set_type_class,
73   __file_type_class,
74   __lang_type_class
75 };
76
77 #endif
78 #define va_end(pvar)    ((void)0)
79
80 /* Avoid errors if compiling GCC v2 with GCC v1.  */
81 #if __GNUC__ == 1
82 #define __extension__
83 #endif
84
85 /* RECORD_TYPE args passed using the C calling convention are
86    passed by invisible reference.  ??? RECORD_TYPE args passed
87    in the stack are made to be word-aligned; for an aggregate that is
88    not word-aligned, we advance the pointer to the first non-reg slot.  */
89
90 #ifdef __arch64__
91
92 typedef unsigned int __ptrint __attribute__ ((__mode__ (__DI__)));
93
94 /* ??? TODO: little endian support */
95
96 #define va_arg(pvar, TYPE) \
97 __extension__                                                   \
98 (*({int __type = __builtin_classify_type (* (TYPE *) 0);        \
99   char * __result;                                              \
100   if (__type == __real_type_class)              /* float? */    \
101     {                                                           \
102       if (__alignof__ (TYPE) == 16)                             \
103         (pvar) = (void *) (((__ptrint) (pvar) + 15) & -16);     \
104       __result = (pvar);                                        \
105       (pvar) = (char *) (pvar) + sizeof (TYPE);                 \
106     }                                                           \
107   else if (__type < __record_type_class)        /* integer? */  \
108     {                                                           \
109       (pvar) = (char *) (pvar) + 8;                             \
110       __result = (char *) (pvar) - sizeof (TYPE);               \
111     }                                                           \
112   else /* aggregate object */                                   \
113     {                                                           \
114       if (sizeof (TYPE) <= 8)                                   \
115         {                                                       \
116           __result = (pvar);                                    \
117           (pvar) = (char *) (pvar) + 8;                         \
118         }                                                       \
119       else if (sizeof (TYPE) <= 16)                             \
120         {                                                       \
121           if (__alignof__ (TYPE) == 16)                         \
122             (pvar) = (void *) (((__ptrint) (pvar) + 15) & -16); \
123           __result = (pvar);                                    \
124           (pvar) = (char *) (pvar) + 16;                        \
125         }                                                       \
126       else                                                      \
127         {                                                       \
128           __result = * (void **) (pvar);                        \
129           (pvar) = (char *) (pvar) + 8;                         \
130         }                                                       \
131     }                                                           \
132   (TYPE *) __result;}))
133
134 #else /* not __arch64__ */
135
136 #define __va_rounded_size(TYPE)  \
137   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
138
139 /* We don't declare the union member `d' to have type TYPE
140    because that would lose in C++ if TYPE has a constructor.  */
141 /* We cast to void * and then to TYPE * because this avoids
142    a warning about increasing the alignment requirement.
143    The casts to char * avoid warnings about invalid pointer arithmetic.  */
144 #define va_arg(pvar,TYPE)                                       \
145 __extension__                                                   \
146 (*({((__builtin_classify_type (*(TYPE*) 0) >= __record_type_class \
147       || (__builtin_classify_type (*(TYPE*) 0) == __real_type_class \
148           && sizeof (TYPE) == 16))                              \
149     ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *),    \
150        *(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
151     : __va_rounded_size (TYPE) == 8                             \
152     ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u;      \
153          __u.__i[0] = ((int *) (void *) (pvar))[0];             \
154          __u.__i[1] = ((int *) (void *) (pvar))[1];             \
155          (pvar) = (char *)(pvar) + 8;                           \
156          (TYPE *) (void *) __u.__d; })                          \
157     : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE),      \
158        ((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));}))
159
160 #endif /* not __arch64__ */
161
162 /* Copy __gnuc_va_list into another variable of this type.  */
163 #define __va_copy(dest, src) (dest) = (src)
164
165 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */