d3d10/tests: Avoid implicit cast changing value.
[wine.git] / include / msvcrt / vadefs.h
blobb5205f79c36a84cbd41b5e33615f49ac20e309b1
1 /*
2 * Variable argument definitions
4 * Copyright 2022 Jacek Caban
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef _INC_VADEFS
22 #define _INC_VADEFS
24 #include <corecrt.h>
26 #ifdef __cplusplus
27 #define _ADDRESSOF(v) (&reinterpret_cast<const char &>(v))
28 #else
29 #define _ADDRESSOF(v) (&(v))
30 #endif
32 #if defined (__GNUC__) && (defined(__x86_64__) || (defined(__aarch64__) && __has_attribute(ms_abi)))
34 typedef __builtin_ms_va_list va_list;
35 #define _crt_va_start(v,l) __builtin_ms_va_start(v,l)
36 #define _crt_va_arg(v,l) __builtin_va_arg(v,l)
37 #define _crt_va_end(v) __builtin_ms_va_end(v)
38 #define _crt_va_copy(d,s) __builtin_ms_va_copy(d,s)
40 #elif defined(__GNUC__) || defined(__clang__)
42 typedef __builtin_va_list va_list;
43 #define _crt_va_start(v,l) __builtin_va_start(v,l)
44 #define _crt_va_arg(v,l) __builtin_va_arg(v,l)
45 #define _crt_va_end(v) __builtin_va_end(v)
46 #define _crt_va_copy(d,s) __builtin_va_copy(d,s)
48 #else
50 typedef char *va_list;
52 #if defined(__i386__)
53 #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
54 #define _crt_va_start(v,l) ((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l))
55 #define _crt_va_arg(v,l) (*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l)))
56 #define _crt_va_end(v) ((v) = (va_list)0)
57 #define _crt_va_copy(d,s) ((d) = (s))
58 #endif
60 #endif
62 #endif /* _INC_VADEFS */