blocxx
Types.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2005, Vintela, Inc. All rights reserved.
3 * Copyright (C) 2006, Novell, Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of
14 * Vintela, Inc.,
15 * nor Novell, Inc.,
16 * nor the names of its contributors or employees may be used to
17 * endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *******************************************************************************/
32 
33 
39 #ifndef BLOCXX_TYPES_HPP_INCLUDE_GUARD_
40 #define BLOCXX_TYPES_HPP_INCLUDE_GUARD_
41 #include "blocxx/BLOCXX_config.h"
42 
43 #ifdef BLOCXX_WIN32
44 
45 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
46 #include <wtypes.h>
47 
48 #ifdef max
49 #undef max
50 #endif
51 
52 #endif
53 
54 #ifndef __cplusplus
55 #error "BLOCXX_Types.hpp can only be included by c++ files"
56 #endif
57 
58 extern "C"
59 {
60 #include <sys/types.h>
61 }
62 
63 namespace BLOCXX_NAMESPACE
64 {
65 
66 typedef unsigned char UInt8;
67 typedef signed char Int8;
68 #if BLOCXX_SIZEOF_SHORT_INT == 2
69 typedef unsigned short UInt16;
70 typedef short Int16;
71 #define BLOCXX_INT16_IS_SHORT 1
72 #elif BLOCXX_SIZEOF_INT == 2
73 typedef unsigned int UInt16;
74 typedef int Int16;
75 #define BLOCXX_INT16_IS_INT 1
76 #endif
77 #if BLOCXX_SIZEOF_INT == 4
78 typedef unsigned int UInt32;
79 typedef int Int32;
80 #define BLOCXX_INT32_IS_INT 1
81 #elif BLOCXX_SIZEOF_LONG_INT == 4
82 typedef unsigned long UInt32;
83 typedef long Int32;
84 #define BLOCXX_INT32_IS_LONG 1
85 #endif
86 #if BLOCXX_SIZEOF_LONG_INT == 8
87 typedef unsigned long UInt64;
88 typedef long Int64;
89 #define BLOCXX_INT64_IS_LONG 1
90 #elif BLOCXX_SIZEOF_LONG_LONG_INT == 8
91 typedef unsigned long long UInt64;
92 typedef long long Int64;
93 #define BLOCXX_INT64_IS_LONG_LONG 1
94 #else
95 #error "Compiler must support 64 bit long"
96 #endif
97 #if BLOCXX_SIZEOF_DOUBLE == 8
98 typedef double Real64;
99 #define BLOCXX_REAL64_IS_DOUBLE 1
100 #elif BLOCXX_SIZEOF_LONG_DOUBLE == 8
101 typedef long double Real64;
102 #define BLOCXX_REAL64_IS_LONG_DOUBLE 1
103 #endif
104 #if BLOCXX_SIZEOF_FLOAT == 4
105 typedef float Real32;
106 #define BLOCXX_REAL32_IS_FLOAT 1
107 #elif BLOCXX_SIZEOF_DOUBLE == 4
108 typedef double Real32;
109 #define BLOCXX_REAL32_IS_DOUBLE 1
110 #endif
111 
112 #ifdef BLOCXX_WIN32
113 
114 typedef HANDLE FileHandle;
115 typedef HANDLE Descriptor;
116 #define BLOCXX_INVALID_HANDLE INVALID_HANDLE_VALUE
117 #define BLOCXX_INVALID_FILEHANDLE INVALID_HANDLE_VALUE
118 typedef PSID UserId;
119 typedef PSID uid_t;
120 typedef PSID gid_t;
121 typedef int mode_t;
122 typedef long ssize_t;
123 typedef HANDLE pid_t;
124 typedef HANDLE ProcId;
125 typedef struct {} siginfo_t;
126 
127 #define BLOCXX_SHAREDLIB_EXTENSION ".dll"
128 #define BLOCXX_FILENAME_SEPARATOR "\\"
129 #define BLOCXX_FILENAME_SEPARATOR_C '\\'
130 #define BLOCXX_PATHNAME_SEPARATOR ";"
131 
132 #else //ifdef BLOCXX_WIN32
133 
134 typedef int FileHandle;
135 typedef int Descriptor;
136 #define BLOCXX_INVALID_HANDLE -1
137 #define BLOCXX_INVALID_FILEHANDLE -1
138 typedef uid_t UserId;
139 typedef pid_t ProcId;
140 
141 #if defined BLOCXX_DARWIN
142 #define BLOCXX_SHAREDLIB_EXTENSION ".dylib.bundle"
143 #elif defined BLOCXX_HPUX && !defined(BLOCXX_ARCH_IA64)
144 #define BLOCXX_SHAREDLIB_EXTENSION ".sl"
145 #elif defined BLOCXX_HPUX
146 #define BLOCXX_SHAREDLIB_EXTENSION ".so"
147 #elif defined BLOCXX_NETWARE
148 #define BLOCXX_SHAREDLIB_EXTENSION ".nlm"
149 #else
150 #define BLOCXX_SHAREDLIB_EXTENSION ".so"
151 #endif
152 
153 #define BLOCXX_FILENAME_SEPARATOR "/"
154 #define BLOCXX_FILENAME_SEPARATOR_C '/'
155 #define BLOCXX_PATHNAME_SEPARATOR ":"
156 #endif //ifdef BLOCXX_WIN32
157 
158 } // end namespace BLOCXX_NAMESPACE
159 
160 #endif