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