1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * This software was developed by the Computer Systems Engineering group 11 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 12 * contributed to Berkeley. 13 * 14 * All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by the University of 17 * California, Lawrence Berkeley Laboratory. 18 * 19 * %sccs.include.redist.c% 20 * 21 * @(#)varargs.h 8.3 (Berkeley) 03/22/94 22 * 23 * from: $Header: varargs.h,v 1.8 93/09/27 00:53:20 torek Exp $ 24 */ 25 26 #ifndef _MACHINE_VARARGS_H_ 27 #define _MACHINE_VARARGS_H_ 28 29 typedef char *va_list; 30 31 /* See <machine/stdarg.h> for comments. */ 32 #if __GNUC__ == 1 33 #define __extension__ 34 #define va_dcl int va_alist; 35 #else /* gcc2 */ 36 #ifdef __GCC_NEW_VARARGS__ /* gcc 2.4.5 */ 37 #define va_alist __builtin_va_alist 38 #define va_dcl int __builtin_va_alist; 39 #else /* gcc 2.3.3 */ 40 #define va_dcl int va_alist; ... 41 #endif 42 #endif 43 44 #ifdef __GCC_NEW_VARARGS__ 45 #define va_start(ap) ((ap) = (char *)__builtin_saveregs()) 46 #else 47 #define va_start(ap) (__builtin_saveregs(), (ap) = (char *)&va_alist) 48 #endif 49 #define va_end(ap) /* empty */ 50 51 /* Note, we can assume C code here; C++ does not use <varargs.h>. */ 52 #define __va_8byte(ap, ty) ({ \ 53 union { ty __d; int __i[2]; } __va_u; \ 54 __va_u.__i[0] = ((int *)(void *)(ap))[0]; \ 55 __va_u.__i[1] = ((int *)(void *)(ap))[1]; \ 56 (ap) += 8; __va_u.__d; }) 57 #define va_arg(ap, ty) __extension__ ({ \ 58 ty __va_temp; \ 59 __builtin_classify_type(__va_temp) >= 12 ? \ 60 ((ty **)(void *)((ap) += sizeof(ty *)))[-1][0] : \ 61 sizeof(ty) == 8 ? __va_8byte(ap, ty) : \ 62 ((ty *)(void *)(ap += sizeof(ty)))[-1]; }) 63 64 #endif /* !_MACHINE_VARARGS_H_ */ 65