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

Copyright © 1997-2022 Jeroen van der Zijp