Lunchbox  1.8.0
os.h
1 
2 /* Copyright (c) 2005-2013, 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/defines.h>
23 #include <lunchbox/compiler.h>
24 
25 #ifdef _WIN32
26 # ifndef _MSC_VER
27 # define USE_SYS_TYPES_FD_SET
28 # endif
29 # ifndef _WIN32_WINNT // Hopefully to higher than 0x500...
30 # define _WIN32_WINNT 0x501 // => XP, for WM_XBUTTONDOWN and others
31 # endif
32 # ifndef _USE_MATH_DEFINES
33 # define _USE_MATH_DEFINES
34 # endif
35 # ifndef WIN32_LEAN_AND_MEAN
36 # define WIN32_LEAN_AND_MEAN
37 # endif
38 # ifndef NOMINMAX
39 # define NOMINMAX
40 # endif
41 # include <winsock2.h>
42 # include <windows.h>
43 # include <windef.h>
44 #endif
45 
46 #include <cmath>
47 #include <cstdio>
48 #include <cstdlib>
49 
50 #ifndef _MSC_VER
51 # include <stdint.h>
52 # include <sys/param.h> // for MIN/MAX
53 # include <strings.h>
54 #endif
55 
56 #ifdef __APPLE__
57 # include <crt_externs.h>
58 # define environ (*_NSGetEnviron())
59 #elif !defined(_WIN32)
60 extern "C" char **environ;
61 #endif
62 
63 namespace lunchbox
64 {
66 static inline void setZero( void* ptr, const size_t size )
67 {
68 #ifdef _WIN32
69  ::memset( ptr, 0, size );
70 #else
71  ::bzero( ptr, size );
72 #endif
73 }
74 }
75 
76 #endif //LUNCHBOX_OS_H