15b2a5decSTijl Coosemans /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 45b2a5decSTijl Coosemans * Copyright (c) 2002 David E. O'Brien. All rights reserved. 55b2a5decSTijl Coosemans * 65b2a5decSTijl Coosemans * Redistribution and use in source and binary forms, with or without 75b2a5decSTijl Coosemans * modification, are permitted provided that the following conditions 85b2a5decSTijl Coosemans * are met: 95b2a5decSTijl Coosemans * 1. Redistributions of source code must retain the above copyright 105b2a5decSTijl Coosemans * notice, this list of conditions and the following disclaimer. 115b2a5decSTijl Coosemans * 2. Redistributions in binary form must reproduce the above copyright 125b2a5decSTijl Coosemans * notice, this list of conditions and the following disclaimer in the 135b2a5decSTijl Coosemans * documentation and/or other materials provided with the distribution. 145b2a5decSTijl Coosemans * 3. Neither the name of the University nor the names of its contributors 155b2a5decSTijl Coosemans * may be used to endorse or promote products derived from this software 165b2a5decSTijl Coosemans * without specific prior written permission. 175b2a5decSTijl Coosemans * 185b2a5decSTijl Coosemans * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 195b2a5decSTijl Coosemans * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 205b2a5decSTijl Coosemans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 215b2a5decSTijl Coosemans * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 225b2a5decSTijl Coosemans * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 235b2a5decSTijl Coosemans * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 245b2a5decSTijl Coosemans * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 255b2a5decSTijl Coosemans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 265b2a5decSTijl Coosemans * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 275b2a5decSTijl Coosemans * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 285b2a5decSTijl Coosemans * SUCH DAMAGE. 295b2a5decSTijl Coosemans * 305b2a5decSTijl Coosemans * $FreeBSD$ 315b2a5decSTijl Coosemans */ 325b2a5decSTijl Coosemans 335b2a5decSTijl Coosemans #ifndef _MACHINE_STDARG_H_ 345b2a5decSTijl Coosemans #define _MACHINE_STDARG_H_ 355b2a5decSTijl Coosemans 365b2a5decSTijl Coosemans #include <sys/cdefs.h> 375b2a5decSTijl Coosemans #include <sys/_types.h> 385b2a5decSTijl Coosemans 395b2a5decSTijl Coosemans #ifndef _VA_LIST_DECLARED 405b2a5decSTijl Coosemans #define _VA_LIST_DECLARED 415b2a5decSTijl Coosemans typedef __va_list va_list; 425b2a5decSTijl Coosemans #endif 435b2a5decSTijl Coosemans 445b2a5decSTijl Coosemans #ifdef __GNUCLIKE_BUILTIN_STDARG 455b2a5decSTijl Coosemans 465b2a5decSTijl Coosemans #define va_start(ap, last) \ 475b2a5decSTijl Coosemans __builtin_va_start((ap), (last)) 485b2a5decSTijl Coosemans 495b2a5decSTijl Coosemans #define va_arg(ap, type) \ 505b2a5decSTijl Coosemans __builtin_va_arg((ap), type) 515b2a5decSTijl Coosemans 525b2a5decSTijl Coosemans #define __va_copy(dest, src) \ 535b2a5decSTijl Coosemans __builtin_va_copy((dest), (src)) 545b2a5decSTijl Coosemans 555b2a5decSTijl Coosemans #if __ISO_C_VISIBLE >= 1999 565b2a5decSTijl Coosemans #define va_copy(dest, src) \ 575b2a5decSTijl Coosemans __va_copy(dest, src) 585b2a5decSTijl Coosemans #endif 595b2a5decSTijl Coosemans 605b2a5decSTijl Coosemans #define va_end(ap) \ 615b2a5decSTijl Coosemans __builtin_va_end(ap) 625b2a5decSTijl Coosemans 635b2a5decSTijl Coosemans #elif defined(lint) 645b2a5decSTijl Coosemans /* Provide a fake implementation for lint's benefit */ 655b2a5decSTijl Coosemans #define __va_size(type) \ 665b2a5decSTijl Coosemans (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long)) 675b2a5decSTijl Coosemans #define va_start(ap, last) \ 685b2a5decSTijl Coosemans ((ap) = (va_list)&(last) + __va_size(last)) 69eafc73a8SPoul-Henning Kamp #define va_copy(dst, src) \ 70eafc73a8SPoul-Henning Kamp ((dst) = (src)) 715b2a5decSTijl Coosemans #define va_arg(ap, type) \ 725b2a5decSTijl Coosemans (*(type *)((ap) += __va_size(type), (ap) - __va_size(type))) 735b2a5decSTijl Coosemans #define va_end(ap) 745b2a5decSTijl Coosemans 755b2a5decSTijl Coosemans #else 765b2a5decSTijl Coosemans #error this file needs to be ported to your compiler 775b2a5decSTijl Coosemans #endif 785b2a5decSTijl Coosemans 795b2a5decSTijl Coosemans #endif /* !_MACHINE_STDARG_H_ */ 80