e_os2.h revision 160814
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 ----------------------------------- */ 196142425Snectar#ifdef OPENSSL_SYSNAME_VOS 197142425Snectar# define OPENSSL_SYS_VOS 198142425Snectar#endif 199142425Snectar 200109998Smarkm/* ------------------------------- VxWorks --------------------------------- */ 201109998Smarkm#ifdef OPENSSL_SYSNAME_VXWORKS 202109998Smarkm# define OPENSSL_SYS_VXWORKS 203109998Smarkm#endif 204109998Smarkm 205109998Smarkm/** 206109998Smarkm * That's it for OS-specific stuff 207109998Smarkm *****************************************************************************/ 208109998Smarkm 209109998Smarkm 210109998Smarkm/* Specials for I/O an exit */ 211109998Smarkm#ifdef OPENSSL_SYS_MSDOS 21255714Skris# define OPENSSL_UNISTD_IO <io.h> 21355714Skris# define OPENSSL_DECLARE_EXIT extern void exit(int); 21455714Skris#else 21555714Skris# define OPENSSL_UNISTD_IO OPENSSL_UNISTD 21655714Skris# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ 21755714Skris#endif 21855714Skris 219109998Smarkm/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare 220109998Smarkm certain global symbols that, with some compilers under VMS, have to be 221109998Smarkm defined and declared explicitely with globaldef and globalref. 222109998Smarkm Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare 223109998Smarkm DLL exports and imports for compilers under Win32. These are a little 224109998Smarkm more complicated to use. Basically, for any library that exports some 225109998Smarkm global variables, the following code must be present in the header file 226109998Smarkm that declares them, before OPENSSL_EXTERN is used: 22755714Skris 228109998Smarkm #ifdef SOME_BUILD_FLAG_MACRO 229109998Smarkm # undef OPENSSL_EXTERN 230109998Smarkm # define OPENSSL_EXTERN OPENSSL_EXPORT 231109998Smarkm #endif 232109998Smarkm 233109998Smarkm The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL 234109998Smarkm have some generally sensible values, and for OPENSSL_EXTERN to have the 235109998Smarkm value OPENSSL_IMPORT. 236109998Smarkm*/ 237109998Smarkm 238109998Smarkm#if defined(OPENSSL_SYS_VMS_NODECC) 239109998Smarkm# define OPENSSL_EXPORT globalref 240109998Smarkm# define OPENSSL_IMPORT globalref 24155714Skris# define OPENSSL_GLOBAL globaldef 242109998Smarkm#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) 243160814Ssimon# define OPENSSL_EXPORT extern __declspec(dllexport) 244160814Ssimon# define OPENSSL_IMPORT extern __declspec(dllimport) 245109998Smarkm# define OPENSSL_GLOBAL 24655714Skris#else 247109998Smarkm# define OPENSSL_EXPORT extern 248109998Smarkm# define OPENSSL_IMPORT extern 24955714Skris# define OPENSSL_GLOBAL 25055714Skris#endif 251109998Smarkm#define OPENSSL_EXTERN OPENSSL_IMPORT 25255714Skris 253109998Smarkm/* Macros to allow global variables to be reached through function calls when 254160814Ssimon required (if a shared library version requvres it, for example. 255109998Smarkm The way it's done allows definitions like this: 256109998Smarkm 257109998Smarkm // in foobar.c 258109998Smarkm OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; 259109998Smarkm // in foobar.h 260109998Smarkm OPENSSL_DECLARE_GLOBAL(int,foobar); 261109998Smarkm #define foobar OPENSSL_GLOBAL_REF(foobar) 262109998Smarkm*/ 263109998Smarkm#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION 264142425Snectar# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ 265142425Snectar extern type _hide_##name; \ 266142425Snectar type *_shadow_##name(void) { return &_hide_##name; } \ 267142425Snectar static type _hide_##name 268109998Smarkm# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) 269109998Smarkm# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) 270109998Smarkm#else 271109998Smarkm# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name 272109998Smarkm# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name 273109998Smarkm# define OPENSSL_GLOBAL_REF(name) _shadow_##name 274109998Smarkm#endif 275109998Smarkm 27655714Skris#ifdef __cplusplus 27755714Skris} 27855714Skris#endif 27955714Skris#endif 280