#ifndef OSSL_E_OS_H
#define OSSL_E_OS_H
#include <limits.h>
#include <openssl/opensslconf.h>
#include <openssl/e_os2.h>
#include <openssl/crypto.h>
#include "internal/numbers.h"
#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
#define NO_CHMOD
#define NO_SYSLOG
#endif
#define get_last_sys_error() errno
#define clear_sys_error() errno = 0
#define set_sys_error(e) errno = (e)
#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
#define WIN32
#endif
#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
#define WINDOWS
#endif
#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
#define MSDOS
#endif
#ifdef WIN32
#undef get_last_sys_error
#undef clear_sys_error
#undef set_sys_error
#define get_last_sys_error() GetLastError()
#define clear_sys_error() SetLastError(0)
#define set_sys_error(e) SetLastError(e)
#if !defined(WINNT)
#define WIN_CONSOLE_BUG
#endif
#else
#endif
#if (defined(WINDOWS) || defined(MSDOS))
#ifdef __DJGPP__
#include <unistd.h>
#include <sys/stat.h>
#define _setmode setmode
#define _O_TEXT O_TEXT
#define _O_BINARY O_BINARY
#undef DEVRANDOM_EGD
#undef DEVRANDOM
#define DEVRANDOM "/dev/urandom\x24"
#endif
#ifndef S_IFDIR
#define S_IFDIR _S_IFDIR
#endif
#ifndef S_IFMT
#define S_IFMT _S_IFMT
#endif
#if !defined(WINNT) && !defined(__DJGPP__)
#define NO_SYSLOG
#endif
#ifdef WINDOWS
#if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#if defined(_WIN32_WCE) && !defined(EACCES)
#define EACCES 13
#endif
#include <string.h>
#include <malloc.h>
#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin)
#if _MSC_VER >= 1300 && _MSC_VER < 1600
#undef stdin
#undef stdout
#undef stderr
FILE *__iob_func(void);
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
#endif
#endif
#endif
#include <io.h>
#include <fcntl.h>
#ifdef OPENSSL_SYS_WINCE
#define OPENSSL_NO_POSIX_IO
#endif
#define EXIT(n) exit(n)
#define LIST_SEPARATOR_CHAR ';'
#ifndef W_OK
#define W_OK 2
#endif
#ifndef R_OK
#define R_OK 4
#endif
#ifdef OPENSSL_SYS_WINCE
#define DEFAULT_HOME ""
#else
#define DEFAULT_HOME "C:"
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1800
#define check_winnt() (1)
#define check_win_minplat(x) (1)
#else
#define check_winnt() (GetVersion() < 0x80000000)
#define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x))
#endif
#else
#if defined(OPENSSL_SYS_VXWORKS)
#include <time.h>
#else
#include <sys/time.h>
#endif
#ifdef OPENSSL_SYS_VMS
#define VMS 1
#include <stdlib.h>
#if defined(__DECC)
#include <unistd.h>
#else
#include <unixlib.h>
#endif
#define LIST_SEPARATOR_CHAR ','
#undef DEVRANDOM
#define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1)
#define DEFAULT_HOME "SYS$LOGIN:"
#else
#include <unistd.h>
#include <sys/types.h>
#ifdef OPENSSL_SYS_WIN32_CYGWIN
#include <io.h>
#include <fcntl.h>
#endif
#define LIST_SEPARATOR_CHAR ':'
#define EXIT(n) exit(n)
#endif
#endif
#if defined(OPENSSL_SYS_WINDOWS)
#if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(_WIN32_WCE)
#define open _open
#define fdopen _fdopen
#define close _close
#ifndef strdup
#define strdup _strdup
#endif
#define unlink _unlink
#define fileno _fileno
#define isatty _isatty
#endif
#else
#include <strings.h>
#endif
#if defined(OPENSSL_SYS_VXWORKS)
#include <ioLib.h>
#include <tickLib.h>
#include <sysLib.h>
#include <vxWorks.h>
#include <sockLib.h>
#include <taskLib.h>
#define TTY_STRUCT int
#define sleep(a) taskDelay((a) * sysClkRateGet())
struct hostent *gethostbyname(const char *name);
struct hostent *gethostbyaddr(const char *addr, int length, int type);
struct servent *getservbyname(const char *name, const char *proto);
#endif
#if defined(__TANDEM) && defined(_GUARDIAN_TARGET)
#include <strings.h>
#include <netdb.h>
#define getservbyname(name, proto) getservbyname((char *)name, proto)
#define gethostbyname(name) gethostbyname((char *)name)
#define ioctlsocket(a, b, c) ioctl(a, b, c)
#ifdef NO_GETPID
inline int nssgetpid(void);
#ifndef NSSGETPID_MACRO
#define NSSGETPID_MACRO
#include <cextdecs.h(PROCESSHANDLE_GETMINE_)>
#include <cextdecs.h(PROCESSHANDLE_DECOMPOSE_)>
inline int nssgetpid(void)
{
short phandle[10] = { 0 };
union pseudo_pid {
struct {
short cpu;
short pin;
} cpu_pin;
int ppid;
} ppid = { 0 };
PROCESSHANDLE_GETMINE_(phandle);
PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin);
return ppid.ppid;
}
#define getpid(a) nssgetpid(a)
#endif
#endif
#if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_)
#define SPT_THREAD_SIGNAL 1
#define SPT_THREAD_AWARE 1
#include <spthread.h>
#undef close
#define close spt_close
#define accept(a, b, c) accept(a, (struct sockaddr *)b, c)
#define recvfrom(a, b, c, d, e, f) recvfrom(a, b, (socklen_t)c, d, e, f)
#endif
#endif
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#define CRYPTO_memcmp memcmp
#endif
#ifndef OPENSSL_NO_SECURE_MEMORY
#if (defined(OPENSSL_SYS_UNIX) \
&& ((defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
|| defined(__sun) || defined(__hpux) || defined(__sgi) \
|| defined(__osf__))) \
|| defined(_WIN32)
#else
#define OPENSSL_NO_SECURE_MEMORY
#endif
#endif
#if defined(OPENSSL_SYS_WINDOWS)
#define locale_t _locale_t
#define freelocale _free_locale
#define strcasecmp_l _stricmp_l
#define strncasecmp_l _strnicmp_l
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#elif !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L \
|| defined(OPENSSL_SYS_TANDEM)
#ifndef OPENSSL_NO_LOCALE
#define OPENSSL_NO_LOCALE
#endif
#endif
#endif