1 | /*
|
---|
2 | * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License 2.0 (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
|
---|
8 | */
|
---|
9 |
|
---|
10 | #ifndef OPENSSL_E_OS2_H
|
---|
11 | # define OPENSSL_E_OS2_H
|
---|
12 | # pragma once
|
---|
13 |
|
---|
14 | # include <openssl/macros.h>
|
---|
15 | # ifndef OPENSSL_NO_DEPRECATED_3_0
|
---|
16 | # define HEADER_E_OS2_H
|
---|
17 | # endif
|
---|
18 |
|
---|
19 | # include <openssl/opensslconf.h>
|
---|
20 |
|
---|
21 | #ifdef __cplusplus
|
---|
22 | extern "C" {
|
---|
23 | #endif
|
---|
24 |
|
---|
25 | /******************************************************************************
|
---|
26 | * Detect operating systems. This probably needs completing.
|
---|
27 | * The result is that at least one OPENSSL_SYS_os macro should be defined.
|
---|
28 | * However, if none is defined, Unix is assumed.
|
---|
29 | **/
|
---|
30 |
|
---|
31 | # define OPENSSL_SYS_UNIX
|
---|
32 |
|
---|
33 | /* --------------------- Microsoft operating systems ---------------------- */
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * Note that MSDOS actually denotes 32-bit environments running on top of
|
---|
37 | * MS-DOS, such as DJGPP one.
|
---|
38 | */
|
---|
39 | # if defined(OPENSSL_SYS_MSDOS)
|
---|
40 | # undef OPENSSL_SYS_UNIX
|
---|
41 | # endif
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * For 32 bit environment, there seems to be the CygWin environment and then
|
---|
45 | * all the others that try to do the same thing Microsoft does...
|
---|
46 | */
|
---|
47 | /*
|
---|
48 | * UEFI lives here because it might be built with a Microsoft toolchain and
|
---|
49 | * we need to avoid the false positive match on Windows.
|
---|
50 | */
|
---|
51 | # if defined(OPENSSL_SYS_UEFI)
|
---|
52 | # undef OPENSSL_SYS_UNIX
|
---|
53 | # elif defined(OPENSSL_SYS_UWIN)
|
---|
54 | # undef OPENSSL_SYS_UNIX
|
---|
55 | # define OPENSSL_SYS_WIN32_UWIN
|
---|
56 | # else
|
---|
57 | # if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)
|
---|
58 | # define OPENSSL_SYS_WIN32_CYGWIN
|
---|
59 | # else
|
---|
60 | # if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)
|
---|
61 | # undef OPENSSL_SYS_UNIX
|
---|
62 | # if !defined(OPENSSL_SYS_WIN32)
|
---|
63 | # define OPENSSL_SYS_WIN32
|
---|
64 | # endif
|
---|
65 | # endif
|
---|
66 | # if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)
|
---|
67 | # undef OPENSSL_SYS_UNIX
|
---|
68 | # if !defined(OPENSSL_SYS_WIN64)
|
---|
69 | # define OPENSSL_SYS_WIN64
|
---|
70 | # endif
|
---|
71 | # endif
|
---|
72 | # if defined(OPENSSL_SYS_WINNT)
|
---|
73 | # undef OPENSSL_SYS_UNIX
|
---|
74 | # endif
|
---|
75 | # if defined(OPENSSL_SYS_WINCE)
|
---|
76 | # undef OPENSSL_SYS_UNIX
|
---|
77 | # endif
|
---|
78 | # endif
|
---|
79 | # endif
|
---|
80 |
|
---|
81 | /* Anything that tries to look like Microsoft is "Windows" */
|
---|
82 | # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
|
---|
83 | # undef OPENSSL_SYS_UNIX
|
---|
84 | # define OPENSSL_SYS_WINDOWS
|
---|
85 | # ifndef OPENSSL_SYS_MSDOS
|
---|
86 | # define OPENSSL_SYS_MSDOS
|
---|
87 | # endif
|
---|
88 | # endif
|
---|
89 |
|
---|
90 | /*
|
---|
91 | * DLL settings. This part is a bit tough, because it's up to the
|
---|
92 | * application implementor how he or she will link the application, so it
|
---|
93 | * requires some macro to be used.
|
---|
94 | */
|
---|
95 | # ifdef OPENSSL_SYS_WINDOWS
|
---|
96 | # ifndef OPENSSL_OPT_WINDLL
|
---|
97 | # if defined(_WINDLL) /* This is used when building OpenSSL to
|
---|
98 | * indicate that DLL linkage should be used */
|
---|
99 | # define OPENSSL_OPT_WINDLL
|
---|
100 | # endif
|
---|
101 | # endif
|
---|
102 | # endif
|
---|
103 |
|
---|
104 | /* ------------------------------- OpenVMS -------------------------------- */
|
---|
105 | # if defined(__VMS) || defined(VMS)
|
---|
106 | # if !defined(OPENSSL_SYS_VMS)
|
---|
107 | # undef OPENSSL_SYS_UNIX
|
---|
108 | # define OPENSSL_SYS_VMS
|
---|
109 | # endif
|
---|
110 | # if defined(__DECC)
|
---|
111 | # define OPENSSL_SYS_VMS_DECC
|
---|
112 | # elif defined(__DECCXX)
|
---|
113 | # define OPENSSL_SYS_VMS_DECC
|
---|
114 | # define OPENSSL_SYS_VMS_DECCXX
|
---|
115 | # else
|
---|
116 | # define OPENSSL_SYS_VMS_NODECC
|
---|
117 | # endif
|
---|
118 | # endif
|
---|
119 |
|
---|
120 | /* -------------------------------- Unix ---------------------------------- */
|
---|
121 | # ifdef OPENSSL_SYS_UNIX
|
---|
122 | # if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)
|
---|
123 | # define OPENSSL_SYS_LINUX
|
---|
124 | # endif
|
---|
125 | # if defined(_AIX) && !defined(OPENSSL_SYS_AIX)
|
---|
126 | # define OPENSSL_SYS_AIX
|
---|
127 | # endif
|
---|
128 | # endif
|
---|
129 |
|
---|
130 | /* -------------------------------- VOS ----------------------------------- */
|
---|
131 | # if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)
|
---|
132 | # define OPENSSL_SYS_VOS
|
---|
133 | # ifdef __HPPA__
|
---|
134 | # define OPENSSL_SYS_VOS_HPPA
|
---|
135 | # endif
|
---|
136 | # ifdef __IA32__
|
---|
137 | # define OPENSSL_SYS_VOS_IA32
|
---|
138 | # endif
|
---|
139 | # endif
|
---|
140 |
|
---|
141 | /* ---------------------------- HP NonStop -------------------------------- */
|
---|
142 | # ifdef __TANDEM
|
---|
143 | # ifdef _STRING
|
---|
144 | # include <strings.h>
|
---|
145 | # endif
|
---|
146 | # define OPENSSL_USE_BUILD_DATE
|
---|
147 | # if defined(OPENSSL_THREADS) && defined(_SPT_MODEL_)
|
---|
148 | # define SPT_THREAD_SIGNAL 1
|
---|
149 | # define SPT_THREAD_AWARE 1
|
---|
150 | # include <spthread.h>
|
---|
151 | # elif defined(OPENSSL_THREADS) && defined(_PUT_MODEL_)
|
---|
152 | # include <pthread.h>
|
---|
153 | # endif
|
---|
154 | # endif
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * That's it for OS-specific stuff
|
---|
158 | *****************************************************************************/
|
---|
159 |
|
---|
160 | /*-
|
---|
161 | * OPENSSL_EXTERN is normally used to declare a symbol with possible extra
|
---|
162 | * attributes to handle its presence in a shared library.
|
---|
163 | * OPENSSL_EXPORT is used to define a symbol with extra possible attributes
|
---|
164 | * to make it visible in a shared library.
|
---|
165 | * Care needs to be taken when a header file is used both to declare and
|
---|
166 | * define symbols. Basically, for any library that exports some global
|
---|
167 | * variables, the following code must be present in the header file that
|
---|
168 | * declares them, before OPENSSL_EXTERN is used:
|
---|
169 | *
|
---|
170 | * #ifdef SOME_BUILD_FLAG_MACRO
|
---|
171 | * # undef OPENSSL_EXTERN
|
---|
172 | * # define OPENSSL_EXTERN OPENSSL_EXPORT
|
---|
173 | * #endif
|
---|
174 | *
|
---|
175 | * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN
|
---|
176 | * have some generally sensible values.
|
---|
177 | */
|
---|
178 |
|
---|
179 | # if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
|
---|
180 | # define OPENSSL_EXPORT extern __declspec(dllexport)
|
---|
181 | # define OPENSSL_EXTERN extern __declspec(dllimport)
|
---|
182 | # else
|
---|
183 | # define OPENSSL_EXPORT extern
|
---|
184 | # define OPENSSL_EXTERN extern
|
---|
185 | # endif
|
---|
186 |
|
---|
187 | # ifdef _WIN32
|
---|
188 | # ifdef _WIN64
|
---|
189 | # define ossl_ssize_t __int64
|
---|
190 | # define OSSL_SSIZE_MAX _I64_MAX
|
---|
191 | # else
|
---|
192 | # define ossl_ssize_t int
|
---|
193 | # define OSSL_SSIZE_MAX INT_MAX
|
---|
194 | # endif
|
---|
195 | # endif
|
---|
196 |
|
---|
197 | # if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t)
|
---|
198 | # define ossl_ssize_t INTN
|
---|
199 | # define OSSL_SSIZE_MAX MAX_INTN
|
---|
200 | # endif
|
---|
201 |
|
---|
202 | # ifndef ossl_ssize_t
|
---|
203 | # define ossl_ssize_t ssize_t
|
---|
204 | # if defined(SSIZE_MAX)
|
---|
205 | # define OSSL_SSIZE_MAX SSIZE_MAX
|
---|
206 | # elif defined(_POSIX_SSIZE_MAX)
|
---|
207 | # define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX
|
---|
208 | # else
|
---|
209 | # define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))
|
---|
210 | # endif
|
---|
211 | # endif
|
---|
212 |
|
---|
213 | # if defined(UNUSEDRESULT_DEBUG)
|
---|
214 | # define __owur __attribute__((__warn_unused_result__))
|
---|
215 | # else
|
---|
216 | # define __owur
|
---|
217 | # endif
|
---|
218 |
|
---|
219 | /* Standard integer types */
|
---|
220 | # define OPENSSL_NO_INTTYPES_H
|
---|
221 | # define OPENSSL_NO_STDINT_H
|
---|
222 | # if defined(OPENSSL_SYS_UEFI)
|
---|
223 | typedef INT8 int8_t;
|
---|
224 | typedef UINT8 uint8_t;
|
---|
225 | typedef INT16 int16_t;
|
---|
226 | typedef UINT16 uint16_t;
|
---|
227 | typedef INT32 int32_t;
|
---|
228 | typedef UINT32 uint32_t;
|
---|
229 | typedef INT64 int64_t;
|
---|
230 | typedef UINT64 uint64_t;
|
---|
231 | # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
---|
232 | defined(__osf__) || defined(__sgi) || defined(__hpux) || \
|
---|
233 | defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__)
|
---|
234 | # include <inttypes.h>
|
---|
235 | # undef OPENSSL_NO_INTTYPES_H
|
---|
236 | /* Because the specs say that inttypes.h includes stdint.h if present */
|
---|
237 | # undef OPENSSL_NO_STDINT_H
|
---|
238 | # elif defined(_MSC_VER) && _MSC_VER<1600
|
---|
239 | /*
|
---|
240 | * minimally required typdefs for systems not supporting inttypes.h or
|
---|
241 | * stdint.h: currently just older VC++
|
---|
242 | */
|
---|
243 | typedef signed char int8_t;
|
---|
244 | typedef unsigned char uint8_t;
|
---|
245 | typedef short int16_t;
|
---|
246 | typedef unsigned short uint16_t;
|
---|
247 | typedef int int32_t;
|
---|
248 | typedef unsigned int uint32_t;
|
---|
249 | typedef __int64 int64_t;
|
---|
250 | typedef unsigned __int64 uint64_t;
|
---|
251 | # else
|
---|
252 | # ifdef VBOX
|
---|
253 | # include <iprt/stdint.h> /* stdint.h isn't -Wall clean */
|
---|
254 | # else
|
---|
255 | # include <stdint.h>
|
---|
256 | # endif
|
---|
257 | # undef OPENSSL_NO_STDINT_H
|
---|
258 | # endif
|
---|
259 | # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
|
---|
260 | defined(INTMAX_MAX) && defined(UINTMAX_MAX)
|
---|
261 | typedef intmax_t ossl_intmax_t;
|
---|
262 | typedef uintmax_t ossl_uintmax_t;
|
---|
263 | # else
|
---|
264 | /* Fall back to the largest we know we require and can handle */
|
---|
265 | typedef int64_t ossl_intmax_t;
|
---|
266 | typedef uint64_t ossl_uintmax_t;
|
---|
267 | # endif
|
---|
268 |
|
---|
269 | /* ossl_inline: portable inline definition usable in public headers */
|
---|
270 | # if !defined(inline) && !defined(__cplusplus)
|
---|
271 | # if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
---|
272 | /* just use inline */
|
---|
273 | # define ossl_inline inline
|
---|
274 | # elif defined(__GNUC__) && __GNUC__>=2
|
---|
275 | # define ossl_inline __inline__
|
---|
276 | # elif defined(_MSC_VER)
|
---|
277 | /*
|
---|
278 | * Visual Studio: inline is available in C++ only, however
|
---|
279 | * __inline is available for C, see
|
---|
280 | * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
|
---|
281 | */
|
---|
282 | # define ossl_inline __inline
|
---|
283 | # else
|
---|
284 | # define ossl_inline
|
---|
285 | # endif
|
---|
286 | # else
|
---|
287 | # define ossl_inline inline
|
---|
288 | # endif
|
---|
289 |
|
---|
290 | # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \
|
---|
291 | !defined(__cplusplus)
|
---|
292 | # define ossl_noreturn _Noreturn
|
---|
293 | # elif defined(__GNUC__) && __GNUC__ >= 2
|
---|
294 | # define ossl_noreturn __attribute__((noreturn))
|
---|
295 | # else
|
---|
296 | # define ossl_noreturn
|
---|
297 | # endif
|
---|
298 |
|
---|
299 | /* ossl_unused: portable unused attribute for use in public headers */
|
---|
300 | # if defined(__GNUC__)
|
---|
301 | # define ossl_unused __attribute__((unused))
|
---|
302 | # else
|
---|
303 | # define ossl_unused
|
---|
304 | # endif
|
---|
305 |
|
---|
306 | #ifdef __cplusplus
|
---|
307 | }
|
---|
308 | #endif
|
---|
309 | #endif
|
---|