Pyrogenesis  trunk
wposix_types.h
Go to the documentation of this file.
1 /* Copyright (C) 2010 Wildfire Games.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 /*
24  * type definitions needed for wposix.
25  */
26 
27 #ifndef INCLUDED_WPOSIX_TYPES
28 #define INCLUDED_WPOSIX_TYPES
29 
30 #include <crtdefs.h> // intptr_t
31 
32 
33 //
34 // <inttypes.h>
35 //
36 
37 typedef signed char int8_t;
38 typedef short int16_t;
39 
40 // already defined by MinGW
41 #if MSC_VERSION
42 typedef int int32_t;
43 #endif
44 
45 #if MSC_VERSION || ICC_VERSION || LCC_VERSION
46 typedef __int64 int64_t;
47 #else
48 typedef long long int64_t;
49 #endif
50 
51 typedef unsigned char uint8_t;
52 typedef unsigned short uint16_t;
53 typedef unsigned int uint32_t;
54 #if MSC_VERSION || ICC_VERSION || LCC_VERSION
55 typedef unsigned __int64 uint64_t;
56 #else
57 typedef unsigned long long uint64_t;
58 #endif
59 
60 // note: we used to define [u]intptr_t here (if not already done).
61 // however, it's not necessary with VC7 and later, and the compiler's
62 // definition squelches 'pointer-to-int truncation' warnings, so don't.
63 
64 #if MSC_VERSION >= 1600
65 # include <cstdint>
66 #else // define them ourselves
67 # define INT16_MAX 32767
68 # define INT16_MIN (-INT16_MAX-1)
69 # define UINT16_MAX 65536u
70 # define UINT16_MIN 0u
71 # define INT32_MAX 2147483647
72 # define INT32_MIN (-INT32_MAX-1)
73 # define UINT32_MAX 4294967295u
74 # define UINT32_MIN 0u
75 #endif
76 
77 
78 //
79 // <sys/types.h>
80 //
81 
82 typedef intptr_t ssize_t;
83 // prevent wxWidgets from (incompatibly) redefining it
84 #define HAVE_SSIZE_T
85 
86 // VC9 defines off_t as long, but we need 64-bit file offsets even in
87 // 32-bit builds. to avoid conflicts, we have to define _OFF_T_DEFINED,
88 // which promises _off_t has also been defined. since that's used by
89 // CRT headers, we have to define it too, but must use the original
90 // long type to avoid breaking struct stat et al.
91 typedef __int64 off_t;
92 typedef long _off_t;
93 #define _OFF_T_DEFINED
94 
95 
96 //
97 // <limits.h>
98 //
99 
100 // Win32 MAX_PATH is 260; our number may be a bit more efficient.
101 #define PATH_MAX 256u
102 
103 #if OS_WIN
104 # ifndef SIZE_MAX // VC2005 already defines this in limits.h
105 # define SIZE_MAX 0xFFFFFFFF
106 # endif
107 #else
108 # define SIZE_MAX 0xFFFFFFFFFFFFFFFF
109 #endif
110 
111 
112 #endif // #ifndef INCLUDED_WPOSIX_TYPES
signed char int8_t
Definition: wposix_types.h:37
short int16_t
Definition: wposix_types.h:38
unsigned long long uint64_t
Definition: wposix_types.h:57
__int64 off_t
Definition: wposix_types.h:91
long _off_t
Definition: wposix_types.h:92
unsigned char uint8_t
Definition: wposix_types.h:51
intptr_t ssize_t
Definition: wposix_types.h:82
unsigned int uint32_t
Definition: wposix_types.h:53
unsigned short uint16_t
Definition: wposix_types.h:52
long long int64_t
Definition: wposix_types.h:48