xref: /csrg-svn/sys/sparc/include/varargs.h (revision 66437)
155127Storek /*
263320Sbostic  * Copyright (c) 1992, 1993
363320Sbostic  *	The Regents of the University of California.  All rights reserved.
4*66437Sbostic  * (c) UNIX System Laboratories, Inc.
5*66437Sbostic  * All or some portions of this file are derived from material licensed
6*66437Sbostic  * to the University of California by American Telephone and Telegraph
7*66437Sbostic  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8*66437Sbostic  * the permission of UNIX System Laboratories, Inc.
955127Storek  *
1055127Storek  * This software was developed by the Computer Systems Engineering group
1155127Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
1255127Storek  * contributed to Berkeley.
1355127Storek  *
1455501Sbostic  * All advertising materials mentioning features or use of this software
1555501Sbostic  * must display the following acknowledgement:
1655501Sbostic  *	This product includes software developed by the University of
1759211Storek  *	California, Lawrence Berkeley Laboratory.
1855501Sbostic  *
1955127Storek  * %sccs.include.redist.c%
2055127Storek  *
21*66437Sbostic  *	@(#)varargs.h	8.3 (Berkeley) 03/22/94
2255127Storek  *
2364667Storek  * from: $Header: varargs.h,v 1.8 93/09/27 00:53:20 torek Exp $
2455127Storek  */
2555127Storek 
2655127Storek #ifndef _MACHINE_VARARGS_H_
2755127Storek #define	_MACHINE_VARARGS_H_
2855127Storek 
2959792Storek typedef char *va_list;
3059792Storek 
3156566Storek /* See <machine/stdarg.h> for comments. */
3256566Storek #if __GNUC__ == 1
3356566Storek #define __extension__
3459792Storek #define	va_dcl	int va_alist;
3564667Storek #else /* gcc2 */
3664667Storek #ifdef __GCC_NEW_VARARGS__	/* gcc 2.4.5 */
3764667Storek #define va_alist __builtin_va_alist
3864667Storek #define	va_dcl	int __builtin_va_alist;
3964667Storek #else				/* gcc 2.3.3 */
4059792Storek #define	va_dcl	int va_alist; ...
4156566Storek #endif
4264667Storek #endif
4355127Storek 
4464667Storek #ifdef __GCC_NEW_VARARGS__
4564667Storek #define	va_start(ap)	((ap) = (char *)__builtin_saveregs())
4664667Storek #else
4759792Storek #define	va_start(ap)	(__builtin_saveregs(), (ap) = (char *)&va_alist)
4864667Storek #endif
4959792Storek #define va_end(ap)	/* empty */
5059792Storek 
5159792Storek /* Note, we can assume C code here; C++ does not use <varargs.h>. */
5259792Storek #define	__va_8byte(ap, ty) ({ \
5359792Storek 	union { ty __d; int __i[2]; } __va_u; \
5459792Storek 	__va_u.__i[0] = ((int *)(void *)(ap))[0]; \
5559792Storek 	__va_u.__i[1] = ((int *)(void *)(ap))[1]; \
5659792Storek 	(ap) += 8; __va_u.__d; })
5759792Storek #define va_arg(ap, ty) __extension__ ({ \
5859792Storek     ty __va_temp; \
5959792Storek     __builtin_classify_type(__va_temp) >= 12 ? \
6059792Storek 	((ty **)(void *)((ap) += sizeof(ty *)))[-1][0] : \
6159792Storek     sizeof(ty) == 8 ? __va_8byte(ap, ty) : \
6259792Storek 	((ty *)(void *)(ap += sizeof(ty)))[-1]; })
6359792Storek 
6455127Storek #endif /* !_MACHINE_VARARGS_H_ */
65