stdarg.h revision 80709
1/* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. 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 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * from: @(#)stdarg.h 8.2 (Berkeley) 9/27/93 36 * from: NetBSD: stdarg.h,v 1.11 2000/07/23 21:36:56 mycroft Exp 37 * $FreeBSD: head/sys/sparc64/include/stdarg.h 80709 2001-07-31 06:05:05Z jake $ 38 */ 39 40#ifndef _MACHINE_STDARG_H_ 41#define _MACHINE_STDARG_H_ 42 43#include <machine/ansi.h> 44 45typedef _BSD_VA_LIST_ va_list; 46 47#define va_start(ap, last) \ 48 (__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs()) 49 50#define va_end(ap) 51 52#define __va_arg8(ap, type) \ 53 (*(type *)(void *)((ap) += 8, (ap) - 8)) 54#define __va_arg16(ap, type) \ 55 (*(type *)(void *)((ap) = (va_list)(((unsigned long)(ap) + 31) & -16),\ 56 (ap) - 16)) 57#define __va_int(ap, type) \ 58 (*(type *)(void *)((ap) += 8, (ap) - sizeof(type))) 59 60#define __REAL_TYPE_CLASS 8 61#define __RECORD_TYPE_CLASS 12 62#define va_arg(ap, type) \ 63 (__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS ? \ 64 (__alignof__(type) == 16 ? __va_arg16(ap, type) : \ 65 __va_arg8(ap, type)) : \ 66 (__builtin_classify_type(*(type *)0) < __RECORD_TYPE_CLASS ? \ 67 __va_int(ap, type) : \ 68 (sizeof(type) <= 8 ? __va_arg8(ap, type) : \ 69 (sizeof(type) <= 16 ? __va_arg16(ap, type) : \ 70 *__va_arg8(ap, type *))))) 71 72#endif /* !_MACHINE_STDARG_H_ */ 73