Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
include
xincs.h
1
/********************************************************************************
2
* *
3
* F O X P r i v a t e I n c l u d e F i l e s *
4
* *
5
*********************************************************************************
6
* Copyright (C) 1997,2026 by Jeroen van der Zijp. All Rights Reserved. *
7
*********************************************************************************
8
* This library is free software; you can redistribute it and/or modify *
9
* it under the terms of the GNU Lesser General Public License as published by *
10
* the Free Software Foundation; either version 3 of the License, or *
11
* (at your option) any later version. *
12
* *
13
* This library is distributed in the hope that it will be useful, *
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
* GNU Lesser General Public License for more details. *
17
* *
18
* You should have received a copy of the GNU Lesser General Public License *
19
* along with this program. If not, see <http://www.gnu.org/licenses/> *
20
********************************************************************************/
21
#ifndef XINCS_H
22
#define XINCS_H
23
24
26
27
// Thread safe
28
#ifndef _POSIX_PTHREAD_SEMANTICS
29
#define _POSIX_PTHREAD_SEMANTICS
30
#endif
31
32
// GNU extras if we can get them
33
#ifndef _GNU_SOURCE
34
#define _GNU_SOURCE
35
#endif
36
37
// Use 64-bit files
38
#ifndef WIN32
39
#ifndef _FILE_OFFSET_BITS
40
#define _FILE_OFFSET_BITS 64
41
#endif
42
#endif
43
44
45
// Basic includes
46
#include <cstdio>
47
#include <cstdlib>
48
#include <cstdarg>
49
#include <climits>
50
#include <cstdint>
51
#include <cmath>
52
#include <cfloat>
53
#include <cerrno>
54
#include <cctype>
55
#include <ctime>
56
#include <csignal>
57
#include <cstring>
58
#include <csignal>
59
#include <clocale>
60
61
62
// Platform includes
63
#if defined(WIN32)
64
65
// Windows 2000 is minimum now
66
#if _WIN32_WINNT < 0x0500
67
#define _WIN32_WINNT 0x0500
68
#endif
69
70
// Enforce handle types
71
#ifndef STRICT
72
#define STRICT 1
73
#endif
74
75
// Skip some stuff
76
#ifndef WIN32_LEAN_AND_MEAN
77
#define WIN32_LEAN_AND_MEAN
78
#endif
79
80
#if (_MSC_VER >= 1500)
81
#pragma warning(disable: 4251)
82
#endif
83
84
// Common headers
85
#include <windows.h>
// Core Windows stuff
86
#include <winspool.h>
// Printer stuff
87
#include <winternl.h>
88
#include <io.h>
89
#ifndef __CYGWIN__
90
#include <winsock2.h>
91
#endif
92
#include "winnt.h"
93
#include <commctrl.h>
// For _TrackMouseEvent
94
#include <shellapi.h>
95
#include <imm.h>
// IME
96
#include <sddl.h>
97
#ifdef UNICODE
98
#include <wchar.h>
// Wide character support
99
#endif
100
#ifndef PROCESS_SUSPEND_RESUME
101
#define PROCESS_SUSPEND_RESUME 0x0800
102
#endif
103
#ifndef INVALID_FILE_ATTRIBUTES
104
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
105
#endif
106
#if (_MSC_VER >= 1400) // VC++ 2005 or newer
107
#include <intrin.h>
108
#endif
109
110
// OpenGL includes
111
#ifdef HAVE_GL_H
112
#include <GL/gl.h>
113
#endif
114
//#ifdef WIN32
115
//#include <GL/glext.h>
116
//#endif
117
#ifndef GLAPIENTRY
118
#define GLAPIENTRY
119
#endif
120
#ifndef GLAPI
121
#define GLAPI
122
#endif
123
#ifndef GL_BGRA
124
#define GL_BGRA GL_BGRA_EXT
125
#endif
126
//#ifdef HAVE_GLU_H
127
//#include <GL/glu.h>
128
//#endif
129
130
#else
131
132
// Common headers
133
#include <grp.h>
134
#include <pwd.h>
135
#include <sys/ioctl.h>
136
#include <fcntl.h>
137
#include <sys/stat.h>
138
139
#ifdef HAVE_SYS_STATVFS_H
140
#include <sys/statvfs.h>
141
#endif
142
#ifdef HAVE_SYS_MOUNT_H
143
#include <sys/mount.h>
144
#endif
145
#ifdef HAVE_UNISTD_H
146
#include <sys/types.h>
147
#include <unistd.h>
148
#endif
149
#ifdef HAVE_SYS_FILIO_H // Get FIONREAD on Solaris
150
#include <sys/filio.h>
151
#endif
152
#ifdef HAVE_SYS_WAIT_H
153
#include <sys/wait.h>
154
#endif
155
#ifdef HAVE_SYS_PARAM_H
156
#include <sys/param.h>
157
#endif
158
#ifdef HAVE_DIRENT_H // Directory scanning
159
#include <dirent.h>
160
#endif
161
#ifdef HAVE_SYS_SELECT_H // Event handling
162
#include <sys/select.h>
163
#endif
164
#ifdef HAVE_SYS_EPOLL_H
165
#include <sys/epoll.h>
166
#endif
167
#ifdef HAVE_SYS_TIMERFD_H
168
#include <sys/timerfd.h>
169
#endif
170
#ifdef HAVE_SYS_RESOURCE_H
171
#include <sys/resource.h>
172
#endif
173
#ifdef HAVE_SYS_IPC_H
174
#include <sys/ipc.h>
175
#endif
176
#ifdef HAVE_SYS_SHM_H
177
#include <sys/shm.h>
178
#endif
179
#ifdef HAVE_SYS_MMAN_H
180
#include <sys/mman.h>
181
#endif
182
#ifdef HAVE_SYS_PSTAT_H
183
#include <sys/pstat.h>
184
#endif
185
#ifdef HAVE_SYS_INOTIFY_H
186
#include <sys/inotify.h>
187
#endif
188
#ifdef HAVE_SYS_UTSNAME_H
189
#include <sys/utsname.h>
190
#endif
191
#ifdef HAVE_SYS_SYSCTL_H
192
#if !defined(__linux__)
193
#include <sys/sysctl.h>
194
#endif
195
#endif
196
#if defined(__APPLE__)
197
#include <libkern/OSAtomic.h>
198
#endif
199
#include <pthread.h>
200
#ifdef HAVE_SEMAPHORE_H
201
#include <semaphore.h>
202
#endif
203
#if defined(HAVE_PTHREAD_SETAFFINITY_NP)
204
#if defined(__FreeBSD__)
205
#include <osreldate.h>
206
#if __FreeBSD_version >= 702000
207
#include <pthread_np.h>
208
#include <sys/cpuset.h>
209
typedef
cpuset_t cpu_set_t;
210
#endif
211
#endif
212
#endif
213
#if defined(__minix) // MINIX
214
#ifdef sleep
215
#undef sleep // We mean sleep not __pthread_sleep
216
#endif
217
#ifdef read
218
#undef read // We mean read not __pthread_read
219
#endif
220
#ifdef write
221
#undef write // We mean write not __pthread_write
222
#endif
223
#ifdef select
224
#undef select // We mean select not __pthread_select
225
#endif
226
#endif
227
228
// Dynamic library loading
229
#ifdef HAVE_SHL_LOAD
230
#include <dl.h>
// HP-UX
231
#ifndef DYNAMIC_PATH
232
#define DYNAMIC_PATH 0
233
#endif
234
#ifndef BIND_RESTRICTED
235
#define BIND_RESTRICTED 0
236
#endif
237
#else
238
#ifdef HAVE_DLFCN_H
239
#include <dlfcn.h>
// POSIX
240
#endif
241
#endif
242
#ifndef RTLD_GLOBAL
243
#define RTLD_GLOBAL 0 // Does not exist on DEC
244
#endif
245
#ifndef RTLD_NOLOAD // Older GLIBC libraries
246
#define RTLD_NOLOAD 0
247
#endif
248
#ifndef RTLD_NOW // for OpenBSD
249
#define RTLD_NOW DL_LAZY
250
#endif
251
252
// SSE Intrinsics only if available and turned on
253
#if ((defined(__GNUC__) || defined(__INTEL_COMPILER)) && (defined(__i386__) || defined(__x86_64__)))
254
#if defined(HAVE_IMMINTRIN_H)
255
#include <immintrin.h>
256
#if defined(__SSE__)
257
#define FOX_HAS_SSE
258
#endif
259
#if defined(__SSE2__)
260
#define FOX_HAS_SSE2
261
#endif
262
#if defined(__SSE3__)
263
#define FOX_HAS_SSE3
264
#endif
265
#if defined(__SSSE3__)
266
#define FOX_HAS_SSSE3
267
#endif
268
#if defined(__SSE4_1__) && defined(__SSE4_2__)
269
#define FOX_HAS_SSE4
270
#endif
271
#if defined(__AVX__)
272
#define FOX_HAS_AVX
273
#endif
274
#if defined(__AVX2__)
275
#define FOX_HAS_AVX2
276
#endif
277
#if defined(__FMA__)
278
#define FOX_HAS_FMA
279
#endif
280
#if defined(__F16C__)
281
#define FOX_HAS_F16
282
#endif
283
#endif
284
#endif
285
286
287
// X11 includes
288
#include <X11/X.h>
289
#include <X11/Xlib.h>
290
#include <X11/Xcms.h>
291
#include <X11/Xutil.h>
292
#include <X11/Xresource.h>
293
#include <X11/Xatom.h>
294
#include <X11/cursorfont.h>
295
#ifdef HAVE_XSHM_H
296
#include <X11/extensions/XShm.h>
297
#endif
298
#ifdef HAVE_XCURSOR_H
299
#include <X11/Xcursor/Xcursor.h>
300
#endif
301
#ifdef HAVE_XFT_H
302
#include <X11/Xft/Xft.h>
303
#endif
304
#ifdef HAVE_XSHAPE_H
305
#include <X11/extensions/shape.h>
306
#endif
307
#ifdef HAVE_XRANDR_H
308
#include <X11/extensions/Xrandr.h>
309
#endif
310
#ifdef HAVE_XFIXES_H
311
#include <X11/extensions/Xfixes.h>
312
#endif
313
#ifdef HAVE_XRENDER_H
314
#include <X11/extensions/Xrender.h>
315
#endif
316
#ifdef HAVE_XINPUT2_H
317
#include <X11/extensions/XInput2.h>
318
#endif
319
#ifndef NO_XIM
320
#ifndef XlibSpecificationRelease // Not defined until X11R5
321
#define NO_XIM
322
#elif XlibSpecificationRelease < 6 // Need at least Xlib X11R6
323
#define NO_XIM
324
#endif
325
#endif
326
327
// OpenGL includes
328
#ifdef HAVE_GL_H
329
#ifndef SUN_OGL_NO_VERTEX_MACROS
330
#define SUN_OGL_NO_VERTEX_MACROS
331
#endif
332
#ifndef HPOGL_SUPPRESS_FAST_API
333
#define HPOGL_SUPPRESS_FAST_API
334
#endif
335
#include <GL/gl.h>
336
#ifdef HAVE_GLX_H
337
#include <GL/glx.h>
338
#endif
339
#endif
340
//#ifdef HAVE_GLU_H
341
//#include <GL/glu.h>
342
//#endif
343
344
#endif
345
346
// Maximum path length
347
#ifndef MAXPATHLEN
348
#if defined(PATH_MAX)
349
#define MAXPATHLEN PATH_MAX
350
#elif defined(_MAX_PATH)
351
#define MAXPATHLEN _MAX_PATH
352
#elif defined(MAX_PATH)
353
#define MAXPATHLEN MAX_PATH
354
#else
355
#define MAXPATHLEN 4096
356
#endif
357
#endif
358
359
// Maximum host name length
360
#ifndef MAXHOSTNAMELEN
361
#define MAXHOSTNAMELEN 256
362
#endif
363
364
// Some systems don't have it
365
#ifndef SEEK_SET
366
#define SEEK_SET 0
367
#endif
368
#ifndef SEEK_CUR
369
#define SEEK_CUR 1
370
#endif
371
#ifndef SEEK_END
372
#define SEEK_END 2
373
#endif
374
375
// Remove crap
376
#ifdef VOID
377
#undef VOID
378
#endif
379
380
#endif
Copyright © 1997-2026 Jeroen van der Zijp