xref: /haiku/headers/build/gcc-2.95.3/va-clipper.h (revision 404a0fea4653b894fabf4d5fee8e73df7bf84e75)
1*404a0feaSIngo Weinhold /* GNU C varargs and stdargs support for Clipper.  */
2*404a0feaSIngo Weinhold 
3*404a0feaSIngo Weinhold /* Define __gnuc_va_list. */
4*404a0feaSIngo Weinhold 
5*404a0feaSIngo Weinhold #ifndef __GNUC_VA_LIST
6*404a0feaSIngo Weinhold #define __GNUC_VA_LIST
7*404a0feaSIngo Weinhold 
8*404a0feaSIngo Weinhold typedef struct
9*404a0feaSIngo Weinhold {
10*404a0feaSIngo Weinhold   int __va_ap;				/* pointer to stack args */
11*404a0feaSIngo Weinhold   void *__va_reg[4];			/* pointer to r0,f0,r1,f1 */
12*404a0feaSIngo Weinhold   int __va_num;				/* number of args processed */
13*404a0feaSIngo Weinhold } __gnuc_va_list;
14*404a0feaSIngo Weinhold #endif /* not __GNUC_VA_LIST */
15*404a0feaSIngo Weinhold 
16*404a0feaSIngo Weinhold 
17*404a0feaSIngo Weinhold #if defined (_STDARG_H) || defined (_VARARGS_H)
18*404a0feaSIngo Weinhold typedef __gnuc_va_list va_list;
19*404a0feaSIngo Weinhold #define __va_list __gnuc_va_list	/* acc compatibility */
20*404a0feaSIngo Weinhold 
21*404a0feaSIngo Weinhold #define _VA_LIST
22*404a0feaSIngo Weinhold #define _VA_LIST_
23*404a0feaSIngo Weinhold #define _SYS_INT_STDARG_H		/* acc compatibility */
24*404a0feaSIngo Weinhold 
25*404a0feaSIngo Weinhold /* Call __builtin_next_arg even though we aren't using its value, so that
26*404a0feaSIngo Weinhold    we can verify that LASTARG is correct.  */
27*404a0feaSIngo Weinhold #ifdef _STDARG_H
28*404a0feaSIngo Weinhold #define va_start(AP,LASTARG)			\
29*404a0feaSIngo Weinhold   (__builtin_next_arg (LASTARG),		\
30*404a0feaSIngo Weinhold    (AP) = *(va_list *)__builtin_saveregs(),	\
31*404a0feaSIngo Weinhold    (AP).__va_num = __builtin_args_info (0),	\
32*404a0feaSIngo Weinhold    (AP).__va_ap += __builtin_args_info (1))
33*404a0feaSIngo Weinhold #else
34*404a0feaSIngo Weinhold #define va_alist  __builtin_va_alist
35*404a0feaSIngo Weinhold /* The ... causes current_function_varargs to be set in cc1.  */
36*404a0feaSIngo Weinhold #define va_dcl    va_list __builtin_va_alist; ...
37*404a0feaSIngo Weinhold #define va_start(AP)				\
38*404a0feaSIngo Weinhold   ((AP) = *(va_list *)__builtin_saveregs(),	\
39*404a0feaSIngo Weinhold    (AP).__va_num = __builtin_args_info (0))
40*404a0feaSIngo Weinhold #endif /* _STDARG_H */
41*404a0feaSIngo Weinhold 
42*404a0feaSIngo Weinhold /* round to alignment of `type' but keep a least integer alignment */
43*404a0feaSIngo Weinhold #define __va_round(AP,TYPE)					\
44*404a0feaSIngo Weinhold   ((AP).__va_ap = ((AP).__va_ap + __alignof__ (TYPE) - 1 ) &	\
45*404a0feaSIngo Weinhold    ~(__alignof__ (TYPE) - 1),					\
46*404a0feaSIngo Weinhold   ((AP).__va_ap = ((AP).__va_ap + sizeof (int) - 1) & ~(sizeof (int) - 1)))
47*404a0feaSIngo Weinhold 
48*404a0feaSIngo Weinhold #define va_arg(AP, TYPE) \
49*404a0feaSIngo Weinhold   (*((AP).__va_num < 2 && __builtin_classify_type (* (TYPE *)0) < 12	\
50*404a0feaSIngo Weinhold    ? (__builtin_classify_type (* (TYPE *)0) == 8			\
51*404a0feaSIngo Weinhold       ? ((TYPE *)(AP).__va_reg[2 * (AP).__va_num++ + 1])		\
52*404a0feaSIngo Weinhold       : ((TYPE *)(AP).__va_reg[2 * (AP).__va_num++ ]))			\
53*404a0feaSIngo Weinhold    : ((AP).__va_num++, __va_round (AP,TYPE), ((TYPE *)((AP).__va_ap))++)))
54*404a0feaSIngo Weinhold 
55*404a0feaSIngo Weinhold #define va_end(AP)	((void) 0)
56*404a0feaSIngo Weinhold 
57*404a0feaSIngo Weinhold /* Copy __gnuc_va_list into another variable of this type.  */
58*404a0feaSIngo Weinhold #define __va_copy(dest, src) (dest) = (src)
59*404a0feaSIngo Weinhold 
60*404a0feaSIngo Weinhold #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
61