Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | /* |
2 | * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
||
3 | * It is copyright by its individual contributors, as recorded in the |
||
4 | * project's Git history. See COPYING.txt at the top level for license |
||
5 | * terms and a link to the Git history. |
||
6 | */ |
||
7 | /* |
||
8 | * |
||
9 | * Common types and defines |
||
10 | * |
||
11 | */ |
||
12 | |||
13 | #ifndef _TYPES_H |
||
14 | #define _TYPES_H |
||
15 | |||
16 | #ifndef macintosh |
||
17 | #include <sys/types.h> |
||
18 | #endif |
||
19 | |||
20 | #include <cstdint> |
||
21 | #include <limits.h> |
||
22 | |||
23 | //define a signed byte |
||
24 | typedef signed char sbyte; |
||
25 | |||
26 | //define unsigned types; |
||
27 | typedef unsigned char ubyte; |
||
28 | #if defined(_WIN32) || defined(macintosh) |
||
29 | typedef unsigned short ushort; |
||
30 | typedef unsigned int uint; |
||
31 | #endif |
||
32 | |||
33 | #if defined(_WIN32) || defined(__sun__) // platforms missing (u_)int??_t |
||
34 | # include <SDL_types.h> |
||
35 | #elif defined(macintosh) // misses (u_)int??_t and does not like SDL_types.h |
||
36 | # include <MacTypes.h> |
||
37 | typedef SInt16 int16_t; |
||
38 | typedef SInt32 int32_t; |
||
39 | typedef SInt64 int64_t; |
||
40 | typedef UInt16 uint16_t; |
||
41 | typedef UInt32 uint32_t; |
||
42 | typedef UInt64 uint64_t; |
||
43 | #endif // macintosh |
||
44 | #if defined(_WIN32) || defined(__sun__) // platforms missing u_int??_t |
||
45 | typedef Uint16 uint16_t; |
||
46 | typedef Uint32 uint32_t; |
||
47 | typedef Uint64 uint64_t; |
||
48 | #endif // defined(_WIN32) || defined(__sun__) |
||
49 | |||
50 | #ifdef _MSC_VER |
||
51 | # include <stdlib.h> // this is where min and max are defined |
||
52 | #endif |
||
53 | |||
54 | // the following stuff has nothing to do with types but needed everywhere, |
||
55 | // and since this file is included everywhere, it's here. |
||
56 | #if defined(__i386__) || defined(__ia64__) || defined(_WIN32) || \ |
||
57 | (defined(__alpha__) || defined(__alpha)) || \ |
||
58 | defined(__arm__) || defined(ARM) || \ |
||
59 | (defined(__mips__) && defined(__MIPSEL__)) || \ |
||
60 | defined(__SYMBIAN32__) || \ |
||
61 | defined(__x86_64__) || \ |
||
62 | defined(__LITTLE_ENDIAN__) // from physfs_internal.h |
||
63 | //# define WORDS_BIGENDIAN 0 |
||
64 | #else |
||
65 | # define WORDS_BIGENDIAN 1 |
||
66 | #endif |
||
67 | |||
68 | #ifdef __GNUC__ |
||
69 | #ifdef WIN32 |
||
70 | # define __pack__ __attribute__((gcc_struct, packed)) |
||
71 | #else |
||
72 | # define __pack__ __attribute__((packed)) |
||
73 | #endif |
||
74 | #elif defined(_MSC_VER) |
||
75 | # pragma pack(push, packing) |
||
76 | # pragma pack(1) |
||
77 | # define __pack__ |
||
78 | #elif defined(macintosh) |
||
79 | # pragma options align=packed |
||
80 | # define __pack__ |
||
81 | #else |
||
82 | # error "This program will not work without packed structures" |
||
83 | #endif |
||
84 | |||
85 | #endif //_TYPES_H |
||
86 |