]>
Commit | Line | Data |
---|---|---|
21dcbebc RS |
1 | /* |
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | |
cf1b7d96 | 3 | * |
21dcbebc RS |
4 | * Licensed under the OpenSSL license (the "License"). You may not use |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
cf1b7d96 | 8 | */ |
2a4a0a34 BM |
9 | |
10 | #ifndef HEADER_E_OS2_H | |
0f113f3e | 11 | # define HEADER_E_OS2_H |
2a4a0a34 | 12 | |
dbc8541b VD |
13 | # include <openssl/opensslconf.h> |
14 | ||
2a4a0a34 BM |
15 | #ifdef __cplusplus |
16 | extern "C" { | |
17 | #endif | |
18 | ||
cf1b7d96 RL |
19 | /****************************************************************************** |
20 | * Detect operating systems. This probably needs completing. | |
21 | * The result is that at least one OPENSSL_SYS_os macro should be defined. | |
22 | * However, if none is defined, Unix is assumed. | |
23 | **/ | |
24 | ||
0f113f3e | 25 | # define OPENSSL_SYS_UNIX |
cf1b7d96 | 26 | |
0f113f3e | 27 | /* --------------------- Microsoft operating systems ---------------------- */ |
cf1b7d96 | 28 | |
0f113f3e MC |
29 | /* |
30 | * Note that MSDOS actually denotes 32-bit environments running on top of | |
31 | * MS-DOS, such as DJGPP one. | |
32 | */ | |
68b00c23 | 33 | # if defined(OPENSSL_SYS_MSDOS) |
0f113f3e | 34 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 35 | # endif |
c510eec0 | 36 | |
0f113f3e MC |
37 | /* |
38 | * For 32 bit environment, there seems to be the CygWin environment and then | |
39 | * all the others that try to do the same thing Microsoft does... | |
40 | */ | |
4d60c7e1 DW |
41 | /* |
42 | * UEFI lives here because it might be built with a Microsoft toolchain and | |
43 | * we need to avoid the false positive match on Windows. | |
44 | */ | |
45 | # if defined(OPENSSL_SYS_UEFI) | |
46 | # undef OPENSSL_SYS_UNIX | |
47 | # elif defined(OPENSSL_SYS_UWIN) | |
cf1b7d96 | 48 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 49 | # define OPENSSL_SYS_WIN32_UWIN |
c69d1039 | 50 | # else |
68b00c23 | 51 | # if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) |
c69d1039 | 52 | # undef OPENSSL_SYS_UNIX |
0f113f3e MC |
53 | # define OPENSSL_SYS_WIN32_CYGWIN |
54 | # else | |
68b00c23 | 55 | # if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) |
0f113f3e | 56 | # undef OPENSSL_SYS_UNIX |
68b00c23 RS |
57 | # if !defined(OPENSSL_SYS_WIN32) |
58 | # define OPENSSL_SYS_WIN32 | |
59 | # endif | |
0f113f3e | 60 | # endif |
3f131556 RL |
61 | # if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) |
62 | # undef OPENSSL_SYS_UNIX | |
63 | # if !defined(OPENSSL_SYS_WIN64) | |
64 | # define OPENSSL_SYS_WIN64 | |
65 | # endif | |
66 | # endif | |
68b00c23 | 67 | # if defined(OPENSSL_SYS_WINNT) |
0f113f3e | 68 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 69 | # endif |
68b00c23 | 70 | # if defined(OPENSSL_SYS_WINCE) |
0f113f3e | 71 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 72 | # endif |
0bf23d9b | 73 | # endif |
cf1b7d96 | 74 | # endif |
cf1b7d96 RL |
75 | |
76 | /* Anything that tries to look like Microsoft is "Windows" */ | |
3f131556 | 77 | # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) |
0f113f3e MC |
78 | # undef OPENSSL_SYS_UNIX |
79 | # define OPENSSL_SYS_WINDOWS | |
80 | # ifndef OPENSSL_SYS_MSDOS | |
81 | # define OPENSSL_SYS_MSDOS | |
82 | # endif | |
1961b327 | 83 | # endif |
cf1b7d96 | 84 | |
0f113f3e MC |
85 | /* |
86 | * DLL settings. This part is a bit tough, because it's up to the | |
87 | * application implementor how he or she will link the application, so it | |
88 | * requires some macro to be used. | |
89 | */ | |
90 | # ifdef OPENSSL_SYS_WINDOWS | |
91 | # ifndef OPENSSL_OPT_WINDLL | |
92 | # if defined(_WINDLL) /* This is used when building OpenSSL to | |
93 | * indicate that DLL linkage should be used */ | |
94 | # define OPENSSL_OPT_WINDLL | |
95 | # endif | |
5cac59b6 RL |
96 | # endif |
97 | # endif | |
5cac59b6 | 98 | |
0f113f3e | 99 | /* ------------------------------- OpenVMS -------------------------------- */ |
68b00c23 RS |
100 | # if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS) |
101 | # if !defined(OPENSSL_SYS_VMS) | |
102 | # undef OPENSSL_SYS_UNIX | |
103 | # endif | |
0f113f3e MC |
104 | # define OPENSSL_SYS_VMS |
105 | # if defined(__DECC) | |
106 | # define OPENSSL_SYS_VMS_DECC | |
107 | # elif defined(__DECCXX) | |
108 | # define OPENSSL_SYS_VMS_DECC | |
109 | # define OPENSSL_SYS_VMS_DECCXX | |
110 | # else | |
111 | # define OPENSSL_SYS_VMS_NODECC | |
112 | # endif | |
cf1b7d96 | 113 | # endif |
dc01b6b1 | 114 | |
0f113f3e MC |
115 | /* -------------------------------- Unix ---------------------------------- */ |
116 | # ifdef OPENSSL_SYS_UNIX | |
68b00c23 | 117 | # if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) |
0f113f3e MC |
118 | # define OPENSSL_SYS_LINUX |
119 | # endif | |
68b00c23 | 120 | # if defined(_AIX) && !defined(OPENSSL_SYS_AIX) |
0f113f3e MC |
121 | # define OPENSSL_SYS_AIX |
122 | # endif | |
cf1b7d96 | 123 | # endif |
cf1b7d96 | 124 | |
0f113f3e | 125 | /* -------------------------------- VOS ----------------------------------- */ |
68b00c23 | 126 | # if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) |
0f113f3e MC |
127 | # define OPENSSL_SYS_VOS |
128 | # ifdef __HPPA__ | |
129 | # define OPENSSL_SYS_VOS_HPPA | |
130 | # endif | |
131 | # ifdef __IA32__ | |
132 | # define OPENSSL_SYS_VOS_IA32 | |
133 | # endif | |
134 | # endif | |
28a80034 | 135 | |
cf1b7d96 RL |
136 | /** |
137 | * That's it for OS-specific stuff | |
138 | *****************************************************************************/ | |
139 | ||
cf1b7d96 | 140 | /* Specials for I/O an exit */ |
0f113f3e MC |
141 | # ifdef OPENSSL_SYS_MSDOS |
142 | # define OPENSSL_UNISTD_IO <io.h> | |
143 | # define OPENSSL_DECLARE_EXIT extern void exit(int); | |
144 | # else | |
145 | # define OPENSSL_UNISTD_IO OPENSSL_UNISTD | |
146 | # define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ | |
147 | # endif | |
e766a681 | 148 | |
1d97c843 | 149 | /*- |
6cef8015 RL |
150 | * OPENSSL_EXTERN is normally used to declare a symbol with possible extra |
151 | * attributes to handle its presence in a shared library. | |
152 | * OPENSSL_EXPORT is used to define a symbol with extra possible attributes | |
153 | * to make it visible in a shared library. | |
154 | * Care needs to be taken when a header file is used both to declare and | |
155 | * define symbols. Basically, for any library that exports some global | |
156 | * variables, the following code must be present in the header file that | |
157 | * declares them, before OPENSSL_EXTERN is used: | |
1d97c843 TH |
158 | * |
159 | * #ifdef SOME_BUILD_FLAG_MACRO | |
160 | * # undef OPENSSL_EXTERN | |
161 | * # define OPENSSL_EXTERN OPENSSL_EXPORT | |
162 | * #endif | |
163 | * | |
9c5e87bf | 164 | * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN |
9716b0b9 | 165 | * have some generally sensible values. |
1d97c843 | 166 | */ |
2a4a0a34 | 167 | |
6cef8015 | 168 | # if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) |
0f113f3e | 169 | # define OPENSSL_EXPORT extern __declspec(dllexport) |
9716b0b9 | 170 | # define OPENSSL_EXTERN extern __declspec(dllimport) |
0f113f3e MC |
171 | # else |
172 | # define OPENSSL_EXPORT extern | |
9716b0b9 | 173 | # define OPENSSL_EXTERN extern |
0f113f3e | 174 | # endif |
2a4a0a34 | 175 | |
1d97c843 TH |
176 | /*- |
177 | * Macros to allow global variables to be reached through function calls when | |
178 | * required (if a shared library version requires it, for example. | |
179 | * The way it's done allows definitions like this: | |
180 | * | |
0f113f3e MC |
181 | * // in foobar.c |
182 | * OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) | |
183 | * // in foobar.h | |
184 | * OPENSSL_DECLARE_GLOBAL(int,foobar); | |
185 | * #define foobar OPENSSL_GLOBAL_REF(foobar) | |
1d97c843 | 186 | */ |
0f113f3e MC |
187 | # ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION |
188 | # define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ | |
189 | type *_shadow_##name(void) \ | |
190 | { static type _hide_##name=value; return &_hide_##name; } | |
191 | # define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) | |
192 | # define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) | |
193 | # else | |
9c5e87bf | 194 | # define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) type _shadow_##name=value; |
0f113f3e MC |
195 | # define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name |
196 | # define OPENSSL_GLOBAL_REF(name) _shadow_##name | |
197 | # endif | |
62dc5aad | 198 | |
f4bd5de5 AP |
199 | # ifdef _WIN32 |
200 | # ifdef _WIN64 | |
201 | # define ossl_ssize_t __int64 | |
e634b448 | 202 | # define OSSL_SSIZE_MAX _I64_MAX |
f4bd5de5 AP |
203 | # else |
204 | # define ossl_ssize_t int | |
e634b448 | 205 | # define OSSL_SSIZE_MAX INT_MAX |
f4bd5de5 | 206 | # endif |
0f113f3e | 207 | # endif |
eb1c48be | 208 | |
23d38992 | 209 | # if defined(OPENSSL_SYS_UEFI) && !defined(ssize_t) |
0f113f3e | 210 | # define ossl_ssize_t int |
e634b448 | 211 | # define OSSL_SSIZE_MAX INT_MAX |
0f113f3e | 212 | # endif |
eb1c48be | 213 | |
0f113f3e | 214 | # ifndef ossl_ssize_t |
eb1c48be | 215 | # define ossl_ssize_t ssize_t |
2a7de0fd JW |
216 | # if defined(SSIZE_MAX) |
217 | # define OSSL_SSIZE_MAX SSIZE_MAX | |
218 | # elif defined(_POSIX_SSIZE_MAX) | |
219 | # define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX | |
220 | # endif | |
0f113f3e | 221 | # endif |
eb1c48be | 222 | |
0f113f3e MC |
223 | # ifdef DEBUG_UNUSED |
224 | # define __owur __attribute__((__warn_unused_result__)) | |
225 | # else | |
226 | # define __owur | |
227 | # endif | |
acf20c7d | 228 | |
c1a623c5 | 229 | /* Standard integer types */ |
cbb259ca | 230 | # if defined(OPENSSL_SYS_UEFI) |
4d60c7e1 DW |
231 | typedef INT8 int8_t; |
232 | typedef UINT8 uint8_t; | |
233 | typedef INT16 int16_t; | |
234 | typedef UINT16 uint16_t; | |
235 | typedef INT32 int32_t; | |
236 | typedef UINT32 uint32_t; | |
237 | typedef INT64 int64_t; | |
238 | typedef UINT64 uint64_t; | |
cbb259ca DW |
239 | # define PRIu64 "%Lu" |
240 | # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ | |
241 | defined(__osf__) || defined(__sgi) || defined(__hpux) || \ | |
6b44f259 | 242 | defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__) |
cbb259ca | 243 | # include <inttypes.h> |
c1a623c5 DSH |
244 | # elif defined(_MSC_VER) && _MSC_VER<=1500 |
245 | /* | |
246 | * minimally required typdefs for systems not supporting inttypes.h or | |
247 | * stdint.h: currently just older VC++ | |
248 | */ | |
249 | typedef signed char int8_t; | |
250 | typedef unsigned char uint8_t; | |
251 | typedef short int16_t; | |
252 | typedef unsigned short uint16_t; | |
253 | typedef int int32_t; | |
254 | typedef unsigned int uint32_t; | |
255 | typedef __int64 int64_t; | |
256 | typedef unsigned __int64 uint64_t; | |
c1a623c5 DSH |
257 | # else |
258 | # include <stdint.h> | |
259 | # endif | |
260 | ||
80e0ecbf DSH |
261 | /* ossl_inline: portable inline definition usable in public headers */ |
262 | # if !defined(inline) && !defined(__cplusplus) | |
263 | # if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L | |
264 | /* just use inline */ | |
265 | # define ossl_inline inline | |
266 | # elif defined(__GNUC__) && __GNUC__>=2 | |
267 | # define ossl_inline __inline__ | |
268 | # elif defined(_MSC_VER) | |
269 | /* | |
270 | * Visual Studio: inline is available in C++ only, however | |
271 | * __inline is available for C, see | |
272 | * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx | |
273 | */ | |
274 | # define ossl_inline __inline | |
275 | # else | |
276 | # define ossl_inline | |
277 | # endif | |
f820b792 M |
278 | # else |
279 | # define ossl_inline inline | |
80e0ecbf DSH |
280 | # endif |
281 | ||
90edbfcc | 282 | # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
87275905 | 283 | # define ossl_noreturn _Noreturn |
90edbfcc AP |
284 | # elif defined(__GNUC__) && __GNUC__ >= 2 |
285 | # define ossl_noreturn __attribute__((noreturn)) | |
87275905 | 286 | # else |
287 | # define ossl_noreturn | |
288 | # endif | |
289 | ||
2a4a0a34 BM |
290 | #ifdef __cplusplus |
291 | } | |
292 | #endif | |
293 | #endif |