e_os2.h revision 238405
155714Skris/* e_os2.h */ 2109998Smarkm/* ==================================================================== 3109998Smarkm * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 4109998Smarkm * 5109998Smarkm * Redistribution and use in source and binary forms, with or without 6109998Smarkm * modification, are permitted provided that the following conditions 7109998Smarkm * are met: 8109998Smarkm * 9109998Smarkm * 1. Redistributions of source code must retain the above copyright 10109998Smarkm * notice, this list of conditions and the following disclaimer. 11109998Smarkm * 12109998Smarkm * 2. Redistributions in binary form must reproduce the above copyright 13109998Smarkm * notice, this list of conditions and the following disclaimer in 14109998Smarkm * the documentation and/or other materials provided with the 15109998Smarkm * distribution. 16109998Smarkm * 17109998Smarkm * 3. All advertising materials mentioning features or use of this 18109998Smarkm * software must display the following acknowledgment: 19109998Smarkm * "This product includes software developed by the OpenSSL Project 20109998Smarkm * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21109998Smarkm * 22109998Smarkm * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23109998Smarkm * endorse or promote products derived from this software without 24109998Smarkm * prior written permission. For written permission, please contact 25109998Smarkm * openssl-core@openssl.org. 26109998Smarkm * 27109998Smarkm * 5. Products derived from this software may not be called "OpenSSL" 28109998Smarkm * nor may "OpenSSL" appear in their names without prior written 29109998Smarkm * permission of the OpenSSL Project. 30109998Smarkm * 31109998Smarkm * 6. Redistributions of any form whatsoever must retain the following 32109998Smarkm * acknowledgment: 33109998Smarkm * "This product includes software developed by the OpenSSL Project 34109998Smarkm * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35109998Smarkm * 36109998Smarkm * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37109998Smarkm * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39109998Smarkm * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40109998Smarkm * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41109998Smarkm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42109998Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43109998Smarkm * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45109998Smarkm * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46109998Smarkm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47109998Smarkm * OF THE POSSIBILITY OF SUCH DAMAGE. 48109998Smarkm * ==================================================================== 49109998Smarkm * 50109998Smarkm * This product includes cryptographic software written by Eric Young 51109998Smarkm * (eay@cryptsoft.com). This product includes software written by Tim 52109998Smarkm * Hudson (tjh@cryptsoft.com). 53109998Smarkm * 54109998Smarkm */ 5555714Skris 56109998Smarkm#include <openssl/opensslconf.h> 57109998Smarkm 5855714Skris#ifndef HEADER_E_OS2_H 5955714Skris#define HEADER_E_OS2_H 6055714Skris 6155714Skris#ifdef __cplusplus 6255714Skrisextern "C" { 6355714Skris#endif 6455714Skris 65109998Smarkm/****************************************************************************** 66109998Smarkm * Detect operating systems. This probably needs completing. 67109998Smarkm * The result is that at least one OPENSSL_SYS_os macro should be defined. 68109998Smarkm * However, if none is defined, Unix is assumed. 69109998Smarkm **/ 70109998Smarkm 71109998Smarkm#define OPENSSL_SYS_UNIX 72109998Smarkm 73109998Smarkm/* ----------------------- Macintosh, before MacOS X ----------------------- */ 74109998Smarkm#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) 75109998Smarkm# undef OPENSSL_SYS_UNIX 76109998Smarkm# define OPENSSL_SYS_MACINTOSH_CLASSIC 77109998Smarkm#endif 78109998Smarkm 79160814Ssimon/* ----------------------- NetWare ----------------------------------------- */ 80160814Ssimon#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) 81160814Ssimon# undef OPENSSL_SYS_UNIX 82160814Ssimon# define OPENSSL_SYS_NETWARE 83160814Ssimon#endif 84160814Ssimon 85109998Smarkm/* ---------------------- Microsoft operating systems ---------------------- */ 86109998Smarkm 87160814Ssimon/* Note that MSDOS actually denotes 32-bit environments running on top of 88160814Ssimon MS-DOS, such as DJGPP one. */ 89160814Ssimon#if defined(OPENSSL_SYSNAME_MSDOS) 90109998Smarkm# undef OPENSSL_SYS_UNIX 91109998Smarkm# define OPENSSL_SYS_MSDOS 92109998Smarkm#endif 93109998Smarkm 94109998Smarkm/* For 32 bit environment, there seems to be the CygWin environment and then 95109998Smarkm all the others that try to do the same thing Microsoft does... */ 96109998Smarkm#if defined(OPENSSL_SYSNAME_UWIN) 97109998Smarkm# undef OPENSSL_SYS_UNIX 98109998Smarkm# define OPENSSL_SYS_WIN32_UWIN 99109998Smarkm#else 100109998Smarkm# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) 101109998Smarkm# undef OPENSSL_SYS_UNIX 102109998Smarkm# define OPENSSL_SYS_WIN32_CYGWIN 103109998Smarkm# else 104109998Smarkm# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) 105109998Smarkm# undef OPENSSL_SYS_UNIX 106109998Smarkm# define OPENSSL_SYS_WIN32 107109998Smarkm# endif 108109998Smarkm# if defined(OPENSSL_SYSNAME_WINNT) 109109998Smarkm# undef OPENSSL_SYS_UNIX 110109998Smarkm# define OPENSSL_SYS_WINNT 111109998Smarkm# endif 112109998Smarkm# if defined(OPENSSL_SYSNAME_WINCE) 113109998Smarkm# undef OPENSSL_SYS_UNIX 114109998Smarkm# define OPENSSL_SYS_WINCE 115109998Smarkm# endif 116109998Smarkm# endif 117109998Smarkm#endif 118109998Smarkm 119109998Smarkm/* Anything that tries to look like Microsoft is "Windows" */ 120160814Ssimon#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) 121109998Smarkm# undef OPENSSL_SYS_UNIX 122109998Smarkm# define OPENSSL_SYS_WINDOWS 123109998Smarkm# ifndef OPENSSL_SYS_MSDOS 124109998Smarkm# define OPENSSL_SYS_MSDOS 125109998Smarkm# endif 126109998Smarkm#endif 127109998Smarkm 128109998Smarkm/* DLL settings. This part is a bit tough, because it's up to the application 129109998Smarkm implementor how he or she will link the application, so it requires some 130109998Smarkm macro to be used. */ 131109998Smarkm#ifdef OPENSSL_SYS_WINDOWS 132109998Smarkm# ifndef OPENSSL_OPT_WINDLL 133109998Smarkm# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that 134109998Smarkm DLL linkage should be used */ 135109998Smarkm# define OPENSSL_OPT_WINDLL 136109998Smarkm# endif 137109998Smarkm# endif 138109998Smarkm#endif 139109998Smarkm 140109998Smarkm/* -------------------------------- OpenVMS -------------------------------- */ 141109998Smarkm#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) 142109998Smarkm# undef OPENSSL_SYS_UNIX 143109998Smarkm# define OPENSSL_SYS_VMS 144109998Smarkm# if defined(__DECC) 145109998Smarkm# define OPENSSL_SYS_VMS_DECC 146109998Smarkm# elif defined(__DECCXX) 147109998Smarkm# define OPENSSL_SYS_VMS_DECC 148109998Smarkm# define OPENSSL_SYS_VMS_DECCXX 149109998Smarkm# else 150109998Smarkm# define OPENSSL_SYS_VMS_NODECC 151109998Smarkm# endif 152109998Smarkm#endif 153109998Smarkm 154109998Smarkm/* --------------------------------- OS/2 ---------------------------------- */ 155109998Smarkm#if defined(__EMX__) || defined(__OS2__) 156109998Smarkm# undef OPENSSL_SYS_UNIX 157109998Smarkm# define OPENSSL_SYS_OS2 158109998Smarkm#endif 159109998Smarkm 160109998Smarkm/* --------------------------------- Unix ---------------------------------- */ 161109998Smarkm#ifdef OPENSSL_SYS_UNIX 162109998Smarkm# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) 163109998Smarkm# define OPENSSL_SYS_LINUX 164109998Smarkm# endif 165109998Smarkm# ifdef OPENSSL_SYSNAME_MPE 166109998Smarkm# define OPENSSL_SYS_MPE 167109998Smarkm# endif 168109998Smarkm# ifdef OPENSSL_SYSNAME_SNI 169109998Smarkm# define OPENSSL_SYS_SNI 170109998Smarkm# endif 171109998Smarkm# ifdef OPENSSL_SYSNAME_ULTRASPARC 172109998Smarkm# define OPENSSL_SYS_ULTRASPARC 173109998Smarkm# endif 174109998Smarkm# ifdef OPENSSL_SYSNAME_NEWS4 175109998Smarkm# define OPENSSL_SYS_NEWS4 176109998Smarkm# endif 177109998Smarkm# ifdef OPENSSL_SYSNAME_MACOSX 178109998Smarkm# define OPENSSL_SYS_MACOSX 179109998Smarkm# endif 180109998Smarkm# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY 181109998Smarkm# define OPENSSL_SYS_MACOSX_RHAPSODY 182109998Smarkm# define OPENSSL_SYS_MACOSX 183109998Smarkm# endif 184109998Smarkm# ifdef OPENSSL_SYSNAME_SUNOS 185109998Smarkm# define OPENSSL_SYS_SUNOS 186109998Smarkm#endif 187109998Smarkm# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) 188109998Smarkm# define OPENSSL_SYS_CRAY 189109998Smarkm# endif 190109998Smarkm# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) 191109998Smarkm# define OPENSSL_SYS_AIX 192109998Smarkm# endif 193109998Smarkm#endif 194109998Smarkm 195142425Snectar/* --------------------------------- VOS ----------------------------------- */ 196238405Sjkim#if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS) 197142425Snectar# define OPENSSL_SYS_VOS 198238405Sjkim#ifdef __HPPA__ 199238405Sjkim# define OPENSSL_SYS_VOS_HPPA 200142425Snectar#endif 201238405Sjkim#ifdef __IA32__ 202238405Sjkim# define OPENSSL_SYS_VOS_IA32 203238405Sjkim#endif 204238405Sjkim#endif 205142425Snectar 206109998Smarkm/* ------------------------------- VxWorks --------------------------------- */ 207109998Smarkm#ifdef OPENSSL_SYSNAME_VXWORKS 208109998Smarkm# define OPENSSL_SYS_VXWORKS 209109998Smarkm#endif 210109998Smarkm 211238405Sjkim/* --------------------------------- BeOS ---------------------------------- */ 212238405Sjkim#if defined(__BEOS__) 213238405Sjkim# define OPENSSL_SYS_BEOS 214238405Sjkim# include <sys/socket.h> 215238405Sjkim# if defined(BONE_VERSION) 216238405Sjkim# define OPENSSL_SYS_BEOS_BONE 217238405Sjkim# else 218238405Sjkim# define OPENSSL_SYS_BEOS_R5 219238405Sjkim# endif 220238405Sjkim#endif 221238405Sjkim 222109998Smarkm/** 223109998Smarkm * That's it for OS-specific stuff 224109998Smarkm *****************************************************************************/ 225109998Smarkm 226109998Smarkm 227109998Smarkm/* Specials for I/O an exit */ 228109998Smarkm#ifdef OPENSSL_SYS_MSDOS 22955714Skris# define OPENSSL_UNISTD_IO <io.h> 23055714Skris# define OPENSSL_DECLARE_EXIT extern void exit(int); 23155714Skris#else 23255714Skris# define OPENSSL_UNISTD_IO OPENSSL_UNISTD 23355714Skris# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ 23455714Skris#endif 23555714Skris 236109998Smarkm/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare 237109998Smarkm certain global symbols that, with some compilers under VMS, have to be 238109998Smarkm defined and declared explicitely with globaldef and globalref. 239109998Smarkm Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare 240109998Smarkm DLL exports and imports for compilers under Win32. These are a little 241109998Smarkm more complicated to use. Basically, for any library that exports some 242109998Smarkm global variables, the following code must be present in the header file 243109998Smarkm that declares them, before OPENSSL_EXTERN is used: 24455714Skris 245109998Smarkm #ifdef SOME_BUILD_FLAG_MACRO 246109998Smarkm # undef OPENSSL_EXTERN 247109998Smarkm # define OPENSSL_EXTERN OPENSSL_EXPORT 248109998Smarkm #endif 249109998Smarkm 250109998Smarkm The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL 251109998Smarkm have some generally sensible values, and for OPENSSL_EXTERN to have the 252109998Smarkm value OPENSSL_IMPORT. 253109998Smarkm*/ 254109998Smarkm 255109998Smarkm#if defined(OPENSSL_SYS_VMS_NODECC) 256109998Smarkm# define OPENSSL_EXPORT globalref 257109998Smarkm# define OPENSSL_IMPORT globalref 25855714Skris# define OPENSSL_GLOBAL globaldef 259109998Smarkm#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) 260160814Ssimon# define OPENSSL_EXPORT extern __declspec(dllexport) 261160814Ssimon# define OPENSSL_IMPORT extern __declspec(dllimport) 262109998Smarkm# define OPENSSL_GLOBAL 26355714Skris#else 264109998Smarkm# define OPENSSL_EXPORT extern 265109998Smarkm# define OPENSSL_IMPORT extern 26655714Skris# define OPENSSL_GLOBAL 26755714Skris#endif 268109998Smarkm#define OPENSSL_EXTERN OPENSSL_IMPORT 26955714Skris 270109998Smarkm/* Macros to allow global variables to be reached through function calls when 271238405Sjkim required (if a shared library version requires it, for example. 272109998Smarkm The way it's done allows definitions like this: 273109998Smarkm 274109998Smarkm // in foobar.c 275238405Sjkim OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) 276109998Smarkm // in foobar.h 277109998Smarkm OPENSSL_DECLARE_GLOBAL(int,foobar); 278109998Smarkm #define foobar OPENSSL_GLOBAL_REF(foobar) 279109998Smarkm*/ 280109998Smarkm#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION 281238405Sjkim# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ 282238405Sjkim type *_shadow_##name(void) \ 283238405Sjkim { static type _hide_##name=value; return &_hide_##name; } 284109998Smarkm# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) 285109998Smarkm# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) 286109998Smarkm#else 287238405Sjkim# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value; 288109998Smarkm# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name 289109998Smarkm# define OPENSSL_GLOBAL_REF(name) _shadow_##name 290109998Smarkm#endif 291109998Smarkm 292238405Sjkim#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE) 293238405Sjkim# define ossl_ssize_t long 294238405Sjkim#endif 295238405Sjkim 296238405Sjkim#ifdef OPENSSL_SYS_MSDOS 297238405Sjkim# define ossl_ssize_t long 298238405Sjkim#endif 299238405Sjkim 300238405Sjkim#if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS) 301238405Sjkim# define ssize_t int 302238405Sjkim#endif 303238405Sjkim 304238405Sjkim#if defined(__ultrix) && !defined(ssize_t) 305238405Sjkim# define ossl_ssize_t int 306238405Sjkim#endif 307238405Sjkim 308238405Sjkim#ifndef ossl_ssize_t 309238405Sjkim# define ossl_ssize_t ssize_t 310238405Sjkim#endif 311238405Sjkim 31255714Skris#ifdef __cplusplus 31355714Skris} 31455714Skris#endif 31555714Skris#endif 316