e_os2.h revision 160815
161981Sbrian/* e_os2.h */ 261981Sbrian/* ==================================================================== 361981Sbrian * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 461981Sbrian * 561981Sbrian * Redistribution and use in source and binary forms, with or without 661981Sbrian * modification, are permitted provided that the following conditions 761981Sbrian * are met: 861981Sbrian * 961981Sbrian * 1. Redistributions of source code must retain the above copyright 1061981Sbrian * notice, this list of conditions and the following disclaimer. 1161981Sbrian * 1261981Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1361981Sbrian * notice, this list of conditions and the following disclaimer in 1461981Sbrian * the documentation and/or other materials provided with the 1561981Sbrian * distribution. 1661981Sbrian * 1761981Sbrian * 3. All advertising materials mentioning features or use of this 1861981Sbrian * software must display the following acknowledgment: 1961981Sbrian * "This product includes software developed by the OpenSSL Project 2061981Sbrian * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 2161981Sbrian * 2261981Sbrian * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 2361981Sbrian * endorse or promote products derived from this software without 2461981Sbrian * prior written permission. For written permission, please contact 2565843Sbrian * openssl-core@openssl.org. 2665843Sbrian * 2765843Sbrian * 5. Products derived from this software may not be called "OpenSSL" 2865843Sbrian * nor may "OpenSSL" appear in their names without prior written 2965843Sbrian * permission of the OpenSSL Project. 3065843Sbrian * 3165843Sbrian * 6. Redistributions of any form whatsoever must retain the following 3265843Sbrian * acknowledgment: 3365843Sbrian * "This product includes software developed by the OpenSSL Project 3465843Sbrian * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 3561981Sbrian * 3661981Sbrian * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 3761981Sbrian * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3861981Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 3961981Sbrian * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 4061981Sbrian * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4161981Sbrian * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 4261981Sbrian * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 4361981Sbrian * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4461981Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4561981Sbrian * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 4661981Sbrian * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 4761981Sbrian * OF THE POSSIBILITY OF SUCH DAMAGE. 4861981Sbrian * ==================================================================== 4961981Sbrian * 5061981Sbrian * This product includes cryptographic software written by Eric Young 5161981Sbrian * (eay@cryptsoft.com). This product includes software written by Tim 5261981Sbrian * Hudson (tjh@cryptsoft.com). 5361981Sbrian * 5461981Sbrian */ 5561981Sbrian 5661981Sbrian#include <openssl/opensslconf.h> 5761981Sbrian 5861981Sbrian#ifndef HEADER_E_OS2_H 5961981Sbrian#define HEADER_E_OS2_H 6061981Sbrian 6161981Sbrian#ifdef __cplusplus 6261981Sbrianextern "C" { 63108959Swollman#endif 64108959Swollman 6561981Sbrian/****************************************************************************** 6661981Sbrian * Detect operating systems. This probably needs completing. 6761981Sbrian * The result is that at least one OPENSSL_SYS_os macro should be defined. 6861981Sbrian * However, if none is defined, Unix is assumed. 6961981Sbrian **/ 7061981Sbrian 7161981Sbrian#define OPENSSL_SYS_UNIX 7261981Sbrian 7361981Sbrian/* ----------------------- Macintosh, before MacOS X ----------------------- */ 7461981Sbrian#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) 7561981Sbrian# undef OPENSSL_SYS_UNIX 7661981Sbrian# define OPENSSL_SYS_MACINTOSH_CLASSIC 7762054Sbrian#endif 7877496Sbrian 7977492Sbrian/* ----------------------- NetWare ----------------------------------------- */ 8061981Sbrian#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) 8161981Sbrian# undef OPENSSL_SYS_UNIX 8261981Sbrian# define OPENSSL_SYS_NETWARE 8361981Sbrian#endif 8461981Sbrian 8561981Sbrian/* ---------------------- Microsoft operating systems ---------------------- */ 8662644Ssheldonh 8761981Sbrian/* Note that MSDOS actually denotes 32-bit environments running on top of 88121620Sjesper MS-DOS, such as DJGPP one. */ 89123498Sjesper#if defined(OPENSSL_SYSNAME_MSDOS) 90121620Sjesper# undef OPENSSL_SYS_UNIX 9161981Sbrian# define OPENSSL_SYS_MSDOS 9261981Sbrian#endif 9361981Sbrian 9461981Sbrian/* For 32 bit environment, there seems to be the CygWin environment and then 9561981Sbrian all the others that try to do the same thing Microsoft does... */ 9661981Sbrian#if defined(OPENSSL_SYSNAME_UWIN) 9761981Sbrian# undef OPENSSL_SYS_UNIX 9861981Sbrian# define OPENSSL_SYS_WIN32_UWIN 9961981Sbrian#else 10061981Sbrian# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) 10194342Sgshapiro# undef OPENSSL_SYS_UNIX 10261981Sbrian# define OPENSSL_SYS_WIN32_CYGWIN 10361981Sbrian# else 10461981Sbrian# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) 10587514Scjc# undef OPENSSL_SYS_UNIX 10661981Sbrian# define OPENSSL_SYS_WIN32 10761981Sbrian# endif 10861981Sbrian# if defined(OPENSSL_SYSNAME_WINNT) 10962274Sbrian# undef OPENSSL_SYS_UNIX 11061981Sbrian# define OPENSSL_SYS_WINNT 11175809Sdirk# endif 11275809Sdirk# if defined(OPENSSL_SYSNAME_WINCE) 11375809Sdirk# undef OPENSSL_SYS_UNIX 11475809Sdirk# define OPENSSL_SYS_WINCE 11572677Speter# endif 11672677Speter# endif 11794342Sgshapiro#endif 11872677Speter 11961981Sbrian/* Anything that tries to look like Microsoft is "Windows" */ 12061981Sbrian#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) 12161981Sbrian# undef OPENSSL_SYS_UNIX 12261981Sbrian# define OPENSSL_SYS_WINDOWS 12387514Scjc# ifndef OPENSSL_SYS_MSDOS 12487514Scjc# define OPENSSL_SYS_MSDOS 125101607Sfanf# endif 12687514Scjc#endif 12787514Scjc 12887514Scjc/* DLL settings. This part is a bit tough, because it's up to the application 12987514Scjc implementor how he or she will link the application, so it requires some 13087514Scjc macro to be used. */ 131135591Sjkoshy#ifdef OPENSSL_SYS_WINDOWS 13287514Scjc# ifndef OPENSSL_OPT_WINDLL 13387514Scjc# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that 13487514Scjc DLL linkage should be used */ 13587514Scjc# define OPENSSL_OPT_WINDLL 13687514Scjc# endif 13787514Scjc# endif 13887514Scjc#endif 13987514Scjc 14087514Scjc/* -------------------------------- OpenVMS -------------------------------- */ 14187514Scjc#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) 14287514Scjc# undef OPENSSL_SYS_UNIX 14387514Scjc# define OPENSSL_SYS_VMS 14487514Scjc# if defined(__DECC) 14587514Scjc# define OPENSSL_SYS_VMS_DECC 14687514Scjc# elif defined(__DECCXX) 14787514Scjc# define OPENSSL_SYS_VMS_DECC 14887514Scjc# define OPENSSL_SYS_VMS_DECCXX 14987514Scjc# else 150105937Sthomas# define OPENSSL_SYS_VMS_NODECC 151105937Sthomas# endif 152105937Sthomas#endif 15387514Scjc 15487514Scjc/* --------------------------------- OS/2 ---------------------------------- */ 15587514Scjc#if defined(__EMX__) || defined(__OS2__) 15687514Scjc# undef OPENSSL_SYS_UNIX 15787514Scjc# define OPENSSL_SYS_OS2 15887514Scjc#endif 159128473Sdarrenr 160128473Sdarrenr/* --------------------------------- Unix ---------------------------------- */ 161128473Sdarrenr#ifdef OPENSSL_SYS_UNIX 16287514Scjc# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) 16387514Scjc# define OPENSSL_SYS_LINUX 16487514Scjc# endif 16587514Scjc# ifdef OPENSSL_SYSNAME_MPE 16687514Scjc# define OPENSSL_SYS_MPE 16787514Scjc# endif 16887514Scjc# ifdef OPENSSL_SYSNAME_SNI 16987514Scjc# define OPENSSL_SYS_SNI 17087514Scjc# endif 17187514Scjc# ifdef OPENSSL_SYSNAME_ULTRASPARC 17287514Scjc# define OPENSSL_SYS_ULTRASPARC 17387514Scjc# endif 17487514Scjc# ifdef OPENSSL_SYSNAME_NEWS4 17561981Sbrian# define OPENSSL_SYS_NEWS4 17661981Sbrian# endif 17765843Sbrian# ifdef OPENSSL_SYSNAME_MACOSX 17865843Sbrian# define OPENSSL_SYS_MACOSX 17965843Sbrian# endif 18065843Sbrian# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY 18165843Sbrian# define OPENSSL_SYS_MACOSX_RHAPSODY 18265843Sbrian# define OPENSSL_SYS_MACOSX 18365843Sbrian# endif 18465843Sbrian# ifdef OPENSSL_SYSNAME_SUNOS 18565843Sbrian# define OPENSSL_SYS_SUNOS 18665843Sbrian#endif 18761981Sbrian# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) 18861981Sbrian# define OPENSSL_SYS_CRAY 18961981Sbrian# endif 19061981Sbrian# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) 19161981Sbrian# define OPENSSL_SYS_AIX 19261981Sbrian# endif 19361981Sbrian#endif 19461981Sbrian 19561981Sbrian/* --------------------------------- VOS ----------------------------------- */ 19661981Sbrian#ifdef OPENSSL_SYSNAME_VOS 19761981Sbrian# define OPENSSL_SYS_VOS 19861981Sbrian#endif 19961981Sbrian 20061981Sbrian/* ------------------------------- VxWorks --------------------------------- */ 20161981Sbrian#ifdef OPENSSL_SYSNAME_VXWORKS 20261981Sbrian# define OPENSSL_SYS_VXWORKS 20361981Sbrian#endif 20461981Sbrian 20562206Sbrian/** 20662155Sbrian * That's it for OS-specific stuff 207103948Sbrian *****************************************************************************/ 208129424Sjoe 20962155Sbrian 21061981Sbrian/* Specials for I/O an exit */ 21161981Sbrian#ifdef OPENSSL_SYS_MSDOS 21261981Sbrian# define OPENSSL_UNISTD_IO <io.h> 21361981Sbrian# define OPENSSL_DECLARE_EXIT extern void exit(int); 21461981Sbrian#else 21561981Sbrian# define OPENSSL_UNISTD_IO OPENSSL_UNISTD 21665843Sbrian# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ 21765843Sbrian#endif 21865843Sbrian 21965843Sbrian/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare 22065843Sbrian certain global symbols that, with some compilers under VMS, have to be 22165843Sbrian defined and declared explicitely with globaldef and globalref. 22265843Sbrian Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare 22365843Sbrian DLL exports and imports for compilers under Win32. These are a little 22465843Sbrian more complicated to use. Basically, for any library that exports some 22565843Sbrian global variables, the following code must be present in the header file 22661981Sbrian that declares them, before OPENSSL_EXTERN is used: 22761981Sbrian 22861981Sbrian #ifdef SOME_BUILD_FLAG_MACRO 22961981Sbrian # undef OPENSSL_EXTERN 23061981Sbrian # define OPENSSL_EXTERN OPENSSL_EXPORT 23161981Sbrian #endif 23261981Sbrian 23361981Sbrian The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL 23461981Sbrian have some generally sensible values, and for OPENSSL_EXTERN to have the 23561981Sbrian value OPENSSL_IMPORT. 23661981Sbrian*/ 23761981Sbrian 23861981Sbrian#if defined(OPENSSL_SYS_VMS_NODECC) 23961981Sbrian# define OPENSSL_EXPORT globalref 24061981Sbrian# define OPENSSL_IMPORT globalref 24161981Sbrian# define OPENSSL_GLOBAL globaldef 24261981Sbrian#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) 24361981Sbrian# define OPENSSL_EXPORT extern __declspec(dllexport) 24461981Sbrian# define OPENSSL_IMPORT extern __declspec(dllimport) 24561981Sbrian# define OPENSSL_GLOBAL 24661981Sbrian#else 24761981Sbrian# define OPENSSL_EXPORT extern 24861981Sbrian# define OPENSSL_IMPORT extern 24961981Sbrian# define OPENSSL_GLOBAL 25061981Sbrian#endif 25161981Sbrian#define OPENSSL_EXTERN OPENSSL_IMPORT 25261981Sbrian 253/* Macros to allow global variables to be reached through function calls when 254 required (if a shared library version requvres it, for example. 255 The way it's done allows definitions like this: 256 257 // in foobar.c 258 OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; 259 // in foobar.h 260 OPENSSL_DECLARE_GLOBAL(int,foobar); 261 #define foobar OPENSSL_GLOBAL_REF(foobar) 262*/ 263#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION 264# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ 265 extern type _hide_##name; \ 266 type *_shadow_##name(void) { return &_hide_##name; } \ 267 static type _hide_##name 268# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) 269# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) 270#else 271# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name 272# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name 273# define OPENSSL_GLOBAL_REF(name) _shadow_##name 274#endif 275 276#ifdef __cplusplus 277} 278#endif 279#endif 280