xref: /original-bsd/sys/sparc/include/varargs.h (revision 95ecee29)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratory.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)varargs.h	8.2 (Berkeley) 09/27/93
17  *
18  * from: $Header: varargs.h,v 1.8 93/09/27 00:53:20 torek Exp $
19  */
20 
21 #ifndef _MACHINE_VARARGS_H_
22 #define	_MACHINE_VARARGS_H_
23 
24 typedef char *va_list;
25 
26 /* See <machine/stdarg.h> for comments. */
27 #if __GNUC__ == 1
28 #define __extension__
29 #define	va_dcl	int va_alist;
30 #else /* gcc2 */
31 #ifdef __GCC_NEW_VARARGS__	/* gcc 2.4.5 */
32 #define va_alist __builtin_va_alist
33 #define	va_dcl	int __builtin_va_alist;
34 #else				/* gcc 2.3.3 */
35 #define	va_dcl	int va_alist; ...
36 #endif
37 #endif
38 
39 #ifdef __GCC_NEW_VARARGS__
40 #define	va_start(ap)	((ap) = (char *)__builtin_saveregs())
41 #else
42 #define	va_start(ap)	(__builtin_saveregs(), (ap) = (char *)&va_alist)
43 #endif
44 #define va_end(ap)	/* empty */
45 
46 /* Note, we can assume C code here; C++ does not use <varargs.h>. */
47 #define	__va_8byte(ap, ty) ({ \
48 	union { ty __d; int __i[2]; } __va_u; \
49 	__va_u.__i[0] = ((int *)(void *)(ap))[0]; \
50 	__va_u.__i[1] = ((int *)(void *)(ap))[1]; \
51 	(ap) += 8; __va_u.__d; })
52 #define va_arg(ap, ty) __extension__ ({ \
53     ty __va_temp; \
54     __builtin_classify_type(__va_temp) >= 12 ? \
55 	((ty **)(void *)((ap) += sizeof(ty *)))[-1][0] : \
56     sizeof(ty) == 8 ? __va_8byte(ap, ty) : \
57 	((ty *)(void *)(ap += sizeof(ty)))[-1]; })
58 
59 #endif /* !_MACHINE_VARARGS_H_ */
60