xref: /csrg-svn/include/stdarg.h (revision 43677)
141889Sbostic /*-
241889Sbostic  * Copyright (c) 1990 The Regents of the University of California.
341889Sbostic  * All rights reserved.
441889Sbostic  *
541889Sbostic  * %sccs.include.redist.c%
641889Sbostic  *
7*43677Sbostic  *	@(#)stdarg.h	5.3 (Berkeley) 06/24/90
841889Sbostic  */
941889Sbostic 
1041889Sbostic typedef char *va_list;
1141889Sbostic 
1242236Sbostic /*
1342236Sbostic  * ANSI says: "If there is no actual next argument, or if type is not
1442236Sbostic  * compatible with the type of the actual next argument (as promoted
1542236Sbostic  * according to the default argument promotions), the behavior is
1642236Sbostic  * undefined."  We read this to mean that we're not allowed to do the
1742236Sbostic  * promotion for the user, so shorts and chars drop core.
1842236Sbostic  */
1942236Sbostic #define	va_arg(ap, type) \
2042236Sbostic 	((type *)(ap += sizeof(type) < sizeof(int) ? \
21*43677Sbostic 		(abort(), 0) : sizeof(type)))[-1]
2242236Sbostic 
2342236Sbostic #define	va_end(ap)
2442236Sbostic 
2542236Sbostic #define	__va_promote(type) \
2641889Sbostic 	(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
2741889Sbostic 
2841889Sbostic #define	va_start(ap, last) \
2942236Sbostic 	(ap = ((char *)&(last) + __va_promote(last)))
30