xref: /freebsd/contrib/llvm-project/clang/lib/Headers/stdarg.h (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1 /*===---- stdarg.h - Variable argument handling ----------------------------===
2  *
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===-----------------------------------------------------------------------===
8  */
9 
10 #ifndef __STDARG_H
11 
12 #ifndef __GNUC_VA_LIST
13 #define __GNUC_VA_LIST
14 typedef __builtin_va_list __gnuc_va_list;
15 #endif
16 
17 #ifdef __need___va_list
18 #undef __need___va_list
19 #else
20 #define __STDARG_H
21 #ifndef _VA_LIST
22 typedef __builtin_va_list va_list;
23 #define _VA_LIST
24 #endif
25 
26 /* FIXME: This is using the placeholder dates Clang produces for these macros
27    in C2x mode; switch to the correct values once they've been published. */
28 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
29 /* C2x does not require the second parameter for va_start. */
30 #define va_start(ap, ...) __builtin_va_start(ap, 0)
31 #else
32 /* Versions before C2x do require the second parameter. */
33 #define va_start(ap, param) __builtin_va_start(ap, param)
34 #endif
35 #define va_end(ap)          __builtin_va_end(ap)
36 #define va_arg(ap, type)    __builtin_va_arg(ap, type)
37 
38 /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
39  * or -ansi is not specified, since it was not part of C90.
40  */
41 #define __va_copy(d,s) __builtin_va_copy(d,s)
42 
43 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||              \
44     (defined(__cplusplus) && __cplusplus >= 201103L) ||                        \
45     !defined(__STRICT_ANSI__)
46 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
47 #endif
48 
49 #endif /* __STDARG_H */
50 
51 #endif /* not __STDARG_H */
52