1a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman/*===---- stdarg.h - Variable argument handling ----------------------------===
2a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman *
3a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * Copyright (c) 2008 Eli Friedman
4a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman *
5a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * Permission is hereby granted, free of charge, to any person obtaining a copy
6a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * of this software and associated documentation files (the "Software"), to deal
7a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * in the Software without restriction, including without limitation the rights
8a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * copies of the Software, and to permit persons to whom the Software is
10a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * furnished to do so, subject to the following conditions:
11a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman *
12a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * The above copyright notice and this permission notice shall be included in
13a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * all copies or substantial portions of the Software.
14a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman *
15a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman * THE SOFTWARE.
22a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman *
23a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman *===-----------------------------------------------------------------------===
24a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman */
25a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman
26a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#ifndef __STDARG_H
27a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#define __STDARG_H
28a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman
2982bab0dda6d8acec8463783bf885a0724ef1e2c3Ted Kremenek#ifndef _VA_LIST
30a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedmantypedef __builtin_va_list va_list;
3182bab0dda6d8acec8463783bf885a0724ef1e2c3Ted Kremenek#define _VA_LIST
3282bab0dda6d8acec8463783bf885a0724ef1e2c3Ted Kremenek#endif
33a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#define va_start(ap, param) __builtin_va_start(ap, param)
34a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#define va_end(ap)          __builtin_va_end(ap)
35a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#define va_arg(ap, type)    __builtin_va_arg(ap, type)
362ec926cce387e2f2fc8b00620af5a70e823d71e8Chris Lattner
372ec926cce387e2f2fc8b00620af5a70e823d71e8Chris Lattner/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
382ec926cce387e2f2fc8b00620af5a70e823d71e8Chris Lattner * or -ansi is not specified, since it was not part of C90.
392ec926cce387e2f2fc8b00620af5a70e823d71e8Chris Lattner */
401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump#define __va_copy(d,s) __builtin_va_copy(d,s)
412ec926cce387e2f2fc8b00620af5a70e823d71e8Chris Lattner
42651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__)
43a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#define va_copy(dest, src)  __builtin_va_copy(dest, src)
442ec926cce387e2f2fc8b00620af5a70e823d71e8Chris Lattner#endif
45a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman
46a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman/* Hack required to make standard headers work, at least on Ubuntu */
47ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#ifndef __GNUC_VA_LIST
48a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#define __GNUC_VA_LIST 1
49ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#endif
50a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedmantypedef __builtin_va_list __gnuc_va_list;
51a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman
52a1d91fe84d98e005947125f0ded9f5246803d368Eli Friedman#endif /* __STDARG_H */
53