forked from packetflinger/q2admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_platform.h
168 lines (142 loc) · 3.97 KB
/
q_platform.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
Copyright (C) 2012 Andrey Nazarov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//
// platform.h -- platform-specific definitions
//
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
#define DLLNAME ("gamex86.real.dll")
#elif defined(_WIN64)
#define DLLNAME ("gamex86_64.real.dll")
#else /*_WIN32 */
#ifdef __x86_64__
#define DLLNAME ("gamex86_64.real.so")
#else /*__x86_64__*/
#define DLLNAME ("gamex86.real.so")
#endif /*__x86_64__*/
#endif /*_WIN32*/
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <io.h>
#include <direct.h>
#include <winsock2.h>
#include <winsock.h>
#include <windows.h>
#include <ws2tcpip.h>
#define boolean qboolean
#else
#include <dlfcn.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/ioctl.h>
#define closesocket close
#define ioctlsocket ioctl
#endif
#ifdef _WIN32
#define MSG_DONTWAIT 0
#define AI_ADDRCONFIG 0x00000400
#endif
#ifdef _WIN32
#define PRIz "Iu"
#else
#define PRIz "zu"
#endif
#ifdef _WIN32
#define LIBSUFFIX ".dll"
#else
#define LIBSUFFIX ".so"
#endif
#ifdef _WIN32
#define PATH_SEP_CHAR '\\'
#define PATH_SEP_STRING "\\"
#else
#define PATH_SEP_CHAR '/'
#define PATH_SEP_STRING "/"
#endif
#ifdef _WIN32
#define os_mkdir(p) _mkdir(p)
#define os_unlink(p) _unlink(p)
#define os_stat(p, s) _stat(p, s)
#define os_fstat(f, s) _fstat(f, s)
#define os_fileno(f) _fileno(f)
#define os_access(p, m) _access(p, m)
#define Q_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#define Q_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define Q_STATBUF struct _stat
#else
#define os_mkdir(p) mkdir(p, 0775)
#define os_unlink(p) unlink(p)
#define os_stat(p, s) stat(p, s)
#define os_fstat(f, s) fstat(f, s)
#define os_fileno(f) fileno(f)
#define os_access(p, m) access(p, m)
#define Q_ISREG(m) S_ISREG(m)
#define Q_ISDIR(m) S_ISDIR(m)
#define Q_STATBUF struct stat
#define q2a_inet_ntop inet_ntop
#endif
#ifndef F_OK
#define F_OK 0
#define X_OK 1
#define W_OK 2
#define R_OK 4
#endif
#ifdef __GNUC__
#define q_printf(f, a) __attribute__((format(printf, f, a)))
#define q_noreturn __attribute__((noreturn))
#define q_malloc __attribute__((malloc))
#if __GNUC__ >= 4
#define q_sentinel __attribute__((sentinel))
#else
#define q_sentinel
#endif
#define q_likely(x) __builtin_expect(!!(x), 1)
#define q_unlikely(x) __builtin_expect(!!(x), 0)
#if __GNUC__ >= 4
#define q_offsetof(t, m) __builtin_offsetof(t, m)
#else
#define q_offsetof(t, m) ((size_t)&((t *)0)->m)
#endif
#ifdef _WIN32
#define q_gameabi __attribute__((callee_pop_aggregate_return(0)))
#else
#define q_gameabi
#endif
#ifdef _WIN32
#define q_exported __attribute__((dllexport))
#else
#define q_exported __attribute__((visibility("default")))
#endif
#define q_unused __attribute__((unused))
#else /* __GNUC__ */
#define q_printf(f, a)
#define q_noreturn
#define q_malloc
#define q_sentinel
#define q_likely(x) !!(x)
#define q_unlikely(x) !!(x)
#define q_offsetof(t, m) ((size_t)&((t *)0)->m)
#define q_gameabi
#ifdef _WIN32
#define q_exported __declspec(dllexport)
#else
#define q_exported
#endif
#define q_unused
#endif /* !__GNUC__ */