Remove Netware and OS/2
[openssl.git] / include / openssl / e_os2.h
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
9  *    notice, this list of conditions and the following disclaimer.
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  */
54
55 #ifndef HEADER_E_OS2_H
56 # define HEADER_E_OS2_H
57
58 # include <openssl/opensslconf.h>
59
60 #ifdef  __cplusplus
61 extern "C" {
62 #endif
63
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
70 # define OPENSSL_SYS_UNIX
71
72 /* --------------------- Microsoft operating systems ---------------------- */
73
74 /*
75  * Note that MSDOS actually denotes 32-bit environments running on top of
76  * MS-DOS, such as DJGPP one.
77  */
78 # if defined(OPENSSL_SYS_MSDOS)
79 #  undef OPENSSL_SYS_UNIX
80 # endif
81
82 /*
83  * For 32 bit environment, there seems to be the CygWin environment and then
84  * all the others that try to do the same thing Microsoft does...
85  */
86 /*
87  * UEFI lives here because it might be built with a Microsoft toolchain and
88  * we need to avoid the false positive match on Windows.
89  */
90 # if defined(OPENSSL_SYS_UEFI)
91 #  undef OPENSSL_SYS_UNIX
92 # elif defined(OPENSSL_SYS_UWIN)
93 #  undef OPENSSL_SYS_UNIX
94 #  define OPENSSL_SYS_WIN32_UWIN
95 # else
96 #  if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)
97 #   undef OPENSSL_SYS_UNIX
98 #   define OPENSSL_SYS_WIN32_CYGWIN
99 #  else
100 #   if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)
101 #    undef OPENSSL_SYS_UNIX
102 #    if !defined(OPENSSL_SYS_WIN32)
103 #     define OPENSSL_SYS_WIN32
104 #    endif
105 #   endif
106 #   if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)
107 #    undef OPENSSL_SYS_UNIX
108 #    if !defined(OPENSSL_SYS_WIN64)
109 #     define OPENSSL_SYS_WIN64
110 #    endif
111 #   endif
112 #   if defined(OPENSSL_SYS_WINNT)
113 #    undef OPENSSL_SYS_UNIX
114 #   endif
115 #   if defined(OPENSSL_SYS_WINCE)
116 #    undef OPENSSL_SYS_UNIX
117 #   endif
118 #  endif
119 # endif
120
121 /* Anything that tries to look like Microsoft is "Windows" */
122 # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
123 #  undef OPENSSL_SYS_UNIX
124 #  define OPENSSL_SYS_WINDOWS
125 #  ifndef OPENSSL_SYS_MSDOS
126 #   define OPENSSL_SYS_MSDOS
127 #  endif
128 # endif
129
130 /*
131  * DLL settings.  This part is a bit tough, because it's up to the
132  * application implementor how he or she will link the application, so it
133  * requires some macro to be used.
134  */
135 # ifdef OPENSSL_SYS_WINDOWS
136 #  ifndef OPENSSL_OPT_WINDLL
137 #   if defined(_WINDLL)         /* This is used when building OpenSSL to
138                                  * indicate that DLL linkage should be used */
139 #    define OPENSSL_OPT_WINDLL
140 #   endif
141 #  endif
142 # endif
143
144 /* ------------------------------- OpenVMS -------------------------------- */
145 # if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS)
146 #  if !defined(OPENSSL_SYS_VMS)
147 #   undef OPENSSL_SYS_UNIX
148 #  endif
149 #  define OPENSSL_SYS_VMS
150 #  if defined(__DECC)
151 #   define OPENSSL_SYS_VMS_DECC
152 #  elif defined(__DECCXX)
153 #   define OPENSSL_SYS_VMS_DECC
154 #   define OPENSSL_SYS_VMS_DECCXX
155 #  else
156 #   define OPENSSL_SYS_VMS_NODECC
157 #  endif
158 # endif
159
160 /* -------------------------------- Unix ---------------------------------- */
161 # ifdef OPENSSL_SYS_UNIX
162 #  if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)
163 #   define OPENSSL_SYS_LINUX
164 #  endif
165 #  if defined(_AIX) && !defined(OPENSSL_SYS_AIX)
166 #   define OPENSSL_SYS_AIX
167 #  endif
168 # endif
169
170 /* -------------------------------- VOS ----------------------------------- */
171 # if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)
172 #  define OPENSSL_SYS_VOS
173 #  ifdef __HPPA__
174 #   define OPENSSL_SYS_VOS_HPPA
175 #  endif
176 #  ifdef __IA32__
177 #   define OPENSSL_SYS_VOS_IA32
178 #  endif
179 # endif
180
181 /**
182  * That's it for OS-specific stuff
183  *****************************************************************************/
184
185 /* Specials for I/O an exit */
186 # ifdef OPENSSL_SYS_MSDOS
187 #  define OPENSSL_UNISTD_IO <io.h>
188 #  define OPENSSL_DECLARE_EXIT extern void exit(int);
189 # else
190 #  define OPENSSL_UNISTD_IO OPENSSL_UNISTD
191 #  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */
192 # endif
193
194 /*-
195  * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare
196  * certain global symbols that, with some compilers under VMS, have to be
197  * defined and declared explicitly with globaldef and globalref.
198  * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare
199  * DLL exports and imports for compilers under Win32.  These are a little
200  * more complicated to use.  Basically, for any library that exports some
201  * global variables, the following code must be present in the header file
202  * that declares them, before OPENSSL_EXTERN is used:
203  *
204  * #ifdef SOME_BUILD_FLAG_MACRO
205  * # undef OPENSSL_EXTERN
206  * # define OPENSSL_EXTERN OPENSSL_EXPORT
207  * #endif
208  *
209  * The default is to have OPENSSL_EXPORT, OPENSSL_EXTERN and OPENSSL_GLOBAL
210  * have some generally sensible values.
211  */
212
213 # if defined(OPENSSL_SYS_VMS_NODECC)
214 #  define OPENSSL_EXPORT globalref
215 #  define OPENSSL_EXTERN globalref
216 #  define OPENSSL_GLOBAL globaldef
217 # elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
218 #  define OPENSSL_EXPORT extern __declspec(dllexport)
219 #  define OPENSSL_EXTERN extern __declspec(dllimport)
220 #  define OPENSSL_GLOBAL
221 # else
222 #  define OPENSSL_EXPORT extern
223 #  define OPENSSL_EXTERN extern
224 #  define OPENSSL_GLOBAL
225 # endif
226
227 /*-
228  * Macros to allow global variables to be reached through function calls when
229  * required (if a shared library version requires it, for example.
230  * The way it's done allows definitions like this:
231  *
232  *      // in foobar.c
233  *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)
234  *      // in foobar.h
235  *      OPENSSL_DECLARE_GLOBAL(int,foobar);
236  *      #define foobar OPENSSL_GLOBAL_REF(foobar)
237  */
238 # ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
239 #  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \
240         type *_shadow_##name(void)                                      \
241         { static type _hide_##name=value; return &_hide_##name; }
242 #  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
243 #  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
244 # else
245 #  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;
246 #  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
247 #  define OPENSSL_GLOBAL_REF(name) _shadow_##name
248 # endif
249
250 # ifdef _WIN32
251 #  ifdef _WIN64
252 #   define ossl_ssize_t __int64
253 #   define OSSL_SSIZE_MAX _I64_MAX
254 #  else
255 #   define ossl_ssize_t int
256 #   define OSSL_SSIZE_MAX INT_MAX
257 #  endif
258 # endif
259
260 # if defined(OPENSSL_SYS_UEFI) && !defined(ssize_t)
261 #  define ossl_ssize_t int
262 #  define OSSL_SSIZE_MAX INT_MAX
263 # endif
264
265 # ifndef ossl_ssize_t
266 #  define ossl_ssize_t ssize_t
267 #  define OSSL_SSIZE_MAX SSIZE_MAX
268 # endif
269
270 # ifdef DEBUG_UNUSED
271 #  define __owur __attribute__((__warn_unused_result__))
272 # else
273 #  define __owur
274 # endif
275
276 /* Standard integer types */
277 # if defined(OPENSSL_SYS_UEFI)
278 typedef INT8 int8_t;
279 typedef UINT8 uint8_t;
280 typedef INT16 int16_t;
281 typedef UINT16 uint16_t;
282 typedef INT32 int32_t;
283 typedef UINT32 uint32_t;
284 typedef INT64 int64_t;
285 typedef UINT64 uint64_t;
286 #  define PRIu64 "%Lu"
287 # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
288      defined(__osf__) || defined(__sgi) || defined(__hpux) || \
289      defined(OPENSSL_SYS_VMS)
290 #  include <inttypes.h>
291 # elif defined(_MSC_VER) && _MSC_VER<=1500
292 /*
293  * minimally required typdefs for systems not supporting inttypes.h or
294  * stdint.h: currently just older VC++
295  */
296 typedef signed char int8_t;
297 typedef unsigned char uint8_t;
298 typedef short int16_t;
299 typedef unsigned short uint16_t;
300 typedef int int32_t;
301 typedef unsigned int uint32_t;
302 typedef __int64 int64_t;
303 typedef unsigned __int64 uint64_t;
304 # else
305 #  include <stdint.h>
306 # endif
307
308 /*
309  * We need a format operator for some client tools for uint64_t.  If inttypes.h
310  * isn't available or did not define it, just go with hard-coded.
311  */
312 # ifndef PRIu64
313 #  ifdef SIXTY_FOUR_BIT_LONG
314 #   define PRIu64 "lu"
315 #  else
316 #   define PRIu64 "llu"
317 #  endif
318 # endif
319
320 /* ossl_inline: portable inline definition usable in public headers */
321 # if !defined(inline) && !defined(__cplusplus)
322 #  if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
323    /* just use inline */
324 #   define ossl_inline inline
325 #  elif defined(__GNUC__) && __GNUC__>=2
326 #   define ossl_inline __inline__
327 #  elif defined(_MSC_VER)
328   /*
329    * Visual Studio: inline is available in C++ only, however
330    * __inline is available for C, see
331    * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
332    */
333 #   define ossl_inline __inline
334 #  else
335 #   define ossl_inline
336 #  endif
337 # else
338 #  define ossl_inline inline
339 # endif
340
341 #ifdef  __cplusplus
342 }
343 #endif
344 #endif