/
ncompat.h
107 lines (90 loc) · 1.73 KB
/
ncompat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* See Licensing and Copyright notice in naev.h
*/
#ifndef NCOMPAT_H
# define NCOMPAT_H
#include "SDL.h"
/* System specific. */
/**
* @brief System is Linux-class.
*/
#if (defined(linux) || defined(__linux) || defined(__linux__))
#define HAS_LINUX 1
#else
#define HAS_LINUX 0
#endif
/**
* @brief System is FreeBSD.
*/
#if (defined(__FreeBSD__))
#define HAS_FREEBSD 1
#else
#define HAS_FREEBSD 0
#endif
/**
* @brief System is Windows-class.
*/
#if (defined(_WIN32))
#define HAS_WIN32 1
#else
#define HAS_WIN32 0
#endif
/**
* @brief System is macOS.
*/
#if (defined(__APPLE__) && defined(__MACH__))
#define HAS_MACOS 1
#else
#define HAS_MACOS 0
#endif
/* Standard specific. */
/**
* @brief Whether or not the system follows unix standards like $HOME.
*
* @note macOS does not define these macros, but does follow unix somewhat.
*/
#if (defined(__unix__) || defined(__unix) || HAS_MACOS)
#define HAS_UNIX 1
#else
#define HAS_UNIX 0
#endif
/**
* @brief Whether or not the system is compliant to POSIX.1.
*
* @note Most systems don't actually follow it fully so they don't declare that
* they support it. We consider unix good enough.
*/
#if HAS_UNIX
#define HAS_POSIX 1
#else
#define HAS_POSIX 0
#endif
/*
* Endianness.
*/
/**
* @brief Whether or not the system is big endian.
*/
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
#define HAS_BIGENDIAN 1
#else
#define HAS_BIGENDIAN 0
#endif
/**
* @brief Whether or not the system is little endian.
*/
#if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
#define HAS_LILENDIAN 1
#else
#define HAS_LILENDIAN 0
#endif
/* Misc stuff - mainly for debugging. */
/**
* @brief Whether or not to use filedescriptors.
*/
#if HAS_POSIX
#define HAS_FD 1
#else
#define HAS_FD 0
#endif
#endif /* NCOMPAT_H */