1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * 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 7.5 (Berkeley) 05/07/93 17 * 18 * from: $Header: varargs.h,v 1.7 93/05/07 18:10:36 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 wants to see the '...' token */ 31 #define va_dcl int va_alist; ... 32 #endif 33 34 #define va_start(ap) (__builtin_saveregs(), (ap) = (char *)&va_alist) 35 #define va_end(ap) /* empty */ 36 37 /* Note, we can assume C code here; C++ does not use <varargs.h>. */ 38 #define __va_8byte(ap, ty) ({ \ 39 union { ty __d; int __i[2]; } __va_u; \ 40 __va_u.__i[0] = ((int *)(void *)(ap))[0]; \ 41 __va_u.__i[1] = ((int *)(void *)(ap))[1]; \ 42 (ap) += 8; __va_u.__d; }) 43 #define va_arg(ap, ty) __extension__ ({ \ 44 ty __va_temp; \ 45 __builtin_classify_type(__va_temp) >= 12 ? \ 46 ((ty **)(void *)((ap) += sizeof(ty *)))[-1][0] : \ 47 sizeof(ty) == 8 ? __va_8byte(ap, ty) : \ 48 ((ty *)(void *)(ap += sizeof(ty)))[-1]; }) 49 50 #endif /* !_MACHINE_VARARGS_H_ */ 51