1*bed243d3SAndroid Build Coastguard Worker /*===---- stdarg.h - Variable argument handling ----------------------------=== 2*bed243d3SAndroid Build Coastguard Worker * 3*bed243d3SAndroid Build Coastguard Worker * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*bed243d3SAndroid Build Coastguard Worker * See https://llvm.org/LICENSE.txt for license information. 5*bed243d3SAndroid Build Coastguard Worker * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*bed243d3SAndroid Build Coastguard Worker * 7*bed243d3SAndroid Build Coastguard Worker *===-----------------------------------------------------------------------=== 8*bed243d3SAndroid Build Coastguard Worker */ 9*bed243d3SAndroid Build Coastguard Worker 10*bed243d3SAndroid Build Coastguard Worker /* 11*bed243d3SAndroid Build Coastguard Worker * This header is designed to be included multiple times. If any of the __need_ 12*bed243d3SAndroid Build Coastguard Worker * macros are defined, then only that subset of interfaces are provided. This 13*bed243d3SAndroid Build Coastguard Worker * can be useful for POSIX headers that need to not expose all of stdarg.h, but 14*bed243d3SAndroid Build Coastguard Worker * need to use some of its interfaces. Otherwise this header provides all of 15*bed243d3SAndroid Build Coastguard Worker * the expected interfaces. 16*bed243d3SAndroid Build Coastguard Worker * 17*bed243d3SAndroid Build Coastguard Worker * When clang modules are enabled, this header is a textual header. It ignores 18*bed243d3SAndroid Build Coastguard Worker * its header guard so that multiple submodules can export its interfaces. 19*bed243d3SAndroid Build Coastguard Worker * Take module SM with submodules A and B, whose headers both include stdarg.h 20*bed243d3SAndroid Build Coastguard Worker * When SM.A builds, __STDARG_H will be defined. When SM.B builds, the 21*bed243d3SAndroid Build Coastguard Worker * definition from SM.A will leak when building without local submodule 22*bed243d3SAndroid Build Coastguard Worker * visibility. stdarg.h wouldn't include any of its implementation headers, and 23*bed243d3SAndroid Build Coastguard Worker * SM.B wouldn't import any of the stdarg modules, and SM.B's `export *` 24*bed243d3SAndroid Build Coastguard Worker * wouldn't export any stdarg interfaces as expected. However, since stdarg.h 25*bed243d3SAndroid Build Coastguard Worker * ignores its header guard when building with modules, it all works as 26*bed243d3SAndroid Build Coastguard Worker * expected. 27*bed243d3SAndroid Build Coastguard Worker * 28*bed243d3SAndroid Build Coastguard Worker * When clang modules are not enabled, the header guards can function in the 29*bed243d3SAndroid Build Coastguard Worker * normal simple fashion. 30*bed243d3SAndroid Build Coastguard Worker */ 31*bed243d3SAndroid Build Coastguard Worker #if !defined(__STDARG_H) || __has_feature(modules) || \ 32*bed243d3SAndroid Build Coastguard Worker defined(__need___va_list) || defined(__need_va_list) || \ 33*bed243d3SAndroid Build Coastguard Worker defined(__need_va_arg) || defined(__need___va_copy) || \ 34*bed243d3SAndroid Build Coastguard Worker defined(__need_va_copy) 35*bed243d3SAndroid Build Coastguard Worker 36*bed243d3SAndroid Build Coastguard Worker #if !defined(__need___va_list) && !defined(__need_va_list) && \ 37*bed243d3SAndroid Build Coastguard Worker !defined(__need_va_arg) && !defined(__need___va_copy) && \ 38*bed243d3SAndroid Build Coastguard Worker !defined(__need_va_copy) 39*bed243d3SAndroid Build Coastguard Worker #define __STDARG_H 40*bed243d3SAndroid Build Coastguard Worker #define __need___va_list 41*bed243d3SAndroid Build Coastguard Worker #define __need_va_list 42*bed243d3SAndroid Build Coastguard Worker #define __need_va_arg 43*bed243d3SAndroid Build Coastguard Worker #define __need___va_copy 44*bed243d3SAndroid Build Coastguard Worker /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode 45*bed243d3SAndroid Build Coastguard Worker * or -ansi is not specified, since it was not part of C90. 46*bed243d3SAndroid Build Coastguard Worker */ 47*bed243d3SAndroid Build Coastguard Worker #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ 48*bed243d3SAndroid Build Coastguard Worker (defined(__cplusplus) && __cplusplus >= 201103L) || \ 49*bed243d3SAndroid Build Coastguard Worker !defined(__STRICT_ANSI__) 50*bed243d3SAndroid Build Coastguard Worker #define __need_va_copy 51*bed243d3SAndroid Build Coastguard Worker #endif 52*bed243d3SAndroid Build Coastguard Worker #endif 53*bed243d3SAndroid Build Coastguard Worker 54*bed243d3SAndroid Build Coastguard Worker #ifdef __need___va_list 55*bed243d3SAndroid Build Coastguard Worker #include <__stdarg___gnuc_va_list.h> 56*bed243d3SAndroid Build Coastguard Worker #undef __need___va_list 57*bed243d3SAndroid Build Coastguard Worker #endif /* defined(__need___va_list) */ 58*bed243d3SAndroid Build Coastguard Worker 59*bed243d3SAndroid Build Coastguard Worker #ifdef __need_va_list 60*bed243d3SAndroid Build Coastguard Worker #include <__stdarg_va_list.h> 61*bed243d3SAndroid Build Coastguard Worker #undef __need_va_list 62*bed243d3SAndroid Build Coastguard Worker #endif /* defined(__need_va_list) */ 63*bed243d3SAndroid Build Coastguard Worker 64*bed243d3SAndroid Build Coastguard Worker #ifdef __need_va_arg 65*bed243d3SAndroid Build Coastguard Worker #include <__stdarg_va_arg.h> 66*bed243d3SAndroid Build Coastguard Worker #undef __need_va_arg 67*bed243d3SAndroid Build Coastguard Worker #endif /* defined(__need_va_arg) */ 68*bed243d3SAndroid Build Coastguard Worker 69*bed243d3SAndroid Build Coastguard Worker #ifdef __need___va_copy 70*bed243d3SAndroid Build Coastguard Worker #include <__stdarg___va_copy.h> 71*bed243d3SAndroid Build Coastguard Worker #undef __need___va_copy 72*bed243d3SAndroid Build Coastguard Worker #endif /* defined(__need___va_copy) */ 73*bed243d3SAndroid Build Coastguard Worker 74*bed243d3SAndroid Build Coastguard Worker #ifdef __need_va_copy 75*bed243d3SAndroid Build Coastguard Worker #include <__stdarg_va_copy.h> 76*bed243d3SAndroid Build Coastguard Worker #undef __need_va_copy 77*bed243d3SAndroid Build Coastguard Worker #endif /* defined(__need_va_copy) */ 78*bed243d3SAndroid Build Coastguard Worker 79*bed243d3SAndroid Build Coastguard Worker #endif 80