Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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