jpayne@69: /* jpayne@69: * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. jpayne@69: * jpayne@69: * Licensed under the OpenSSL license (the "License"). You may not use jpayne@69: * this file except in compliance with the License. You can obtain a copy jpayne@69: * in the file LICENSE in the source distribution or at jpayne@69: * https://www.openssl.org/source/license.html jpayne@69: */ jpayne@69: jpayne@69: #ifndef HEADER_E_OS2_H jpayne@69: # define HEADER_E_OS2_H jpayne@69: jpayne@69: # include jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /****************************************************************************** jpayne@69: * Detect operating systems. This probably needs completing. jpayne@69: * The result is that at least one OPENSSL_SYS_os macro should be defined. jpayne@69: * However, if none is defined, Unix is assumed. jpayne@69: **/ jpayne@69: jpayne@69: # define OPENSSL_SYS_UNIX jpayne@69: jpayne@69: /* --------------------- Microsoft operating systems ---------------------- */ jpayne@69: jpayne@69: /* jpayne@69: * Note that MSDOS actually denotes 32-bit environments running on top of jpayne@69: * MS-DOS, such as DJGPP one. jpayne@69: */ jpayne@69: # if defined(OPENSSL_SYS_MSDOS) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # endif jpayne@69: jpayne@69: /* jpayne@69: * For 32 bit environment, there seems to be the CygWin environment and then jpayne@69: * all the others that try to do the same thing Microsoft does... jpayne@69: */ jpayne@69: /* jpayne@69: * UEFI lives here because it might be built with a Microsoft toolchain and jpayne@69: * we need to avoid the false positive match on Windows. jpayne@69: */ jpayne@69: # if defined(OPENSSL_SYS_UEFI) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # elif defined(OPENSSL_SYS_UWIN) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # define OPENSSL_SYS_WIN32_UWIN jpayne@69: # else jpayne@69: # if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) jpayne@69: # define OPENSSL_SYS_WIN32_CYGWIN jpayne@69: # else jpayne@69: # if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # if !defined(OPENSSL_SYS_WIN32) jpayne@69: # define OPENSSL_SYS_WIN32 jpayne@69: # endif jpayne@69: # endif jpayne@69: # if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # if !defined(OPENSSL_SYS_WIN64) jpayne@69: # define OPENSSL_SYS_WIN64 jpayne@69: # endif jpayne@69: # endif jpayne@69: # if defined(OPENSSL_SYS_WINNT) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # endif jpayne@69: # if defined(OPENSSL_SYS_WINCE) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # endif jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: /* Anything that tries to look like Microsoft is "Windows" */ jpayne@69: # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # define OPENSSL_SYS_WINDOWS jpayne@69: # ifndef OPENSSL_SYS_MSDOS jpayne@69: # define OPENSSL_SYS_MSDOS jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: /* jpayne@69: * DLL settings. This part is a bit tough, because it's up to the jpayne@69: * application implementor how he or she will link the application, so it jpayne@69: * requires some macro to be used. jpayne@69: */ jpayne@69: # ifdef OPENSSL_SYS_WINDOWS jpayne@69: # ifndef OPENSSL_OPT_WINDLL jpayne@69: # if defined(_WINDLL) /* This is used when building OpenSSL to jpayne@69: * indicate that DLL linkage should be used */ jpayne@69: # define OPENSSL_OPT_WINDLL jpayne@69: # endif jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: /* ------------------------------- OpenVMS -------------------------------- */ jpayne@69: # if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS) jpayne@69: # if !defined(OPENSSL_SYS_VMS) jpayne@69: # undef OPENSSL_SYS_UNIX jpayne@69: # endif jpayne@69: # define OPENSSL_SYS_VMS jpayne@69: # if defined(__DECC) jpayne@69: # define OPENSSL_SYS_VMS_DECC jpayne@69: # elif defined(__DECCXX) jpayne@69: # define OPENSSL_SYS_VMS_DECC jpayne@69: # define OPENSSL_SYS_VMS_DECCXX jpayne@69: # else jpayne@69: # define OPENSSL_SYS_VMS_NODECC jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: /* -------------------------------- Unix ---------------------------------- */ jpayne@69: # ifdef OPENSSL_SYS_UNIX jpayne@69: # if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) jpayne@69: # define OPENSSL_SYS_LINUX jpayne@69: # endif jpayne@69: # if defined(_AIX) && !defined(OPENSSL_SYS_AIX) jpayne@69: # define OPENSSL_SYS_AIX jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: /* -------------------------------- VOS ----------------------------------- */ jpayne@69: # if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) jpayne@69: # define OPENSSL_SYS_VOS jpayne@69: # ifdef __HPPA__ jpayne@69: # define OPENSSL_SYS_VOS_HPPA jpayne@69: # endif jpayne@69: # ifdef __IA32__ jpayne@69: # define OPENSSL_SYS_VOS_IA32 jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: /** jpayne@69: * That's it for OS-specific stuff jpayne@69: *****************************************************************************/ jpayne@69: jpayne@69: /* Specials for I/O an exit */ jpayne@69: # ifdef OPENSSL_SYS_MSDOS jpayne@69: # define OPENSSL_UNISTD_IO jpayne@69: # define OPENSSL_DECLARE_EXIT extern void exit(int); jpayne@69: # else jpayne@69: # define OPENSSL_UNISTD_IO OPENSSL_UNISTD jpayne@69: # define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ jpayne@69: # endif jpayne@69: jpayne@69: /*- jpayne@69: * OPENSSL_EXTERN is normally used to declare a symbol with possible extra jpayne@69: * attributes to handle its presence in a shared library. jpayne@69: * OPENSSL_EXPORT is used to define a symbol with extra possible attributes jpayne@69: * to make it visible in a shared library. jpayne@69: * Care needs to be taken when a header file is used both to declare and jpayne@69: * define symbols. Basically, for any library that exports some global jpayne@69: * variables, the following code must be present in the header file that jpayne@69: * declares them, before OPENSSL_EXTERN is used: jpayne@69: * jpayne@69: * #ifdef SOME_BUILD_FLAG_MACRO jpayne@69: * # undef OPENSSL_EXTERN jpayne@69: * # define OPENSSL_EXTERN OPENSSL_EXPORT jpayne@69: * #endif jpayne@69: * jpayne@69: * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN jpayne@69: * have some generally sensible values. jpayne@69: */ jpayne@69: jpayne@69: # if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) jpayne@69: # define OPENSSL_EXPORT extern __declspec(dllexport) jpayne@69: # define OPENSSL_EXTERN extern __declspec(dllimport) jpayne@69: # else jpayne@69: # define OPENSSL_EXPORT extern jpayne@69: # define OPENSSL_EXTERN extern jpayne@69: # endif jpayne@69: jpayne@69: /*- jpayne@69: * Macros to allow global variables to be reached through function calls when jpayne@69: * required (if a shared library version requires it, for example. jpayne@69: * The way it's done allows definitions like this: jpayne@69: * jpayne@69: * // in foobar.c jpayne@69: * OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) jpayne@69: * // in foobar.h jpayne@69: * OPENSSL_DECLARE_GLOBAL(int,foobar); jpayne@69: * #define foobar OPENSSL_GLOBAL_REF(foobar) jpayne@69: */ jpayne@69: # ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION jpayne@69: # define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ jpayne@69: type *_shadow_##name(void) \ jpayne@69: { static type _hide_##name=value; return &_hide_##name; } jpayne@69: # define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) jpayne@69: # define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) jpayne@69: # else jpayne@69: # define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) type _shadow_##name=value; jpayne@69: # define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name jpayne@69: # define OPENSSL_GLOBAL_REF(name) _shadow_##name jpayne@69: # endif jpayne@69: jpayne@69: # ifdef _WIN32 jpayne@69: # ifdef _WIN64 jpayne@69: # define ossl_ssize_t __int64 jpayne@69: # define OSSL_SSIZE_MAX _I64_MAX jpayne@69: # else jpayne@69: # define ossl_ssize_t int jpayne@69: # define OSSL_SSIZE_MAX INT_MAX jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: # if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t) jpayne@69: # define ossl_ssize_t INTN jpayne@69: # define OSSL_SSIZE_MAX MAX_INTN jpayne@69: # endif jpayne@69: jpayne@69: # ifndef ossl_ssize_t jpayne@69: # define ossl_ssize_t ssize_t jpayne@69: # if defined(SSIZE_MAX) jpayne@69: # define OSSL_SSIZE_MAX SSIZE_MAX jpayne@69: # elif defined(_POSIX_SSIZE_MAX) jpayne@69: # define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX jpayne@69: # else jpayne@69: # define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1)) jpayne@69: # endif jpayne@69: # endif jpayne@69: jpayne@69: # ifdef DEBUG_UNUSED jpayne@69: # define __owur __attribute__((__warn_unused_result__)) jpayne@69: # else jpayne@69: # define __owur jpayne@69: # endif jpayne@69: jpayne@69: /* Standard integer types */ jpayne@69: # if defined(OPENSSL_SYS_UEFI) jpayne@69: typedef INT8 int8_t; jpayne@69: typedef UINT8 uint8_t; jpayne@69: typedef INT16 int16_t; jpayne@69: typedef UINT16 uint16_t; jpayne@69: typedef INT32 int32_t; jpayne@69: typedef UINT32 uint32_t; jpayne@69: typedef INT64 int64_t; jpayne@69: typedef UINT64 uint64_t; jpayne@69: # elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ jpayne@69: defined(__osf__) || defined(__sgi) || defined(__hpux) || \ jpayne@69: defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__) jpayne@69: # include jpayne@69: # elif defined(_MSC_VER) && _MSC_VER<1600 jpayne@69: /* jpayne@69: * minimally required typdefs for systems not supporting inttypes.h or jpayne@69: * stdint.h: currently just older VC++ jpayne@69: */ jpayne@69: typedef signed char int8_t; jpayne@69: typedef unsigned char uint8_t; jpayne@69: typedef short int16_t; jpayne@69: typedef unsigned short uint16_t; jpayne@69: typedef int int32_t; jpayne@69: typedef unsigned int uint32_t; jpayne@69: typedef __int64 int64_t; jpayne@69: typedef unsigned __int64 uint64_t; jpayne@69: # else jpayne@69: # include jpayne@69: # endif jpayne@69: jpayne@69: /* ossl_inline: portable inline definition usable in public headers */ jpayne@69: # if !defined(inline) && !defined(__cplusplus) jpayne@69: # if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L jpayne@69: /* just use inline */ jpayne@69: # define ossl_inline inline jpayne@69: # elif defined(__GNUC__) && __GNUC__>=2 jpayne@69: # define ossl_inline __inline__ jpayne@69: # elif defined(_MSC_VER) jpayne@69: /* jpayne@69: * Visual Studio: inline is available in C++ only, however jpayne@69: * __inline is available for C, see jpayne@69: * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx jpayne@69: */ jpayne@69: # define ossl_inline __inline jpayne@69: # else jpayne@69: # define ossl_inline jpayne@69: # endif jpayne@69: # else jpayne@69: # define ossl_inline inline jpayne@69: # endif jpayne@69: jpayne@69: # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \ jpayne@69: !defined(__cplusplus) jpayne@69: # define ossl_noreturn _Noreturn jpayne@69: # elif defined(__GNUC__) && __GNUC__ >= 2 jpayne@69: # define ossl_noreturn __attribute__((noreturn)) jpayne@69: # else jpayne@69: # define ossl_noreturn jpayne@69: # endif jpayne@69: jpayne@69: /* ossl_unused: portable unused attribute for use in public headers */ jpayne@69: # if defined(__GNUC__) jpayne@69: # define ossl_unused __attribute__((unused)) jpayne@69: # else jpayne@69: # define ossl_unused jpayne@69: # endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif