1139825Simp/*- 296317Sobrien * Copyright (c) 2002 David E. O'Brien. All rights reserved. 380708Sjake * Copyright (c) 1992, 1993 480708Sjake * The Regents of the University of California. All rights reserved. 580708Sjake * 680708Sjake * This software was developed by the Computer Systems Engineering group 780708Sjake * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 880708Sjake * contributed to Berkeley. 980708Sjake * 1080708Sjake * All advertising materials mentioning features or use of this software 1180708Sjake * must display the following acknowledgement: 1280708Sjake * This product includes software developed by the University of 1380708Sjake * California, Lawrence Berkeley Laboratory. 1480708Sjake * 1580708Sjake * Redistribution and use in source and binary forms, with or without 1680708Sjake * modification, are permitted provided that the following conditions 1780708Sjake * are met: 1880708Sjake * 1. Redistributions of source code must retain the above copyright 1980708Sjake * notice, this list of conditions and the following disclaimer. 2080708Sjake * 2. Redistributions in binary form must reproduce the above copyright 2180708Sjake * notice, this list of conditions and the following disclaimer in the 2280708Sjake * documentation and/or other materials provided with the distribution. 2380708Sjake * 2480708Sjake * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2580708Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2680708Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2780708Sjake * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2880708Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2980708Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3080708Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3180708Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3280708Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3380708Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3480708Sjake * SUCH DAMAGE. 3580708Sjake * 3696317Sobrien * @(#)stdarg.h 8.2 (Berkeley) 9/27/93 3796317Sobrien * $NetBSD: stdarg.h,v 1.11 2000/07/23 21:36:56 mycroft Exp $ 3880708Sjake * $FreeBSD: releng/10.3/sys/sparc64/include/stdarg.h 162487 2006-09-21 01:37:02Z kan $ 3980708Sjake */ 4080708Sjake 4180708Sjake#ifndef _MACHINE_STDARG_H_ 4280708Sjake#define _MACHINE_STDARG_H_ 4380708Sjake 44104583Smike#include <sys/cdefs.h> 45102227Smike#include <sys/_types.h> 4680708Sjake 47104583Smike#ifndef _VA_LIST_DECLARED 48104583Smike#define _VA_LIST_DECLARED 49102227Smiketypedef __va_list va_list; 50104583Smike#endif 5180708Sjake 52143063Sjoerg#ifdef __GNUCLIKE_BUILTIN_STDARG 5396317Sobrien 5480708Sjake#define va_start(ap, last) \ 55162487Skan __builtin_va_start((ap), (last)) 5696317Sobrien 5796317Sobrien#define va_arg(ap, type) \ 5896317Sobrien __builtin_va_arg((ap), type) 5996317Sobrien 60104583Smike#if __ISO_C_VISIBLE >= 1999 61103526Smike#define va_copy(dest, src) \ 62103526Smike __builtin_va_copy((dest), (src)) 63104583Smike#endif 64103526Smike 6596317Sobrien#define va_end(ap) \ 6696317Sobrien __builtin_va_end(ap) 6796317Sobrien 68143063Sjoerg#else /* ! __GNUCLIKE_BUILTIN_STDARG */ 6996317Sobrien 70143063Sjoerg#if !defined(__GNUCLIKE_BUILTIN_NEXT_ARG) && !defined(lint) 71143063Sjoerg#error no support for your compiler 72143063Sjoerg#endif 73143063Sjoerg 7496317Sobrien#define va_start(ap, last) \ 7580708Sjake (__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs()) 7680708Sjake 7780708Sjake#define va_end(ap) 7880708Sjake 7980708Sjake#define __va_arg8(ap, type) \ 8080708Sjake (*(type *)(void *)((ap) += 8, (ap) - 8)) 8180708Sjake#define __va_arg16(ap, type) \ 8280708Sjake (*(type *)(void *)((ap) = (va_list)(((unsigned long)(ap) + 31) & -16),\ 8380708Sjake (ap) - 16)) 8480708Sjake#define __va_int(ap, type) \ 8580708Sjake (*(type *)(void *)((ap) += 8, (ap) - sizeof(type))) 8680708Sjake 8780708Sjake#define __REAL_TYPE_CLASS 8 8880708Sjake#define __RECORD_TYPE_CLASS 12 8980708Sjake#define va_arg(ap, type) \ 9080708Sjake (__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS ? \ 9180708Sjake (__alignof__(type) == 16 ? __va_arg16(ap, type) : \ 9280708Sjake __va_arg8(ap, type)) : \ 9380708Sjake (__builtin_classify_type(*(type *)0) < __RECORD_TYPE_CLASS ? \ 9480708Sjake __va_int(ap, type) : \ 9580708Sjake (sizeof(type) <= 8 ? __va_arg8(ap, type) : \ 9680708Sjake (sizeof(type) <= 16 ? __va_arg16(ap, type) : \ 9780708Sjake *__va_arg8(ap, type *))))) 9880708Sjake 99143063Sjoerg#endif /* __GNUCLIKE_BUILTIN_STDARG */ 10096317Sobrien 10180708Sjake#endif /* !_MACHINE_STDARG_H_ */ 102