]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/e_os2.h
Rework and make DEBUG macros consistent.
[thirdparty/openssl.git] / include / openssl / e_os2.h
CommitLineData
21dcbebc 1/*
aff636a4 2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
cf1b7d96 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
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
cf1b7d96 8 */
2a4a0a34 9
ae4186b0
DMSP
10#ifndef OPENSSL_E_OS2_H
11# define OPENSSL_E_OS2_H
d86167ec
DMSP
12# pragma once
13
14# include <openssl/macros.h>
936c2b9e 15# ifndef OPENSSL_NO_DEPRECATED_3_0
d86167ec
DMSP
16# define HEADER_E_OS2_H
17# endif
2a4a0a34 18
dbc8541b
VD
19# include <openssl/opensslconf.h>
20
2a4a0a34
BM
21#ifdef __cplusplus
22extern "C" {
23#endif
24
cf1b7d96
RL
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
0f113f3e 31# define OPENSSL_SYS_UNIX
cf1b7d96 32
0f113f3e 33/* --------------------- Microsoft operating systems ---------------------- */
cf1b7d96 34
0f113f3e
MC
35/*
36 * Note that MSDOS actually denotes 32-bit environments running on top of
37 * MS-DOS, such as DJGPP one.
38 */
68b00c23 39# if defined(OPENSSL_SYS_MSDOS)
0f113f3e 40# undef OPENSSL_SYS_UNIX
0f113f3e 41# endif
c510eec0 42
0f113f3e
MC
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 */
4d60c7e1
DW
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)
cf1b7d96 54# undef OPENSSL_SYS_UNIX
0f113f3e 55# define OPENSSL_SYS_WIN32_UWIN
c69d1039 56# else
68b00c23 57# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)
0f113f3e
MC
58# define OPENSSL_SYS_WIN32_CYGWIN
59# else
68b00c23 60# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)
0f113f3e 61# undef OPENSSL_SYS_UNIX
68b00c23
RS
62# if !defined(OPENSSL_SYS_WIN32)
63# define OPENSSL_SYS_WIN32
64# endif
0f113f3e 65# endif
3f131556
RL
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
68b00c23 72# if defined(OPENSSL_SYS_WINNT)
0f113f3e 73# undef OPENSSL_SYS_UNIX
0f113f3e 74# endif
68b00c23 75# if defined(OPENSSL_SYS_WINCE)
0f113f3e 76# undef OPENSSL_SYS_UNIX
0f113f3e 77# endif
0bf23d9b 78# endif
cf1b7d96 79# endif
cf1b7d96
RL
80
81/* Anything that tries to look like Microsoft is "Windows" */
3f131556 82# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
0f113f3e
MC
83# undef OPENSSL_SYS_UNIX
84# define OPENSSL_SYS_WINDOWS
85# ifndef OPENSSL_SYS_MSDOS
86# define OPENSSL_SYS_MSDOS
87# endif
1961b327 88# endif
cf1b7d96 89
0f113f3e
MC
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
5cac59b6
RL
101# endif
102# endif
5cac59b6 103
0f113f3e 104/* ------------------------------- OpenVMS -------------------------------- */
ac2aa13a 105# if defined(__VMS) || defined(VMS)
68b00c23
RS
106# if !defined(OPENSSL_SYS_VMS)
107# undef OPENSSL_SYS_UNIX
ac2aa13a 108# define OPENSSL_SYS_VMS
68b00c23 109# endif
0f113f3e
MC
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
cf1b7d96 118# endif
dc01b6b1 119
0f113f3e
MC
120/* -------------------------------- Unix ---------------------------------- */
121# ifdef OPENSSL_SYS_UNIX
68b00c23 122# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)
0f113f3e
MC
123# define OPENSSL_SYS_LINUX
124# endif
68b00c23 125# if defined(_AIX) && !defined(OPENSSL_SYS_AIX)
0f113f3e
MC
126# define OPENSSL_SYS_AIX
127# endif
cf1b7d96 128# endif
cf1b7d96 129
0f113f3e 130/* -------------------------------- VOS ----------------------------------- */
68b00c23 131# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)
0f113f3e
MC
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
28a80034 140
08073700
RB
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
cf1b7d96
RL
156/**
157 * That's it for OS-specific stuff
158 *****************************************************************************/
159
1d97c843 160/*-
6cef8015
RL
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:
1d97c843
TH
169 *
170 * #ifdef SOME_BUILD_FLAG_MACRO
171 * # undef OPENSSL_EXTERN
172 * # define OPENSSL_EXTERN OPENSSL_EXPORT
173 * #endif
174 *
9c5e87bf 175 * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN
9716b0b9 176 * have some generally sensible values.
1d97c843 177 */
2a4a0a34 178
6cef8015 179# if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
0f113f3e 180# define OPENSSL_EXPORT extern __declspec(dllexport)
9716b0b9 181# define OPENSSL_EXTERN extern __declspec(dllimport)
0f113f3e
MC
182# else
183# define OPENSSL_EXPORT extern
9716b0b9 184# define OPENSSL_EXTERN extern
0f113f3e 185# endif
2a4a0a34 186
f4bd5de5
AP
187# ifdef _WIN32
188# ifdef _WIN64
189# define ossl_ssize_t __int64
e634b448 190# define OSSL_SSIZE_MAX _I64_MAX
f4bd5de5
AP
191# else
192# define ossl_ssize_t int
e634b448 193# define OSSL_SSIZE_MAX INT_MAX
f4bd5de5 194# endif
0f113f3e 195# endif
eb1c48be 196
005f6766
QL
197# if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t)
198# define ossl_ssize_t INTN
199# define OSSL_SSIZE_MAX MAX_INTN
0f113f3e 200# endif
eb1c48be 201
0f113f3e 202# ifndef ossl_ssize_t
eb1c48be 203# define ossl_ssize_t ssize_t
2a7de0fd
JW
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
89310b8b
AP
208# else
209# define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))
2a7de0fd 210# endif
0f113f3e 211# endif
eb1c48be 212
a935791d 213# if defined(UNUSEDRESULT_DEBUG)
0f113f3e
MC
214# define __owur __attribute__((__warn_unused_result__))
215# else
216# define __owur
217# endif
acf20c7d 218
c1a623c5 219/* Standard integer types */
92bec78a
SL
220# define OPENSSL_NO_INTTYPES_H
221# define OPENSSL_NO_STDINT_H
cbb259ca 222# if defined(OPENSSL_SYS_UEFI)
4d60c7e1
DW
223typedef INT8 int8_t;
224typedef UINT8 uint8_t;
225typedef INT16 int16_t;
226typedef UINT16 uint16_t;
227typedef INT32 int32_t;
228typedef UINT32 uint32_t;
229typedef INT64 int64_t;
230typedef UINT64 uint64_t;
cbb259ca
DW
231# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
232 defined(__osf__) || defined(__sgi) || defined(__hpux) || \
6b44f259 233 defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__)
cbb259ca 234# include <inttypes.h>
92bec78a
SL
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
c35b8535 238# elif defined(_MSC_VER) && _MSC_VER<1600
c1a623c5
DSH
239/*
240 * minimally required typdefs for systems not supporting inttypes.h or
241 * stdint.h: currently just older VC++
242 */
243typedef signed char int8_t;
244typedef unsigned char uint8_t;
245typedef short int16_t;
246typedef unsigned short uint16_t;
247typedef int int32_t;
248typedef unsigned int uint32_t;
249typedef __int64 int64_t;
250typedef unsigned __int64 uint64_t;
c1a623c5
DSH
251# else
252# include <stdint.h>
92bec78a 253# undef OPENSSL_NO_STDINT_H
c1a623c5
DSH
254# endif
255
80e0ecbf
DSH
256/* ossl_inline: portable inline definition usable in public headers */
257# if !defined(inline) && !defined(__cplusplus)
258# if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
259 /* just use inline */
260# define ossl_inline inline
261# elif defined(__GNUC__) && __GNUC__>=2
262# define ossl_inline __inline__
263# elif defined(_MSC_VER)
264 /*
265 * Visual Studio: inline is available in C++ only, however
266 * __inline is available for C, see
267 * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
268 */
269# define ossl_inline __inline
270# else
271# define ossl_inline
272# endif
f820b792
M
273# else
274# define ossl_inline inline
80e0ecbf
DSH
275# endif
276
1f3b58d8
NR
277# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \
278 !defined(__cplusplus)
87275905 279# define ossl_noreturn _Noreturn
90edbfcc
AP
280# elif defined(__GNUC__) && __GNUC__ >= 2
281# define ossl_noreturn __attribute__((noreturn))
87275905 282# else
283# define ossl_noreturn
284# endif
285
48fe4ce1
RL
286/* ossl_unused: portable unused attribute for use in public headers */
287# if defined(__GNUC__)
288# define ossl_unused __attribute__((unused))
289# else
290# define ossl_unused
291# endif
292
2a4a0a34
BM
293#ifdef __cplusplus
294}
295#endif
296#endif