]>
Commit | Line | Data |
---|---|---|
f3db20a3 | 1 | /* This is just like the default gvarargs.h |
6dc42e49 | 2 | except for differences described below. */ |
f3db20a3 | 3 | |
59d52763 CH |
4 | /* Define __gnuc_va_list. */ |
5 | ||
6 | #ifndef __GNUC_VA_LIST | |
7 | #define __GNUC_VA_LIST | |
8 | ||
69d6c854 | 9 | #ifndef __svr4__ |
f3db20a3 RS |
10 | /* This has to be a char * to be compatible with Sun. |
11 | i.e., we have to pass a `va_list' to vsprintf. */ | |
59d52763 | 12 | typedef char * __gnuc_va_list; |
69d6c854 RS |
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. */ | |
59d52763 | 16 | typedef void * __gnuc_va_list; |
69d6c854 | 17 | #endif |
59d52763 CH |
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) | |
f3db20a3 | 23 | |
a36dc548 | 24 | #ifdef _STDARG_H |
f3db20a3 | 25 | |
a36dc548 | 26 | #define va_start(AP, LASTARG) (AP = (char *) __builtin_saveregs ()) |
f3db20a3 | 27 | |
5840cf94 | 28 | #else |
a36dc548 | 29 | |
168c4006 | 30 | #define va_alist __builtin_va_alist |
a36dc548 JW |
31 | #define va_dcl |
32 | #define va_start(AP) ((AP) = (char *) __builtin_saveregs ()) | |
168c4006 | 33 | |
5840cf94 JW |
34 | #endif |
35 | ||
6f8d2fbd | 36 | #ifndef va_end |
59d52763 | 37 | void va_end (__gnuc_va_list); /* Defined in libgcc.a */ |
6f8d2fbd | 38 | #endif |
f3db20a3 RS |
39 | #define va_end(pvar) |
40 | ||
41 | #define __va_rounded_size(TYPE) \ | |
42 | (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) | |
43 | ||
cc8995d5 RS |
44 | /* Avoid errors if compiling GCC v2 with GCC v1. */ |
45 | #if __GNUC__ == 1 | |
46 | #define __extension__ | |
47 | #endif | |
48 | ||
f3db20a3 RS |
49 | /* RECORD_TYPE args passed using the C calling convention are |
50 | passed by invisible reference. ??? RECORD_TYPE args passed | |
51 | in the stack are made to be word-aligned; for an aggregate that is | |
52 | not word-aligned, we advance the pointer to the first non-reg slot. */ | |
5c96a037 RS |
53 | /* We don't declare the union member `d' to have type TYPE |
54 | because that would lose in C++ if TYPE has a constructor. */ | |
7436f435 RS |
55 | /* We cast to void * and then to TYPE * because this avoids |
56 | a warning about increasing the alignment requirement. */ | |
f3db20a3 | 57 | #define va_arg(pvar,TYPE) \ |
e13d81d0 | 58 | __extension__ \ |
f3db20a3 RS |
59 | ({ TYPE __va_temp; \ |
60 | ((__builtin_classify_type (__va_temp) >= 12) \ | |
61 | ? ((pvar) += __va_rounded_size (TYPE *), \ | |
8d02144c | 62 | **(TYPE **) (void *) ((pvar) - __va_rounded_size (TYPE *))) \ |
81359be5 | 63 | : __va_rounded_size (TYPE) == 8 \ |
5c96a037 | 64 | ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \ |
8d02144c JW |
65 | __u.__i[0] = ((int *) (void *) (pvar))[0]; \ |
66 | __u.__i[1] = ((int *) (void *) (pvar))[1]; \ | |
81359be5 | 67 | (pvar) += 8; \ |
7436f435 | 68 | *(TYPE *) (void *) __u.__d; }) \ |
5840cf94 | 69 | : ((pvar) += __va_rounded_size (TYPE), \ |
7436f435 | 70 | *((TYPE *) (void *) ((pvar) - __va_rounded_size (TYPE)))));}) |
59d52763 CH |
71 | |
72 | #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */ | |
73 |