xref: /xnu-11417.101.15/EXTERNAL_HEADERS/stdarg.h (revision e3723e1f17661b24996789d8afc084c0c3303b26)
1*e3723e1fSApple OSS Distributions /*===---- stdarg.h - Variable argument handling ----------------------------===
2*e3723e1fSApple OSS Distributions  *
3*e3723e1fSApple OSS Distributions  * Copyright (c) 2008 Eli Friedman
4*e3723e1fSApple OSS Distributions  *
5*e3723e1fSApple OSS Distributions  * Permission is hereby granted, free of charge, to any person obtaining a copy
6*e3723e1fSApple OSS Distributions  * of this software and associated documentation files (the "Software"), to deal
7*e3723e1fSApple OSS Distributions  * in the Software without restriction, including without limitation the rights
8*e3723e1fSApple OSS Distributions  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*e3723e1fSApple OSS Distributions  * copies of the Software, and to permit persons to whom the Software is
10*e3723e1fSApple OSS Distributions  * furnished to do so, subject to the following conditions:
11*e3723e1fSApple OSS Distributions  *
12*e3723e1fSApple OSS Distributions  * The above copyright notice and this permission notice shall be included in
13*e3723e1fSApple OSS Distributions  * all copies or substantial portions of the Software.
14*e3723e1fSApple OSS Distributions  *
15*e3723e1fSApple OSS Distributions  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*e3723e1fSApple OSS Distributions  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*e3723e1fSApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18*e3723e1fSApple OSS Distributions  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*e3723e1fSApple OSS Distributions  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20*e3723e1fSApple OSS Distributions  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21*e3723e1fSApple OSS Distributions  * THE SOFTWARE.
22*e3723e1fSApple OSS Distributions  *
23*e3723e1fSApple OSS Distributions  *===-----------------------------------------------------------------------===
24*e3723e1fSApple OSS Distributions  */
25*e3723e1fSApple OSS Distributions 
26*e3723e1fSApple OSS Distributions #if XNU_KERNEL_PRIVATE
27*e3723e1fSApple OSS Distributions 
28*e3723e1fSApple OSS Distributions #include_next <stdarg.h>
29*e3723e1fSApple OSS Distributions /* __STDARG_H guard defined */
30*e3723e1fSApple OSS Distributions 
31*e3723e1fSApple OSS Distributions #elif (defined(__has_include) && __has_include(<__xnu_libcxx_sentinel.h>))
32*e3723e1fSApple OSS Distributions 
33*e3723e1fSApple OSS Distributions #if !__has_include_next(<stdarg.h>)
34*e3723e1fSApple OSS Distributions #error Do not build with -nostdinc (use GCC_USE_STANDARD_INCLUDE_SEARCHING=NO)
35*e3723e1fSApple OSS Distributions #else
36*e3723e1fSApple OSS Distributions #include_next <stdarg.h>
37*e3723e1fSApple OSS Distributions /* __STDARG_H guard defined */
38*e3723e1fSApple OSS Distributions #endif /* __has_include_next */
39*e3723e1fSApple OSS Distributions 
40*e3723e1fSApple OSS Distributions #else /* XNU_KERNEL_PRIVATE */
41*e3723e1fSApple OSS Distributions 
42*e3723e1fSApple OSS Distributions #ifndef __STDARG_H
43*e3723e1fSApple OSS Distributions #define __STDARG_H
44*e3723e1fSApple OSS Distributions 
45*e3723e1fSApple OSS Distributions #ifndef _VA_LIST
46*e3723e1fSApple OSS Distributions typedef __builtin_va_list va_list;
47*e3723e1fSApple OSS Distributions #define _VA_LIST
48*e3723e1fSApple OSS Distributions #endif
49*e3723e1fSApple OSS Distributions #define va_start(ap, param) __builtin_va_start(ap, param)
50*e3723e1fSApple OSS Distributions #define va_end(ap)          __builtin_va_end(ap)
51*e3723e1fSApple OSS Distributions #define va_arg(ap, type)    __builtin_va_arg(ap, type)
52*e3723e1fSApple OSS Distributions 
53*e3723e1fSApple OSS Distributions /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
54*e3723e1fSApple OSS Distributions  * or -ansi is not specified, since it was not part of C90.
55*e3723e1fSApple OSS Distributions  */
56*e3723e1fSApple OSS Distributions #define __va_copy(d, s) __builtin_va_copy(d,s)
57*e3723e1fSApple OSS Distributions 
58*e3723e1fSApple OSS Distributions #if __STDC_VERSION__ >= 199900L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__)
59*e3723e1fSApple OSS Distributions #define va_copy(dest, src)  __builtin_va_copy(dest, src)
60*e3723e1fSApple OSS Distributions #endif
61*e3723e1fSApple OSS Distributions 
62*e3723e1fSApple OSS Distributions /* Hack required to make standard headers work, at least on Ubuntu */
63*e3723e1fSApple OSS Distributions #define __GNUC_VA_LIST 1
64*e3723e1fSApple OSS Distributions typedef __builtin_va_list __gnuc_va_list;
65*e3723e1fSApple OSS Distributions 
66*e3723e1fSApple OSS Distributions #endif /* __STDARG_H */
67*e3723e1fSApple OSS Distributions 
68*e3723e1fSApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
69