e_os2.h 8.2 KB

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