Lunchbox  1.16.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
types.h
Go to the documentation of this file.
1 
2 /* Copyright (c) 2007-2017, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
32 #ifndef LUNCHBOX_TYPES_H
33 #define LUNCHBOX_TYPES_H
34 
35 #include <lunchbox/defines.h>
36 #include <servus/types.h>
37 
38 #include <string>
39 #include <sys/types.h>
40 #include <vector>
41 
42 #ifndef _MSC_VER
43 #include <stdint.h>
44 #endif
45 
46 #ifdef _WIN32
47 #include <basetsd.h>
48 
49 typedef int socklen_t;
50 
51 #ifdef _MSC_VER
52 typedef UINT64 uint64_t;
53 typedef INT64 int64_t;
54 typedef UINT32 uint32_t;
55 typedef INT32 int32_t;
56 typedef UINT16 uint16_t;
57 typedef INT16 int16_t;
58 typedef UINT8 uint8_t;
59 typedef INT8 int8_t;
60 #ifndef HAVE_SSIZE_T
61 typedef SSIZE_T ssize_t;
62 #define HAVE_SSIZE_T
63 #endif
64 #endif // Win32, Visual C++
65 #endif // Win32
66 
68 #define LB_UNDEFINED_UINT16 (0xffffu)
69 
71 #define LB_UNDEFINED_UINT32 (0xffffffffu)
72 
74 #define LB_UNDEFINED_UINT64 (0xffffffffffffffffull)
75 
77 #define LB_MAX_UINT32 (0xfffffff0u)
78 
80 #define LB_TIMEOUT_INDEFINITE 0xffffffffu // Attn: identical to Win32 INFINITE!
81 
83 #define LB_TIMEOUT_DEFAULT 0xfffffffeu
84 
85 // Defining our own min/max macros seems to be the only sane way to get this
86 // functionality across platforms thanks to some screwup in the MS header files.
87 #define LB_MAX(a, b) \
88  ((a) > (b) ? (a) : (b))
89 #define LB_MIN(a, b) \
90  ((a) < (b) ? (a) : (b))
91 
92 #define LB_BIT1 (0x00000001u)
93 #define LB_BIT2 (0x00000002u)
94 #define LB_BIT3 (0x00000004u)
95 #define LB_BIT4 (0x00000008u)
96 #define LB_BIT5 (0x00000010u)
97 #define LB_BIT6 (0x00000020u)
98 #define LB_BIT7 (0x00000040u)
99 #define LB_BIT8 (0x00000080u)
100 
101 #define LB_BIT9 (0x00000100u)
102 #define LB_BIT10 (0x00000200u)
103 #define LB_BIT11 (0x00000400u)
104 #define LB_BIT12 (0x00000800u)
105 #define LB_BIT13 (0x00001000u)
106 #define LB_BIT14 (0x00002000u)
107 #define LB_BIT15 (0x00004000u)
108 #define LB_BIT16 (0x00008000u)
109 
110 #define LB_BIT17 (0x00010000u)
111 #define LB_BIT18 (0x00020000u)
112 #define LB_BIT19 (0x00040000u)
113 #define LB_BIT20 (0x00080000u)
114 #define LB_BIT21 (0x00100000u)
115 #define LB_BIT22 (0x00200000u)
116 #define LB_BIT23 (0x00400000u)
117 #define LB_BIT24 (0x00800000u)
118 
119 #define LB_BIT25 (0x01000000u)
120 #define LB_BIT26 (0x02000000u)
121 #define LB_BIT27 (0x04000000u)
122 #define LB_BIT28 (0x08000000u)
123 #define LB_BIT29 (0x10000000u)
124 #define LB_BIT30 (0x20000000u)
125 #define LB_BIT31 (0x40000000u)
126 #define LB_BIT32 (0x80000000u)
127 
128 #define LB_BIT33 (0x0000000100000000ull)
129 #define LB_BIT34 (0x0000000200000000ull)
130 #define LB_BIT35 (0x0000000400000000ull)
131 #define LB_BIT36 (0x0000000800000000ull)
132 #define LB_BIT37 (0x0000001000000000ull)
133 #define LB_BIT38 (0x0000002000000000ull)
134 #define LB_BIT39 (0x0000004000000000ull)
135 #define LB_BIT40 (0x0000008000000000ull)
136 
137 #define LB_BIT41 (0x0000010000000000ull)
138 #define LB_BIT42 (0x0000020000000000ull)
139 #define LB_BIT43 (0x0000040000000000ull)
140 #define LB_BIT44 (0x0000080000000000ull)
141 #define LB_BIT45 (0x0000100000000000ull)
142 #define LB_BIT46 (0x0000200000000000ull)
143 #define LB_BIT47 (0x0000400000000000ull)
144 #define LB_BIT48 (0x0000800000000000ull)
145 
146 #define LB_BIT49 (0x0001000000000000ull)
147 #define LB_BIT50 (0x0002000000000000ull)
148 #define LB_BIT51 (0x0004000000000000ull)
149 #define LB_BIT52 (0x0008000000000000ull)
150 #define LB_BIT53 (0x0010000000000000ull)
151 #define LB_BIT54 (0x0020000000000000ull)
152 #define LB_BIT55 (0x0040000000000000ull)
153 #define LB_BIT56 (0x0080000000000000ull)
154 
155 #define LB_BIT57 (0x0100000000000000ull)
156 #define LB_BIT58 (0x0200000000000000ull)
157 #define LB_BIT59 (0x0400000000000000ull)
158 #define LB_BIT60 (0x0800000000000000ull)
159 #define LB_BIT61 (0x1000000000000000ull)
160 #define LB_BIT62 (0x2000000000000000ull)
161 #define LB_BIT63 (0x4000000000000000ull)
162 #define LB_BIT64 (0x8000000000000000ull)
163 
164 #define LB_BIT_ALL_32 (0xffffffffu)
165 #define LB_BIT_ALL_64 (0xffffffffffffffffull)
166 #define LB_BIT_NONE (0)
167 
168 #define LB_1KB (1024)
169 #define LB_10KB (10240)
170 #define LB_100KB (102400)
171 #define LB_1MB (1048576)
172 #define LB_10MB (10485760)
173 #define LB_100MB (104857600)
174 #define LB_1GB (1073741824)
175 
176 #define LB_2KB (2048)
177 #define LB_4KB (4096)
178 #define LB_8KB (8192)
179 #define LB_16KB (16384)
180 #define LB_32KB (32768)
181 #define LB_64KB (65536)
182 #define LB_128KB (131072)
183 #define LB_256KB (262144)
184 #define LB_512KB (524288)
185 #define LB_2MB (2097152)
186 #define LB_4MB (4194304)
187 #define LB_8MB (8388608)
188 #define LB_16MB (16777216)
189 #define LB_32MB (33554432)
190 #define LB_48MB (50331648)
191 #define LB_64MB (67108864)
192 #define LB_128MB (134217728)
193 #define LB_256MB (268435456)
194 #define LB_512MB (536870912)
195 #define LB_4GB (4294967296u)
196 
198 struct GLEWContextStruct;
199 struct WGLEWContextStruct;
200 typedef struct GLEWContextStruct GLEWContext;
201 typedef struct WGLEWContextStruct WGLEWContext;
202 #define LB_DLLEXPORT LUNCHBOX_DLLEXPORT
203 #define LB_DLLIMPORT LUNCHBOX_DLLIMPORT
204 
206 #ifdef LUNCHBOX_USE_V1_API
207 namespace servus
208 {
209 class Servus;
210 class uint128_t;
211 class URI;
212 }
213 #endif
214 
215 namespace lunchbox
216 {
218 typedef std::vector<std::string> Strings;
219 typedef Strings::const_iterator StringsCIter;
220 typedef Strings::iterator StringsIter;
221 
222 class Clock;
223 class DSO;
224 class PersistentMap;
225 class Referenced;
226 class RequestHandler;
227 class SpinLock;
228 
229 template <class>
230 class Array;
231 template <class>
232 class Atomic;
233 template <class>
234 class Buffer;
235 template <class>
236 class Future;
237 template <class>
238 class Monitor;
239 template <class>
240 class Request;
241 template <class, class>
242 class LFVectorIterator;
243 template <class, class>
244 class Lockable;
245 template <class>
246 class Plugin;
247 template <class>
248 class PluginFactory;
249 template <class, int32_t>
250 class LFVector;
251 
253 typedef Atomic<ssize_t> a_ssize_t;
254 typedef Buffer<uint8_t> Bufferb;
258 typedef Future<ssize_t> f_ssize_t;
261 typedef std::vector<DSO*> DSOs;
262 
263 #ifdef LUNCHBOX_USE_V1_API
264 using servus::Servus;
265 using servus::uint128_t;
266 using servus::URI;
267 
268 typedef servus::uint128_t UUID;
269 #endif
270 }
271 
272 #endif // LUNCHBOX_TYPES_H
A wrapper for C arrays without any memory management.
Definition: array.h:30
Helper to access dynamic shared objects (DSO)
Definition: dso.h:38
An iterator for LFVector.
A variable with atomic semantics and standalone atomic operations.
Definition: atomic.h:87
A fast lock for uncontended memory access.
Definition: spinLock.h:38
A class for time measurements.
Definition: clock.h:33
STL-like vector implementation providing certain thread-safety guarantees.
Definition: lfVector.h:54
Future template specialization for void.
Definition: future.h:122
Factory for Plugin classes.
Definition: pluginFactory.h:56
Atomic< int32_t > a_int32_t
An atomic 32 bit integer variable.
Definition: types.h:252
A monitor primitive.
Definition: monitor.h:46
std::vector< DSO * > DSOs
A vector of DSO.
Definition: types.h:263
A convenience structure to hold data together with a lock for access.
Definition: lockable.h:35
A Future implementation for a RequestHandler request.
Definition: request.h:41
Atomic< ssize_t > a_ssize_t
An atomic signed size variable.
Definition: types.h:255
Includes compile-time defines of Lunchbox.
std::vector< std::string > Strings
A vector of std::strings.
Definition: types.h:220
A future represents a asynchronous operation.
Definition: future.h:62
Buffer< uint8_t > Bufferb
a byte buffer
Definition: types.h:256
Base class for referenced objects.
Definition: referenced.h:45
Abstraction layer and common utilities for multi-threaded programming.
Definition: algorithm.h:29
A thread-safe request handler.
Future< uint32_t > f_uint32_t
A future 32 bit unsigned promise.
Definition: types.h:259
Future< void > f_void_t
A future signed size promise.
Definition: types.h:261
Future< ssize_t > f_ssize_t
A future signed size promise.
Definition: types.h:260
A simple memory buffer with some helper functions.
Definition: buffer.h:44