Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

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,2025 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 #ifndef __CYGWIN__
89 #include <winsock2.h>
90 #endif
91 #include "winnt.h"
92 #include <commctrl.h> // For _TrackMouseEvent
93 #include <shellapi.h>
94 #include <imm.h> // IME
95 #ifdef UNICODE
96 #include <wchar.h> // Wide character support
97 #endif
98 #ifndef PROCESS_SUSPEND_RESUME
99 #define PROCESS_SUSPEND_RESUME 0x0800
100 #endif
101 #ifndef INVALID_FILE_ATTRIBUTES
102 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
103 #endif
104 #if (_MSC_VER >= 1400) // VC++ 2005 or newer
105 #include <intrin.h>
106 #endif
107 
108 // OpenGL includes
109 #ifdef HAVE_GL_H
110 #include <GL/gl.h>
111 #endif
112 //#ifdef WIN32
113 //#include <GL/glext.h>
114 //#endif
115 #ifndef GLAPIENTRY
116 #define GLAPIENTRY
117 #endif
118 #ifndef GLAPI
119 #define GLAPI
120 #endif
121 #ifndef GL_BGRA
122 #define GL_BGRA GL_BGRA_EXT
123 #endif
124 //#ifdef HAVE_GLU_H
125 //#include <GL/glu.h>
126 //#endif
127 
128 #else
129 
130 // Common headers
131 #include <grp.h>
132 #include <pwd.h>
133 #include <sys/ioctl.h>
134 #include <fcntl.h>
135 #include <sys/stat.h>
136 
137 #ifdef HAVE_SYS_STATVFS_H
138 #include <sys/statvfs.h>
139 #endif
140 #ifdef HAVE_SYS_MOUNT_H
141 #include <sys/mount.h>
142 #endif
143 #ifdef HAVE_UNISTD_H
144 #include <sys/types.h>
145 #include <unistd.h>
146 #endif
147 #ifdef HAVE_SYS_FILIO_H // Get FIONREAD on Solaris
148 #include <sys/filio.h>
149 #endif
150 #ifdef HAVE_SYS_WAIT_H
151 #include <sys/wait.h>
152 #endif
153 #ifdef HAVE_SYS_PARAM_H
154 #include <sys/param.h>
155 #endif
156 #ifdef HAVE_DIRENT_H // Directory scanning
157 #include <dirent.h>
158 #endif
159 #ifdef HAVE_SYS_SELECT_H // Event handling
160 #include <sys/select.h>
161 #endif
162 #ifdef HAVE_SYS_EPOLL_H
163 #include <sys/epoll.h>
164 #endif
165 #ifdef HAVE_SYS_TIMERFD_H
166 #include <sys/timerfd.h>
167 #endif
168 #ifdef HAVE_SYS_RESOURCE_H
169 #include <sys/resource.h>
170 #endif
171 #ifdef HAVE_SYS_IPC_H
172 #include <sys/ipc.h>
173 #endif
174 #ifdef HAVE_SYS_SHM_H
175 #include <sys/shm.h>
176 #endif
177 #ifdef HAVE_SYS_MMAN_H
178 #include <sys/mman.h>
179 #endif
180 #ifdef HAVE_SYS_PSTAT_H
181 #include <sys/pstat.h>
182 #endif
183 #ifdef HAVE_SYS_INOTIFY_H
184 #include <sys/inotify.h>
185 #endif
186 #ifdef HAVE_SYS_UTSNAME_H
187 #include <sys/utsname.h>
188 #endif
189 #ifdef HAVE_SYS_SYSCTL_H
190 #if !defined(__linux__)
191 #include <sys/sysctl.h>
192 #endif
193 #endif
194 #if defined(__APPLE__)
195 #include <libkern/OSAtomic.h>
196 #endif
197 #include <pthread.h>
198 #ifdef HAVE_SEMAPHORE_H
199 #include <semaphore.h>
200 #endif
201 #if defined(HAVE_PTHREAD_SETAFFINITY_NP)
202 #if defined(__FreeBSD__)
203 #include <osreldate.h>
204 #if __FreeBSD_version >= 702000
205 #include <pthread_np.h>
206 #include <sys/cpuset.h>
207 typedef cpuset_t cpu_set_t;
208 #endif
209 #endif
210 #endif
211 #if defined(__minix) // MINIX
212 #ifdef sleep
213 #undef sleep // We mean sleep not __pthread_sleep
214 #endif
215 #ifdef read
216 #undef read // We mean read not __pthread_read
217 #endif
218 #ifdef write
219 #undef write // We mean write not __pthread_write
220 #endif
221 #ifdef select
222 #undef select // We mean select not __pthread_select
223 #endif
224 #endif
225 
226 // Dynamic library loading
227 #ifdef HAVE_SHL_LOAD
228 #include <dl.h> // HP-UX
229 #ifndef DYNAMIC_PATH
230 #define DYNAMIC_PATH 0
231 #endif
232 #ifndef BIND_RESTRICTED
233 #define BIND_RESTRICTED 0
234 #endif
235 #else
236 #ifdef HAVE_DLFCN_H
237 #include <dlfcn.h> // POSIX
238 #endif
239 #endif
240 #ifndef RTLD_GLOBAL
241 #define RTLD_GLOBAL 0 // Does not exist on DEC
242 #endif
243 #ifndef RTLD_NOLOAD // Older GLIBC libraries
244 #define RTLD_NOLOAD 0
245 #endif
246 #ifndef RTLD_NOW // for OpenBSD
247 #define RTLD_NOW DL_LAZY
248 #endif
249 
250 // SSE Intrinsics only if available and turned on
251 #if ((defined(__GNUC__) || defined(__INTEL_COMPILER)) && (defined(__i386__) || defined(__x86_64__)))
252 #if defined(HAVE_IMMINTRIN_H)
253 #include <immintrin.h>
254 #if defined(__SSE__)
255 #define FOX_HAS_SSE
256 #endif
257 #if defined(__SSE2__)
258 #define FOX_HAS_SSE2
259 #endif
260 #if defined(__SSE3__)
261 #define FOX_HAS_SSE3
262 #endif
263 #if defined(__SSSE3__)
264 #define FOX_HAS_SSSE3
265 #endif
266 #if defined(__SSE4_1__) && defined(__SSE4_2__)
267 #define FOX_HAS_SSE4
268 #endif
269 #if defined(__AVX__)
270 #define FOX_HAS_AVX
271 #endif
272 #if defined(__AVX2__)
273 #define FOX_HAS_AVX2
274 #endif
275 #if defined(__FMA__)
276 #define FOX_HAS_FMA
277 #endif
278 #if defined(__F16C__)
279 #define FOX_HAS_F16
280 #endif
281 #endif
282 #endif
283 
284 
285 // X11 includes
286 #include <X11/X.h>
287 #include <X11/Xlib.h>
288 #include <X11/Xcms.h>
289 #include <X11/Xutil.h>
290 #include <X11/Xresource.h>
291 #include <X11/Xatom.h>
292 #include <X11/cursorfont.h>
293 #ifdef HAVE_XSHM_H
294 #include <X11/extensions/XShm.h>
295 #endif
296 #ifdef HAVE_XCURSOR_H
297 #include <X11/Xcursor/Xcursor.h>
298 #endif
299 #ifdef HAVE_XFT_H
300 #include <X11/Xft/Xft.h>
301 #endif
302 #ifdef HAVE_XSHAPE_H
303 #include <X11/extensions/shape.h>
304 #endif
305 #ifdef HAVE_XRANDR_H
306 #include <X11/extensions/Xrandr.h>
307 #endif
308 #ifdef HAVE_XFIXES_H
309 #include <X11/extensions/Xfixes.h>
310 #endif
311 #ifdef HAVE_XRENDER_H
312 #include <X11/extensions/Xrender.h>
313 #endif
314 #ifdef HAVE_XINPUT2_H
315 #include <X11/extensions/XInput2.h>
316 #endif
317 #ifndef NO_XIM
318 #ifndef XlibSpecificationRelease // Not defined until X11R5
319 #define NO_XIM
320 #elif XlibSpecificationRelease < 6 // Need at least Xlib X11R6
321 #define NO_XIM
322 #endif
323 #endif
324 
325 // OpenGL includes
326 #ifdef HAVE_GL_H
327 #ifndef SUN_OGL_NO_VERTEX_MACROS
328 #define SUN_OGL_NO_VERTEX_MACROS
329 #endif
330 #ifndef HPOGL_SUPPRESS_FAST_API
331 #define HPOGL_SUPPRESS_FAST_API
332 #endif
333 #include <GL/gl.h>
334 #ifdef HAVE_GLX_H
335 #include <GL/glx.h>
336 #endif
337 #endif
338 //#ifdef HAVE_GLU_H
339 //#include <GL/glu.h>
340 //#endif
341 
342 #endif
343 
344 // Maximum path length
345 #ifndef MAXPATHLEN
346 #if defined(PATH_MAX)
347 #define MAXPATHLEN PATH_MAX
348 #elif defined(_MAX_PATH)
349 #define MAXPATHLEN _MAX_PATH
350 #elif defined(MAX_PATH)
351 #define MAXPATHLEN MAX_PATH
352 #else
353 #define MAXPATHLEN 4096
354 #endif
355 #endif
356 
357 // Maximum host name length
358 #ifndef MAXHOSTNAMELEN
359 #define MAXHOSTNAMELEN 256
360 #endif
361 
362 // Some systems don't have it
363 #ifndef SEEK_SET
364 #define SEEK_SET 0
365 #endif
366 #ifndef SEEK_CUR
367 #define SEEK_CUR 1
368 #endif
369 #ifndef SEEK_END
370 #define SEEK_END 2
371 #endif
372 
373 // Remove crap
374 #ifdef VOID
375 #undef VOID
376 #endif
377 
378 #endif

Copyright © 1997-2022 Jeroen van der Zijp