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