Types.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2004 Vintela, Inc. All rights reserved.
00003 * Copyright (C) 2005 Novell, Inc. All rights reserved.
00004 *
00005 * Redistribution and use in source and binary forms, with or without
00006 * modification, are permitted provided that the following conditions are met:
00007 *
00008 *  - Redistributions of source code must retain the above copyright notice,
00009 *    this list of conditions and the following disclaimer.
00010 *
00011 *  - Redistributions in binary form must reproduce the above copyright notice,
00012 *    this list of conditions and the following disclaimer in the documentation
00013 *    and/or other materials provided with the distribution.
00014 *
00015 *  - Neither the name of Vintela, Inc., Novell, Inc., nor the names of its
00016 *    contributors may be used to endorse or promote products derived from this
00017 *    software without specific prior written permission.
00018 *
00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc., Novell, Inc., OR THE 
00023 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00024 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00025 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00026 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00027 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00028 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00029 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 *******************************************************************************/
00031 
00032 
00038 #ifndef BLOCXX_TYPES_HPP_INCLUDE_GUARD_
00039 #define BLOCXX_TYPES_HPP_INCLUDE_GUARD_
00040 #include "blocxx/BLOCXX_config.h"
00041 
00042 #ifndef __cplusplus
00043 #error "BLOCXX_Types.hpp can only be included by c++ files"
00044 #endif
00045 
00046 extern "C"
00047 {
00048 #include <sys/types.h>
00049 }
00050 
00051 namespace BLOCXX_NAMESPACE
00052 {
00053 
00054 typedef unsigned char               UInt8;
00055 typedef signed char                 Int8;
00056 #if BLOCXX_SIZEOF_SHORT_INT == 2
00057 typedef unsigned short              UInt16;
00058 typedef short                 Int16;
00059 #define BLOCXX_INT16_IS_SHORT 1
00060 #elif BLOCXX_SIZEOF_INT == 2
00061 typedef unsigned int             UInt16;
00062 typedef int                      Int16;
00063 #define BLOCXX_INT16_IS_INT 1
00064 #endif
00065 #if BLOCXX_SIZEOF_INT == 4
00066 typedef unsigned int                UInt32;
00067 typedef int                   Int32;
00068 #define BLOCXX_INT32_IS_INT 1
00069 #elif BLOCXX_SIZEOF_LONG_INT == 4
00070 typedef unsigned long            UInt32;
00071 typedef long                     Int32;
00072 #define BLOCXX_INT32_IS_LONG 1
00073 #endif
00074 #if BLOCXX_SIZEOF_LONG_INT == 8
00075 typedef unsigned long   UInt64;
00076 typedef long    Int64;
00077 #define BLOCXX_INT64_IS_LONG 1
00078 #elif BLOCXX_SIZEOF_LONG_LONG_INT == 8
00079 typedef unsigned long long          UInt64;
00080 typedef long long             Int64;
00081 #define BLOCXX_INT64_IS_LONG_LONG 1
00082 #else
00083 #error "Compiler must support 64 bit long"
00084 #endif
00085 #if BLOCXX_SIZEOF_DOUBLE == 8
00086 typedef double                Real64;
00087 #define BLOCXX_REAL64_IS_DOUBLE 1
00088 #elif BLOCXX_SIZEOF_LONG_DOUBLE == 8
00089 typedef long double              Real64;
00090 #define BLOCXX_REAL64_IS_LONG_DOUBLE 1
00091 #endif
00092 #if BLOCXX_SIZEOF_FLOAT == 4
00093 typedef float                 Real32;
00094 #define BLOCXX_REAL32_IS_FLOAT 1
00095 #elif BLOCXX_SIZEOF_DOUBLE == 4
00096 typedef double                Real32;
00097 #define BLOCXX_REAL32_IS_DOUBLE 1
00098 #endif
00099 
00100 #ifdef BLOCXX_WIN32
00101 
00102 #define BLOCXX_SHAREDLIB_EXTENSION ".dll"
00103 #define BLOCXX_FILENAME_SEPARATOR "\\"
00104 #define BLOCXX_FILENAME_SEPARATOR_C '\\'
00105 #define BLOCXX_PATHNAME_SEPARATOR ";"
00106 
00107 #if __MINGW32__
00108 //
00109 // FIXME: I can't believe that this is MinGW specific,
00110 //        but this is the place where HANDLE and SOCKET
00111 //        types are defined...
00112 //
00113 #include <windef.h>
00114 #include <winsock2.h>
00115 #endif
00116 
00117 // BLOCXX_Select_t is the type of object that can be used in
00118 // synchronous I/O multiplexing (i.e. select).
00119 struct Select_t
00120 {
00121    Select_t() 
00122       : event(NULL)
00123       , sockfd(INVALID_SOCKET)
00124       , networkevents(0)
00125       , doreset(false)
00126    {
00127    }
00128 
00129    Select_t(const Select_t& arg)
00130       : event(arg.event)
00131       , sockfd(arg.sockfd)
00132       , networkevents(arg.networkevents)
00133       , doreset(arg.doreset)
00134    {
00135    }
00136    
00137    HANDLE event;
00138    SOCKET sockfd;
00139    long networkevents;
00140    bool doreset;
00141 };
00142 
00143 //typedef HANDLE Select_t;
00144 #else
00145 // Select_t is the type of object that can be used in
00146 // synchronous I/O multiplexing (i.e. select). There is a
00147 // possibility this can be something other than an int on
00148 // a platform we don't yet support.
00149 typedef int Select_t;
00150 
00151 #if defined BLOCXX_DARWIN
00152 #define BLOCXX_SHAREDLIB_EXTENSION ".dylib.bundle"
00153 #elif defined BLOCXX_HPUX
00154 #define BLOCXX_SHAREDLIB_EXTENSION ".sl"
00155 #elif defined BLOCXX_NETWARE
00156 #define BLOCXX_SHAREDLIB_EXTENSION ".nlm"
00157 #else
00158 #define BLOCXX_SHAREDLIB_EXTENSION ".so"
00159 #endif
00160 #define BLOCXX_FILENAME_SEPARATOR "/"
00161 #define BLOCXX_FILENAME_SEPARATOR_C '/'
00162 #define BLOCXX_PATHNAME_SEPARATOR ":"
00163 #endif
00164 
00165 #ifdef BLOCXX_WIN32
00166 typedef HANDLE FileHandle;
00167 typedef HANDLE Descriptor;
00168 #define BLOCXX_INVALID_FILEHANDLE INVALID_HANDLE_VALUE
00169 typedef int UserId;
00170 typedef int uid_t;
00171 typedef DWORD pid_t;
00172 typedef DWORD ProcId;
00173 typedef struct {} siginfo_t;
00174 #else
00175 typedef int FileHandle;
00176 typedef int Descriptor;
00177 #define BLOCXX_INVALID_FILEHANDLE -1
00178 typedef uid_t UserId;
00179 typedef pid_t ProcId;
00180 #endif
00181 
00182 } // end namespace BLOCXX_NAMESPACE
00183 
00184 #endif

Generated on Fri Jun 16 15:39:09 2006 for blocxx by  doxygen 1.4.6