xref: /freebsd/contrib/llvm-project/clang/lib/Headers/stdarg.h (revision 36b606ae6aa4b24061096ba18582e0a08ccd5dba)
10b57cec5SDimitry Andric /*===---- stdarg.h - Variable argument handling ----------------------------===
20b57cec5SDimitry Andric  *
30b57cec5SDimitry Andric  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric  * See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric  *
70b57cec5SDimitry Andric  *===-----------------------------------------------------------------------===
80b57cec5SDimitry Andric  */
90b57cec5SDimitry Andric 
105f757f3fSDimitry Andric /*
115f757f3fSDimitry Andric  * This header is designed to be included multiple times. If any of the __need_
125f757f3fSDimitry Andric  * macros are defined, then only that subset of interfaces are provided. This
135f757f3fSDimitry Andric  * can be useful for POSIX headers that need to not expose all of stdarg.h, but
145f757f3fSDimitry Andric  * need to use some of its interfaces. Otherwise this header provides all of
155f757f3fSDimitry Andric  * the expected interfaces.
165f757f3fSDimitry Andric  *
170fca6ea1SDimitry Andric  * When clang modules are enabled, this header is a textual header to support
180fca6ea1SDimitry Andric  * the multiple include behavior. As such, it doesn't directly declare anything
190fca6ea1SDimitry Andric  * so that it doesn't add duplicate declarations to all of its includers'
200fca6ea1SDimitry Andric  * modules.
215f757f3fSDimitry Andric  */
220fca6ea1SDimitry Andric #if defined(__MVS__) && __has_include_next(<stdarg.h>)
230fca6ea1SDimitry Andric #undef __need___va_list
240fca6ea1SDimitry Andric #undef __need_va_list
250fca6ea1SDimitry Andric #undef __need_va_arg
260fca6ea1SDimitry Andric #undef __need___va_copy
270fca6ea1SDimitry Andric #undef __need_va_copy
28*36b606aeSDimitry Andric #include <__stdarg_header_macro.h>
290fca6ea1SDimitry Andric #include_next <stdarg.h>
300b57cec5SDimitry Andric 
310fca6ea1SDimitry Andric #else
325f757f3fSDimitry Andric #if !defined(__need___va_list) && !defined(__need_va_list) &&                  \
335f757f3fSDimitry Andric     !defined(__need_va_arg) && !defined(__need___va_copy) &&                   \
345f757f3fSDimitry Andric     !defined(__need_va_copy)
355f757f3fSDimitry Andric #define __need___va_list
365f757f3fSDimitry Andric #define __need_va_list
375f757f3fSDimitry Andric #define __need_va_arg
385f757f3fSDimitry Andric #define __need___va_copy
390b57cec5SDimitry Andric /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
400b57cec5SDimitry Andric  * or -ansi is not specified, since it was not part of C90.
410b57cec5SDimitry Andric  */
42bdd1243dSDimitry Andric #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||              \
43bdd1243dSDimitry Andric     (defined(__cplusplus) && __cplusplus >= 201103L) ||                        \
44bdd1243dSDimitry Andric     !defined(__STRICT_ANSI__)
455f757f3fSDimitry Andric #define __need_va_copy
465f757f3fSDimitry Andric #endif
47*36b606aeSDimitry Andric #include <__stdarg_header_macro.h>
480b57cec5SDimitry Andric #endif
490b57cec5SDimitry Andric 
505f757f3fSDimitry Andric #ifdef __need___va_list
515f757f3fSDimitry Andric #include <__stdarg___gnuc_va_list.h>
525f757f3fSDimitry Andric #undef __need___va_list
535f757f3fSDimitry Andric #endif /* defined(__need___va_list) */
54bdd1243dSDimitry Andric 
555f757f3fSDimitry Andric #ifdef __need_va_list
565f757f3fSDimitry Andric #include <__stdarg_va_list.h>
575f757f3fSDimitry Andric #undef __need_va_list
585f757f3fSDimitry Andric #endif /* defined(__need_va_list) */
595f757f3fSDimitry Andric 
605f757f3fSDimitry Andric #ifdef __need_va_arg
615f757f3fSDimitry Andric #include <__stdarg_va_arg.h>
625f757f3fSDimitry Andric #undef __need_va_arg
635f757f3fSDimitry Andric #endif /* defined(__need_va_arg) */
645f757f3fSDimitry Andric 
655f757f3fSDimitry Andric #ifdef __need___va_copy
665f757f3fSDimitry Andric #include <__stdarg___va_copy.h>
675f757f3fSDimitry Andric #undef __need___va_copy
685f757f3fSDimitry Andric #endif /* defined(__need___va_copy) */
695f757f3fSDimitry Andric 
705f757f3fSDimitry Andric #ifdef __need_va_copy
715f757f3fSDimitry Andric #include <__stdarg_va_copy.h>
725f757f3fSDimitry Andric #undef __need_va_copy
735f757f3fSDimitry Andric #endif /* defined(__need_va_copy) */
745f757f3fSDimitry Andric 
750fca6ea1SDimitry Andric #endif /* __MVS__ */
76