1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)stdarg.h 5.2 (Berkeley) 05/18/90 8 */ 9 10 typedef char *va_list; 11 12 /* 13 * ANSI says: "If there is no actual next argument, or if type is not 14 * compatible with the type of the actual next argument (as promoted 15 * according to the default argument promotions), the behavior is 16 * undefined." We read this to mean that we're not allowed to do the 17 * promotion for the user, so shorts and chars drop core. 18 */ 19 #define va_arg(ap, type) \ 20 ((type *)(ap += sizeof(type) < sizeof(int) ? \ 21 abort() : sizeof(type)))[-1] 22 23 #define va_end(ap) 24 25 #define __va_promote(type) \ 26 (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) 27 28 #define va_start(ap, last) \ 29 (ap = ((char *)&(last) + __va_promote(last))) 30