]>
Commit | Line | Data |
---|---|---|
cf1b7d96 RL |
1 | /* ==================================================================== |
2 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * | |
8 | * 1. Redistributions of source code must retain the above copyright | |
0f113f3e | 9 | * notice, this list of conditions and the following disclaimer. |
cf1b7d96 RL |
10 | * |
11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in | |
13 | * the documentation and/or other materials provided with the | |
14 | * distribution. | |
15 | * | |
16 | * 3. All advertising materials mentioning features or use of this | |
17 | * software must display the following acknowledgment: | |
18 | * "This product includes software developed by the OpenSSL Project | |
19 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | |
20 | * | |
21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | |
22 | * endorse or promote products derived from this software without | |
23 | * prior written permission. For written permission, please contact | |
24 | * openssl-core@openssl.org. | |
25 | * | |
26 | * 5. Products derived from this software may not be called "OpenSSL" | |
27 | * nor may "OpenSSL" appear in their names without prior written | |
28 | * permission of the OpenSSL Project. | |
29 | * | |
30 | * 6. Redistributions of any form whatsoever must retain the following | |
31 | * acknowledgment: | |
32 | * "This product includes software developed by the OpenSSL Project | |
33 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | |
34 | * | |
35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | |
36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | |
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
46 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
47 | * ==================================================================== | |
48 | * | |
49 | * This product includes cryptographic software written by Eric Young | |
50 | * (eay@cryptsoft.com). This product includes software written by Tim | |
51 | * Hudson (tjh@cryptsoft.com). | |
52 | * | |
53 | */ | |
2a4a0a34 BM |
54 | |
55 | #ifndef HEADER_E_OS2_H | |
0f113f3e | 56 | # define HEADER_E_OS2_H |
2a4a0a34 | 57 | |
dbc8541b VD |
58 | # include <openssl/opensslconf.h> |
59 | ||
2a4a0a34 BM |
60 | #ifdef __cplusplus |
61 | extern "C" { | |
62 | #endif | |
63 | ||
cf1b7d96 RL |
64 | /****************************************************************************** |
65 | * Detect operating systems. This probably needs completing. | |
66 | * The result is that at least one OPENSSL_SYS_os macro should be defined. | |
67 | * However, if none is defined, Unix is assumed. | |
68 | **/ | |
69 | ||
0f113f3e | 70 | # define OPENSSL_SYS_UNIX |
cf1b7d96 | 71 | |
0f113f3e | 72 | /* ---------------------- NetWare ----------------------------------------- */ |
68b00c23 | 73 | # if defined(NETWARE) && !defined(OPENSSL_SYS_NETWARE) |
0f113f3e MC |
74 | # undef OPENSSL_SYS_UNIX |
75 | # define OPENSSL_SYS_NETWARE | |
76 | # endif | |
4d8743f4 | 77 | |
0f113f3e | 78 | /* --------------------- Microsoft operating systems ---------------------- */ |
cf1b7d96 | 79 | |
0f113f3e MC |
80 | /* |
81 | * Note that MSDOS actually denotes 32-bit environments running on top of | |
82 | * MS-DOS, such as DJGPP one. | |
83 | */ | |
68b00c23 | 84 | # if defined(OPENSSL_SYS_MSDOS) |
0f113f3e | 85 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 86 | # endif |
c510eec0 | 87 | |
0f113f3e MC |
88 | /* |
89 | * For 32 bit environment, there seems to be the CygWin environment and then | |
90 | * all the others that try to do the same thing Microsoft does... | |
91 | */ | |
4d60c7e1 DW |
92 | /* |
93 | * UEFI lives here because it might be built with a Microsoft toolchain and | |
94 | * we need to avoid the false positive match on Windows. | |
95 | */ | |
96 | # if defined(OPENSSL_SYS_UEFI) | |
97 | # undef OPENSSL_SYS_UNIX | |
98 | # elif defined(OPENSSL_SYS_UWIN) | |
cf1b7d96 | 99 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 100 | # define OPENSSL_SYS_WIN32_UWIN |
c69d1039 | 101 | # else |
68b00c23 | 102 | # if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) |
c69d1039 | 103 | # undef OPENSSL_SYS_UNIX |
0f113f3e MC |
104 | # define OPENSSL_SYS_WIN32_CYGWIN |
105 | # else | |
68b00c23 | 106 | # if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) |
0f113f3e | 107 | # undef OPENSSL_SYS_UNIX |
68b00c23 RS |
108 | # if !defined(OPENSSL_SYS_WIN32) |
109 | # define OPENSSL_SYS_WIN32 | |
110 | # endif | |
0f113f3e | 111 | # endif |
3f131556 RL |
112 | # if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) |
113 | # undef OPENSSL_SYS_UNIX | |
114 | # if !defined(OPENSSL_SYS_WIN64) | |
115 | # define OPENSSL_SYS_WIN64 | |
116 | # endif | |
117 | # endif | |
68b00c23 | 118 | # if defined(OPENSSL_SYS_WINNT) |
0f113f3e | 119 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 120 | # endif |
68b00c23 | 121 | # if defined(OPENSSL_SYS_WINCE) |
0f113f3e | 122 | # undef OPENSSL_SYS_UNIX |
0f113f3e | 123 | # endif |
0bf23d9b | 124 | # endif |
cf1b7d96 | 125 | # endif |
cf1b7d96 RL |
126 | |
127 | /* Anything that tries to look like Microsoft is "Windows" */ | |
3f131556 | 128 | # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) |
0f113f3e MC |
129 | # undef OPENSSL_SYS_UNIX |
130 | # define OPENSSL_SYS_WINDOWS | |
131 | # ifndef OPENSSL_SYS_MSDOS | |
132 | # define OPENSSL_SYS_MSDOS | |
133 | # endif | |
1961b327 | 134 | # endif |
cf1b7d96 | 135 | |
0f113f3e MC |
136 | /* |
137 | * DLL settings. This part is a bit tough, because it's up to the | |
138 | * application implementor how he or she will link the application, so it | |
139 | * requires some macro to be used. | |
140 | */ | |
141 | # ifdef OPENSSL_SYS_WINDOWS | |
142 | # ifndef OPENSSL_OPT_WINDLL | |
143 | # if defined(_WINDLL) /* This is used when building OpenSSL to | |
144 | * indicate that DLL linkage should be used */ | |
145 | # define OPENSSL_OPT_WINDLL | |
146 | # endif | |
5cac59b6 RL |
147 | # endif |
148 | # endif | |
5cac59b6 | 149 | |
0f113f3e | 150 | /* ------------------------------- OpenVMS -------------------------------- */ |
68b00c23 RS |
151 | # if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS) |
152 | # if !defined(OPENSSL_SYS_VMS) | |
153 | # undef OPENSSL_SYS_UNIX | |
154 | # endif | |
0f113f3e MC |
155 | # define OPENSSL_SYS_VMS |
156 | # if defined(__DECC) | |
157 | # define OPENSSL_SYS_VMS_DECC | |
158 | # elif defined(__DECCXX) | |
159 | # define OPENSSL_SYS_VMS_DECC | |
160 | # define OPENSSL_SYS_VMS_DECCXX | |
161 | # else | |
162 | # define OPENSSL_SYS_VMS_NODECC | |
163 | # endif | |
cf1b7d96 | 164 | # endif |
dc01b6b1 | 165 | |
0f113f3e MC |
166 | /* -------------------------------- OS/2 ---------------------------------- */ |
167 | # if defined(__EMX__) || defined(__OS2__) | |
168 | # undef OPENSSL_SYS_UNIX | |
169 | # define OPENSSL_SYS_OS2 | |
cf1b7d96 | 170 | # endif |
0f113f3e MC |
171 | |
172 | /* -------------------------------- Unix ---------------------------------- */ | |
173 | # ifdef OPENSSL_SYS_UNIX | |
68b00c23 | 174 | # if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) |
0f113f3e MC |
175 | # define OPENSSL_SYS_LINUX |
176 | # endif | |
68b00c23 | 177 | # if defined(_AIX) && !defined(OPENSSL_SYS_AIX) |
0f113f3e MC |
178 | # define OPENSSL_SYS_AIX |
179 | # endif | |
cf1b7d96 | 180 | # endif |
cf1b7d96 | 181 | |
0f113f3e | 182 | /* -------------------------------- VOS ----------------------------------- */ |
68b00c23 | 183 | # if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) |
0f113f3e MC |
184 | # define OPENSSL_SYS_VOS |
185 | # ifdef __HPPA__ | |
186 | # define OPENSSL_SYS_VOS_HPPA | |
187 | # endif | |
188 | # ifdef __IA32__ | |
189 | # define OPENSSL_SYS_VOS_IA32 | |
190 | # endif | |
191 | # endif | |
28a80034 | 192 | |
cf1b7d96 RL |
193 | /** |
194 | * That's it for OS-specific stuff | |
195 | *****************************************************************************/ | |
196 | ||
cf1b7d96 | 197 | /* Specials for I/O an exit */ |
0f113f3e MC |
198 | # ifdef OPENSSL_SYS_MSDOS |
199 | # define OPENSSL_UNISTD_IO <io.h> | |
200 | # define OPENSSL_DECLARE_EXIT extern void exit(int); | |
201 | # else | |
202 | # define OPENSSL_UNISTD_IO OPENSSL_UNISTD | |
203 | # define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ | |
204 | # endif | |
e766a681 | 205 | |
1d97c843 TH |
206 | /*- |
207 | * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare | |
208 | * certain global symbols that, with some compilers under VMS, have to be | |
0d4fb843 F |
209 | * defined and declared explicitly with globaldef and globalref. |
210 | * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare | |
1d97c843 TH |
211 | * DLL exports and imports for compilers under Win32. These are a little |
212 | * more complicated to use. Basically, for any library that exports some | |
213 | * global variables, the following code must be present in the header file | |
214 | * that declares them, before OPENSSL_EXTERN is used: | |
215 | * | |
216 | * #ifdef SOME_BUILD_FLAG_MACRO | |
217 | * # undef OPENSSL_EXTERN | |
218 | * # define OPENSSL_EXTERN OPENSSL_EXPORT | |
219 | * #endif | |
220 | * | |
9716b0b9 RS |
221 | * The default is to have OPENSSL_EXPORT, OPENSSL_EXTERN and OPENSSL_GLOBAL |
222 | * have some generally sensible values. | |
1d97c843 | 223 | */ |
2a4a0a34 | 224 | |
0f113f3e MC |
225 | # if defined(OPENSSL_SYS_VMS_NODECC) |
226 | # define OPENSSL_EXPORT globalref | |
9716b0b9 | 227 | # define OPENSSL_EXTERN globalref |
0f113f3e MC |
228 | # define OPENSSL_GLOBAL globaldef |
229 | # elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) | |
230 | # define OPENSSL_EXPORT extern __declspec(dllexport) | |
9716b0b9 | 231 | # define OPENSSL_EXTERN extern __declspec(dllimport) |
0f113f3e MC |
232 | # define OPENSSL_GLOBAL |
233 | # else | |
234 | # define OPENSSL_EXPORT extern | |
9716b0b9 | 235 | # define OPENSSL_EXTERN extern |
0f113f3e MC |
236 | # define OPENSSL_GLOBAL |
237 | # endif | |
2a4a0a34 | 238 | |
1d97c843 TH |
239 | /*- |
240 | * Macros to allow global variables to be reached through function calls when | |
241 | * required (if a shared library version requires it, for example. | |
242 | * The way it's done allows definitions like this: | |
243 | * | |
0f113f3e MC |
244 | * // in foobar.c |
245 | * OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) | |
246 | * // in foobar.h | |
247 | * OPENSSL_DECLARE_GLOBAL(int,foobar); | |
248 | * #define foobar OPENSSL_GLOBAL_REF(foobar) | |
1d97c843 | 249 | */ |
0f113f3e MC |
250 | # ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION |
251 | # define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ | |
252 | type *_shadow_##name(void) \ | |
253 | { static type _hide_##name=value; return &_hide_##name; } | |
254 | # define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) | |
255 | # define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) | |
256 | # else | |
257 | # define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value; | |
258 | # define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name | |
259 | # define OPENSSL_GLOBAL_REF(name) _shadow_##name | |
260 | # endif | |
62dc5aad | 261 | |
f4bd5de5 AP |
262 | # ifdef _WIN32 |
263 | # ifdef _WIN64 | |
264 | # define ossl_ssize_t __int64 | |
e634b448 | 265 | # define OSSL_SSIZE_MAX _I64_MAX |
f4bd5de5 AP |
266 | # else |
267 | # define ossl_ssize_t int | |
e634b448 | 268 | # define OSSL_SSIZE_MAX INT_MAX |
f4bd5de5 | 269 | # endif |
0f113f3e | 270 | # endif |
eb1c48be | 271 | |
21b80f9a | 272 | # if (defined(__ultrix) || defined(OPENSSL_SYS_UEFI)) && !defined(ssize_t) |
0f113f3e | 273 | # define ossl_ssize_t int |
e634b448 | 274 | # define OSSL_SSIZE_MAX INT_MAX |
0f113f3e | 275 | # endif |
eb1c48be | 276 | |
0f113f3e | 277 | # ifndef ossl_ssize_t |
eb1c48be | 278 | # define ossl_ssize_t ssize_t |
e634b448 | 279 | # define OSSL_SSIZE_MAX SSIZE_MAX |
0f113f3e | 280 | # endif |
eb1c48be | 281 | |
0f113f3e MC |
282 | # ifdef DEBUG_UNUSED |
283 | # define __owur __attribute__((__warn_unused_result__)) | |
284 | # else | |
285 | # define __owur | |
286 | # endif | |
acf20c7d | 287 | |
c1a623c5 | 288 | /* Standard integer types */ |
cbb259ca | 289 | # if defined(OPENSSL_SYS_UEFI) |
4d60c7e1 DW |
290 | typedef INT8 int8_t; |
291 | typedef UINT8 uint8_t; | |
292 | typedef INT16 int16_t; | |
293 | typedef UINT16 uint16_t; | |
294 | typedef INT32 int32_t; | |
295 | typedef UINT32 uint32_t; | |
296 | typedef INT64 int64_t; | |
297 | typedef UINT64 uint64_t; | |
cbb259ca DW |
298 | # define PRIu64 "%Lu" |
299 | # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ | |
300 | defined(__osf__) || defined(__sgi) || defined(__hpux) || \ | |
301 | defined(OPENSSL_SYS_VMS) | |
302 | # include <inttypes.h> | |
c1a623c5 DSH |
303 | # elif defined(_MSC_VER) && _MSC_VER<=1500 |
304 | /* | |
305 | * minimally required typdefs for systems not supporting inttypes.h or | |
306 | * stdint.h: currently just older VC++ | |
307 | */ | |
308 | typedef signed char int8_t; | |
309 | typedef unsigned char uint8_t; | |
310 | typedef short int16_t; | |
311 | typedef unsigned short uint16_t; | |
312 | typedef int int32_t; | |
313 | typedef unsigned int uint32_t; | |
314 | typedef __int64 int64_t; | |
315 | typedef unsigned __int64 uint64_t; | |
c1a623c5 DSH |
316 | # else |
317 | # include <stdint.h> | |
318 | # endif | |
319 | ||
fb029ceb | 320 | /* |
dbc8541b VD |
321 | * We need a format operator for some client tools for uint64_t. If inttypes.h |
322 | * isn't available or did not define it, just go with hard-coded. | |
fb029ceb AE |
323 | */ |
324 | # ifndef PRIu64 | |
e314c340 DSH |
325 | # ifdef SIXTY_FOUR_BIT_LONG |
326 | # define PRIu64 "lu" | |
327 | # else | |
328 | # define PRIu64 "llu" | |
329 | # endif | |
fb029ceb AE |
330 | # endif |
331 | ||
80e0ecbf DSH |
332 | /* ossl_inline: portable inline definition usable in public headers */ |
333 | # if !defined(inline) && !defined(__cplusplus) | |
334 | # if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L | |
335 | /* just use inline */ | |
336 | # define ossl_inline inline | |
337 | # elif defined(__GNUC__) && __GNUC__>=2 | |
338 | # define ossl_inline __inline__ | |
339 | # elif defined(_MSC_VER) | |
340 | /* | |
341 | * Visual Studio: inline is available in C++ only, however | |
342 | * __inline is available for C, see | |
343 | * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx | |
344 | */ | |
345 | # define ossl_inline __inline | |
346 | # else | |
347 | # define ossl_inline | |
348 | # endif | |
f820b792 M |
349 | # else |
350 | # define ossl_inline inline | |
80e0ecbf DSH |
351 | # endif |
352 | ||
2a4a0a34 BM |
353 | #ifdef __cplusplus |
354 | } | |
355 | #endif | |
356 | #endif |