2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
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
10 #ifndef OPENSSL_E_OS2_H
11 # define OPENSSL_E_OS2_H
14 # include <openssl/macros.h>
15 # ifndef OPENSSL_NO_DEPRECATED_3_0
16 # define HEADER_E_OS2_H
19 # include <openssl/opensslconf.h>
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.
31 # define OPENSSL_SYS_UNIX
33 /* --------------------- Microsoft operating systems ---------------------- */
36 * Note that MSDOS actually denotes 32-bit environments running on top of
37 * MS-DOS, such as DJGPP one.
39 # if defined(OPENSSL_SYS_MSDOS)
40 # undef OPENSSL_SYS_UNIX
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...
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.
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
57 # if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)
58 # define OPENSSL_SYS_WIN32_CYGWIN
60 # if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)
61 # undef OPENSSL_SYS_UNIX
62 # if !defined(OPENSSL_SYS_WIN32)
63 # define OPENSSL_SYS_WIN32
66 # if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)
67 # undef OPENSSL_SYS_UNIX
68 # if !defined(OPENSSL_SYS_WIN64)
69 # define OPENSSL_SYS_WIN64
72 # if defined(OPENSSL_SYS_WINNT)
73 # undef OPENSSL_SYS_UNIX
75 # if defined(OPENSSL_SYS_WINCE)
76 # undef OPENSSL_SYS_UNIX
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
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.
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
104 /* ------------------------------- OpenVMS -------------------------------- */
105 # if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS)
106 # if !defined(OPENSSL_SYS_VMS)
107 # undef OPENSSL_SYS_UNIX
109 # define OPENSSL_SYS_VMS
111 # define OPENSSL_SYS_VMS_DECC
112 # elif defined(__DECCXX)
113 # define OPENSSL_SYS_VMS_DECC
114 # define OPENSSL_SYS_VMS_DECCXX
116 # define OPENSSL_SYS_VMS_NODECC
120 /* -------------------------------- Unix ---------------------------------- */
121 # ifdef OPENSSL_SYS_UNIX
122 # if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)
123 # define OPENSSL_SYS_LINUX
125 # if defined(_AIX) && !defined(OPENSSL_SYS_AIX)
126 # define OPENSSL_SYS_AIX
130 /* -------------------------------- VOS ----------------------------------- */
131 # if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)
132 # define OPENSSL_SYS_VOS
134 # define OPENSSL_SYS_VOS_HPPA
137 # define OPENSSL_SYS_VOS_IA32
142 * That's it for OS-specific stuff
143 *****************************************************************************/
146 * OPENSSL_EXTERN is normally used to declare a symbol with possible extra
147 * attributes to handle its presence in a shared library.
148 * OPENSSL_EXPORT is used to define a symbol with extra possible attributes
149 * to make it visible in a shared library.
150 * Care needs to be taken when a header file is used both to declare and
151 * define symbols. Basically, for any library that exports some global
152 * variables, the following code must be present in the header file that
153 * declares them, before OPENSSL_EXTERN is used:
155 * #ifdef SOME_BUILD_FLAG_MACRO
156 * # undef OPENSSL_EXTERN
157 * # define OPENSSL_EXTERN OPENSSL_EXPORT
160 * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN
161 * have some generally sensible values.
164 # if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
165 # define OPENSSL_EXPORT extern __declspec(dllexport)
166 # define OPENSSL_EXTERN extern __declspec(dllimport)
168 # define OPENSSL_EXPORT extern
169 # define OPENSSL_EXTERN extern
174 # define ossl_ssize_t __int64
175 # define OSSL_SSIZE_MAX _I64_MAX
177 # define ossl_ssize_t int
178 # define OSSL_SSIZE_MAX INT_MAX
182 # if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t)
183 # define ossl_ssize_t INTN
184 # define OSSL_SSIZE_MAX MAX_INTN
187 # ifndef ossl_ssize_t
188 # define ossl_ssize_t ssize_t
189 # if defined(SSIZE_MAX)
190 # define OSSL_SSIZE_MAX SSIZE_MAX
191 # elif defined(_POSIX_SSIZE_MAX)
192 # define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX
194 # define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))
199 # define __owur __attribute__((__warn_unused_result__))
204 /* Standard integer types */
205 # define OPENSSL_NO_INTTYPES_H
206 # define OPENSSL_NO_STDINT_H
207 # if defined(OPENSSL_SYS_UEFI)
209 typedef UINT8 uint8_t;
210 typedef INT16 int16_t;
211 typedef UINT16 uint16_t;
212 typedef INT32 int32_t;
213 typedef UINT32 uint32_t;
214 typedef INT64 int64_t;
215 typedef UINT64 uint64_t;
216 # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
217 defined(__osf__) || defined(__sgi) || defined(__hpux) || \
218 defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__)
219 # include <inttypes.h>
220 # undef OPENSSL_NO_INTTYPES_H
221 /* Because the specs say that inttypes.h includes stdint.h if present */
222 # undef OPENSSL_NO_STDINT_H
223 # elif defined(_MSC_VER) && _MSC_VER<=1500
225 * minimally required typdefs for systems not supporting inttypes.h or
226 * stdint.h: currently just older VC++
228 typedef signed char int8_t;
229 typedef unsigned char uint8_t;
230 typedef short int16_t;
231 typedef unsigned short uint16_t;
233 typedef unsigned int uint32_t;
234 typedef __int64 int64_t;
235 typedef unsigned __int64 uint64_t;
238 # undef OPENSSL_NO_STDINT_H
241 /* ossl_inline: portable inline definition usable in public headers */
242 # if !defined(inline) && !defined(__cplusplus)
243 # if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
244 /* just use inline */
245 # define ossl_inline inline
246 # elif defined(__GNUC__) && __GNUC__>=2
247 # define ossl_inline __inline__
248 # elif defined(_MSC_VER)
250 * Visual Studio: inline is available in C++ only, however
251 * __inline is available for C, see
252 * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
254 # define ossl_inline __inline
259 # define ossl_inline inline
262 # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
263 # define ossl_noreturn _Noreturn
264 # elif defined(__GNUC__) && __GNUC__ >= 2
265 # define ossl_noreturn __attribute__((noreturn))
267 # define ossl_noreturn
270 /* ossl_unused: portable unused attribute for use in public headers */
271 # if defined(__GNUC__)
272 # define ossl_unused __attribute__((unused))