xref: /reactos/sdk/include/crt/corecrt.h (revision 2d4c0b87)
1 /*
2  * PROJECT:     ReactOS CRT headers
3  * LICENSE:     MIT (https://spdx.org/licenses/MIT)
4  * PURPOSE:     Declarations used throughout the CoreCRT library.
5  * COPYRIGHT:   Copyright (c) Microsoft Corporation. All rights reserved.
6  */
7 
8 #pragma once
9 
10 #include <crtdefs.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #ifndef _CRTRESTRICT
17 #define _CRTRESTRICT
18 #endif
19 
20 #ifndef DEFINED_localeinfo_struct
21 typedef struct localeinfo_struct
22 {
23     pthreadlocinfo locinfo;
24     pthreadmbcinfo mbcinfo;
25 } _locale_tstruct, *_locale_t;
26 #define DEFINED_localeinfo_struct 1
27 #endif
28 
29 #ifndef RC_INVOKED
30     #if defined __cplusplus && _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES
31 
32         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst)     \
33             extern "C++"                                                                          \
34             {                                                                                     \
35                 template <size_t _Size>                                                           \
36                 inline                                                                            \
37                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size]) _CRT_SECURE_CPP_NOTHROW  \
38                 {                                                                                 \
39                     return _FuncName(_Dst, _Size);                                                \
40                 }                                                                                 \
41             }
42 
43         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1)   \
44             extern "C++"                                                                                         \
45             {                                                                                                    \
46                 template <size_t _Size>                                                                          \
47                 inline                                                                                           \
48                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size], _TType1 _TArg1) _CRT_SECURE_CPP_NOTHROW \
49                 {                                                                                                \
50                     return _FuncName(_Dst, _Size, _TArg1);                                                       \
51                 }                                                                                                \
52             }
53 
54         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)  \
55             extern "C++"                                                                                                         \
56             {                                                                                                                    \
57                 template <size_t _Size>                                                                                          \
58                 inline                                                                                                           \
59                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size], _TType1 _TArg1, _TType2 _TArg2) _CRT_SECURE_CPP_NOTHROW \
60                 {                                                                                                                \
61                     return _FuncName(_Dst, _Size, _TArg1, _TArg2);                                                               \
62                 }                                                                                                                \
63             }
64 
65         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
66             extern "C++"                                                                                                                         \
67             {                                                                                                                                    \
68                 template <size_t _Size>                                                                                                          \
69                 inline                                                                                                                           \
70                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) _CRT_SECURE_CPP_NOTHROW \
71                 {                                                                                                                                \
72                     return _FuncName(_Dst, _Size, _TArg1, _TArg2, _TArg3);                                                                       \
73                 }                                                                                                                                \
74             }
75 
76         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
77             extern "C++"                                                                                                                                          \
78             {                                                                                                                                                     \
79                 template <size_t _Size>                                                                                                                           \
80                 inline                                                                                                                                            \
81                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) _CRT_SECURE_CPP_NOTHROW  \
82                 {                                                                                                                                                 \
83                     return _FuncName(_Dst, _Size, _TArg1, _TArg2, _TArg3, _TArg4);                                                                                \
84                 }                                                                                                                                                 \
85             }
86 
87         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1)  \
88             extern "C++"                                                                                                         \
89             {                                                                                                                    \
90                 template <size_t _Size>                                                                                          \
91                 inline                                                                                                           \
92                 _ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Size], _TType1 _TArg1) _CRT_SECURE_CPP_NOTHROW \
93                 {                                                                                                                \
94                     return _FuncName(_HArg1, _Dst, _Size, _TArg1);                                                               \
95                 }                                                                                                                \
96             }
97 
98         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
99             extern "C++"                                                                                                                         \
100             {                                                                                                                                    \
101                 template <size_t _Size>                                                                                                          \
102                 inline                                                                                                                           \
103                 _ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Size], _TType1 _TArg1, _TType2 _TArg2) _CRT_SECURE_CPP_NOTHROW \
104                 {                                                                                                                                \
105                     return _FuncName(_HArg1, _Dst, _Size, _TArg1, _TArg2);                                                                       \
106                 }                                                                                                                                \
107             }
108 
109         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
110             extern "C++"                                                                                                                                          \
111             {                                                                                                                                                     \
112                 template <size_t _Size>                                                                                                                           \
113                 inline                                                                                                                                            \
114                 _ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Size], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) _CRT_SECURE_CPP_NOTHROW  \
115                 {                                                                                                                                                 \
116                     return _FuncName(_HArg1, _Dst, _Size, _TArg1, _TArg2, _TArg3);                                                                                \
117                 }                                                                                                                                                 \
118             }
119 
120         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0(_ReturnType, _FuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst)  \
121             extern "C++"                                                                                                         \
122             {                                                                                                                    \
123                 template <size_t _Size>                                                                                          \
124                 inline                                                                                                           \
125                 _ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType (&_Dst)[_Size]) _CRT_SECURE_CPP_NOTHROW \
126                 {                                                                                                                \
127                     return _FuncName(_HArg1, _HArg2, _Dst, _Size);                                                               \
128                 }                                                                                                                \
129             }
130 
131         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1) \
132             extern "C++"                                                                                                           \
133             {                                                                                                                      \
134                 template <size_t _Size>                                                                                            \
135                 inline                                                                                                             \
136                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size], _TType1 _TArg1, ...) _CRT_SECURE_CPP_NOTHROW              \
137                 {                                                                                                                  \
138                     va_list _ArgList;                                                                                              \
139                     __crt_va_start(_ArgList, _TArg1);                                                                              \
140                     return _VFuncName(_Dst, _Size, _TArg1, _ArgList);                                                              \
141                 }                                                                                                                  \
142             }
143 
144         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
145             extern "C++"                                                                                                                            \
146             {                                                                                                                                       \
147                 template <size_t _Size>                                                                                                             \
148                 inline                                                                                                                              \
149                 _ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Size], _TType1 _TArg1, _TType2 _TArg2, ...) _CRT_SECURE_CPP_NOTHROW               \
150                 {                                                                                                                                   \
151                     va_list _ArgList;                                                                                                               \
152                     __crt_va_start(_ArgList, _TArg2);                                                                                               \
153                     return _VFuncName(_Dst, _Size, _TArg1, _TArg2, _ArgList);                                                                       \
154                 }                                                                                                                                   \
155             }
156 
157         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(_ReturnType, _FuncName, _DstType, _Src)               \
158             extern "C++"                                                                                          \
159             {                                                                                                     \
160                 template <size_t _DriveSize, size_t _DirSize, size_t _NameSize, size_t _ExtSize>                  \
161                 inline                                                                                            \
162                 _ReturnType __CRTDECL _FuncName(                                                                  \
163                     _In_z_ _DstType const* _Src,                                                                  \
164                     _Post_z_ _DstType (&_Drive)[_DriveSize],                                                      \
165                     _Post_z_ _DstType (&_Dir)[_DirSize],                                                          \
166                     _Post_z_ _DstType (&_Name)[_NameSize],                                                        \
167                     _Post_z_ _DstType (&_Ext)[_ExtSize]                                                           \
168                     ) _CRT_SECURE_CPP_NOTHROW                                                                     \
169                 {                                                                                                 \
170                     return _FuncName(_Src, _Drive, _DriveSize, _Dir, _DirSize, _Name, _NameSize, _Ext, _ExtSize); \
171                 }                                                                                                 \
172             }
173 
174     #else  // ^^^ _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES ^^^ // vvv !_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES vvv //
175 
176         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst)
177         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1)
178         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
179         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
180         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4)
181         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1)
182         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
183         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
184         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0(_ReturnType, _FuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst)
185         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1)
186         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
187         #define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(_ReturnType, _FuncName, _DstType, _Src)
188 
189     #endif // !_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES
190 #endif
191 
192 #ifdef __cplusplus
193 } // extern "C"
194 #endif
195