Lunchbox  1.17.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
os.h
1 
2 /* Copyright (c) 2005-2018, 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 
19 #ifndef LUNCHBOX_OS_H
20 #define LUNCHBOX_OS_H
21 
22 #include <lunchbox/api.h>
23 #include <lunchbox/compiler.h>
24 #include <lunchbox/defines.h>
25 
26 #ifdef _WIN32
27 #ifndef WIN32
28 #define WIN32
29 #endif
30 #ifndef WIN32_API
31 #define WIN32_API
32 #endif
33 #ifndef _MSC_VER
34 #define USE_SYS_TYPES_FD_SET
35 #endif
36 #ifndef _WIN32_WINNT // Hopefully to higher than 0x500...
37 #define _WIN32_WINNT 0x501 // => XP, for WM_XBUTTONDOWN and others
38 #endif
39 #ifndef _USE_MATH_DEFINES
40 #define _USE_MATH_DEFINES
41 #endif
42 #ifndef WIN32_LEAN_AND_MEAN
43 #define WIN32_LEAN_AND_MEAN
44 #endif
45 #ifndef NOMINMAX
46 #define NOMINMAX
47 #endif
48 #include <windows.h>
49 #include <winsock2.h>
50 #endif
51 
52 #include <cmath>
53 #include <cstdio>
54 #include <cstdlib>
55 #include <string>
56 
57 #ifndef _MSC_VER
58 #include <stdint.h>
59 #include <strings.h>
60 #include <sys/param.h> // for MIN/MAX
61 #endif
62 
63 #ifdef __APPLE__
64 #include <crt_externs.h>
65 #define environ (*_NSGetEnviron())
66 #elif !defined(_WIN32)
67 extern "C" char** environ;
68 #endif
69 
70 namespace lunchbox
71 {
73 static inline void setZero(void* ptr, const size_t size)
74 {
75 #ifdef _WIN32
76  ::memset(ptr, 0, size);
77 #else
78  ::bzero(ptr, size);
79 #endif
80 }
81 
83 LUNCHBOX_API std::string getHostname();
84 }
85 
86 #endif // LUNCHBOX_OS_H
Defines export visibility macros for library Lunchbox.
std::string getHostname()
static void setZero(void *ptr, const size_t size)
OS-independent call to bzero(3).
Definition: os.h:73
Includes compile-time defines of Lunchbox.
Abstraction layer and common utilities for multi-threaded programming.
Definition: algorithm.h:29