|
|
1.1 root 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: #ifdef __sparc_v9__
10: typedef long long __va_greg;
11: typedef double __va_freg;
12: typedef struct {
13: __va_greg * __va_next_o; /* next available %o* register */
14: __va_greg * __va_next_o_limit; /* past last available %o* register */
15: __va_freg * __va_next_fp; /* next available %f* register */
16: __va_freg * __va_next_fp_limit; /* last available %f* register */
17: __va_greg * __va_next_stack; /* next extended word on stack */
18: } __gnuc_va_list;
19: #else
20: #ifndef __svr4__
21: /* This has to be a char * to be compatible with Sun.
22: i.e., we have to pass a `va_list' to vsprintf. */
23: typedef char * __gnuc_va_list;
24: #else
25: /* This has to be a void * to be compatible with Sun svr4.
26: i.e., we have to pass a `va_list' to vsprintf. */
27: typedef void * __gnuc_va_list;
28: #endif
29: #endif /* not __sparc_v9__ */
30: #endif /* not __GNUC_VA_LIST */
31:
32: /* If this is for internal libc use, don't define anything but
33: __gnuc_va_list. */
34: #if defined (_STDARG_H) || defined (_VARARGS_H)
35:
36: #ifdef _STDARG_H
37:
38: #ifdef __sparc_v9__
39: #define va_start(AP, LASTARG) \
40: __extension__ \
41: ({ \
42: AP.__va_next_o = (__va_greg *) __builtin_saveregs (); \
43: AP.__va_next_o_limit = (AP.__va_next_o + \
44: (__builtin_args_info (0) < 6 ? 6 - __builtin_args_info (0) : 0)); \
45: AP.__va_next_fp = (__va_freg *) AP.__va_next_o_limit; \
46: AP.__va_next_fp_limit = (AP.__va_next_fp + \
47: (__builtin_args_info (1) < 16 ? (16 - __builtin_args_info (1) + 1) / 2 : 0)); \
48: AP.__va_next_stack = (__va_greg *) __builtin_next_arg (LASTARG); \
49: })
50: #else
51: /* Call __builtin_next_arg even though we aren't using its value, so that
52: we can verify that LASTARG is correct. */
53: #ifdef __GCC_NEW_VARARGS__
54: #define va_start(AP, LASTARG) \
55: (__builtin_next_arg (LASTARG), AP = (char *) __builtin_saveregs ())
56: #else
57: #define va_start(AP, LASTARG) \
58: (__builtin_saveregs (), AP = ((char *) __builtin_next_arg (LASTARG)))
59: #endif
60: #endif /* not __sparc_v9__ */
61:
62: #else
63:
64: #define va_alist __builtin_va_alist
65: #define va_dcl int __builtin_va_alist;...
66:
67: #ifdef __sparc_v9__
68: #define va_start(AP) \
69: __extension__ \
70: ({ \
71: AP.__va_next_o = (__va_greg *) __builtin_saveregs (); \
72: AP.__va_next_o_limit = (AP.__va_next_o + \
73: (__builtin_args_info (0) < 6 ? 6 - __builtin_args_info (0) : 0)); \
74: AP.__va_next_fp = (__va_freg *) AP.__va_next_o_limit; \
75: AP.__va_next_fp_limit = (AP.__va_next_fp + \
76: (__builtin_args_info (1) < 16 ? (16 - __builtin_args_info (1) + 1) / 2 : 0)); \
77: AP.__va_next_stack = (__va_greg *) __builtin_next_arg (__builtin_va_alist); \
78: })
79: #else
80: #ifdef __GCC_NEW_VARARGS__
81: #define va_start(AP) ((AP) = (char *) __builtin_saveregs ())
82: #else
83: #define va_start(AP) \
84: (__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
85: #endif
86: #endif /* not __sparc_v9__ */
87:
88: #endif
89:
90: #ifndef va_end
91: void va_end (__gnuc_va_list); /* Defined in libgcc.a */
92:
93: /* Values returned by __builtin_classify_type. */
94:
95: enum __va_type_classes {
96: __no_type_class = -1,
97: __void_type_class,
98: __integer_type_class,
99: __char_type_class,
100: __enumeral_type_class,
101: __boolean_type_class,
102: __pointer_type_class,
103: __reference_type_class,
104: __offset_type_class,
105: __real_type_class,
106: __complex_type_class,
107: __function_type_class,
108: __method_type_class,
109: __record_type_class,
110: __union_type_class,
111: __array_type_class,
112: __string_type_class,
113: __set_type_class,
114: __file_type_class,
115: __lang_type_class
116: };
117:
118: #endif
119: #define va_end(pvar)
120:
121: /* Avoid errors if compiling GCC v2 with GCC v1. */
122: #if __GNUC__ == 1
123: #define __extension__
124: #endif
125:
126: /* RECORD_TYPE args passed using the C calling convention are
127: passed by invisible reference. ??? RECORD_TYPE args passed
128: in the stack are made to be word-aligned; for an aggregate that is
129: not word-aligned, we advance the pointer to the first non-reg slot. */
130:
131: #ifdef __sparc_v9__
132:
133: #define va_arg(pvar,TYPE) \
134: __extension__ \
135: ({int __type = __builtin_classify_type (* (TYPE *) 0); \
136: void * __result; \
137: if (__type == __real_type_class) /* float? */ \
138: { \
139: __va_freg *__r; \
140: /* see PASS_IN_REG_P in gcc's sparc.h */ \
141: if (pvar.__va_next_fp < pvar.__va_next_fp_limit \
142: && ((__r = (__va_freg *) (((__va_greg) pvar.__va_next_fp + sizeof (TYPE) - 1) & ~(__va_greg) (sizeof (TYPE) - 1))) \
143: < pvar.__va_next_fp_limit)) \
144: { \
145: pvar.__va_next_fp = __r + (sizeof (TYPE) + 7) / 8; \
146: } \
147: else \
148: { \
149: __r = (__va_freg *) pvar.__va_next_stack; \
150: pvar.__va_next_stack += (sizeof (TYPE) + 7) / 8; \
151: } \
152: __result = __r; \
153: } \
154: else if (__type < __record_type_class) /* integer? */ \
155: { \
156: __va_greg *__r; \
157: if (pvar.__va_next_o < pvar.__va_next_o_limit) \
158: __r = pvar.__va_next_o++; \
159: else \
160: __r = pvar.__va_next_stack++; \
161: /* adjust for 4 byte ints */ \
162: __result = (char *) __r + 8 - sizeof (TYPE); \
163: } \
164: else /* aggregate object */ \
165: { \
166: void **__r; \
167: if (pvar.__va_next_o < pvar.__va_next_o_limit) \
168: __r = (void **) pvar.__va_next_o++; \
169: else \
170: __r = (void **) pvar.__va_next_stack++; \
171: __result = *__r; \
172: } \
173: *(TYPE *) __result;})
174:
175: #else /* not __sparc_v9__ */
176:
177: #define __va_rounded_size(TYPE) \
178: (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
179:
180: /* We don't declare the union member `d' to have type TYPE
181: because that would lose in C++ if TYPE has a constructor. */
182: /* We cast to void * and then to TYPE * because this avoids
183: a warning about increasing the alignment requirement.
184: The casts to char * avoid warnings about invalid pointer arithmetic. */
185: #define va_arg(pvar,TYPE) \
186: __extension__ \
187: ({ TYPE __va_temp; \
188: ((__builtin_classify_type (__va_temp) >= __record_type_class) \
189: ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \
190: **(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
191: : __va_rounded_size (TYPE) == 8 \
192: ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u; \
193: __u.__i[0] = ((int *) (void *) (pvar))[0]; \
194: __u.__i[1] = ((int *) (void *) (pvar))[1]; \
195: (pvar) = (char *)(pvar) + 8; \
196: *(TYPE *) (void *) __u.__d; }) \
197: : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \
198: *((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));})
199: #endif /* not __sparc_v9__ */
200:
201: #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.