You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

e_os2.h 8.5 kB

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