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,2017 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 // Common headers
79 #include <windows.h> // Core Windows stuff
80 #include <winspool.h> // Printer stuff
81 #include <io.h> // For _access()
82 #ifndef __CYGWIN__
83 #include <winsock2.h>
84 #endif
85 #include <commctrl.h> // For _TrackMouseEvent
86 #include <shellapi.h>
87 #include <imm.h> // IME
88 #ifdef UNICODE
89 #include <wchar.h> // Wide character support
90 #endif
91 #ifndef PROCESS_SUSPEND_RESUME
92 #define PROCESS_SUSPEND_RESUME 0x0800
93 #endif
94 #ifndef INVALID_FILE_ATTRIBUTES
95 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
96 #endif
97 #if (_MSC_VER >= 1400) // VC++ 2005 or newer
98 #include <intrin.h>
99 #endif
100 
101 // OpenGL includes
102 #ifdef HAVE_GL_H
103 #include <GL/gl.h>
104 #endif
105 //#ifdef _WIN32
106 //#include <GL/glext.h>
107 //#endif
108 #ifndef GLAPIENTRY
109 #define GLAPIENTRY
110 #endif
111 #ifndef GLAPI
112 #define GLAPI
113 #endif
114 #ifndef GL_BGRA
115 #define GL_BGRA GL_BGRA_EXT
116 #endif
117 //#ifdef HAVE_GLU_H
118 //#include <GL/glu.h>
119 //#endif
120 
121 #else
122 
123 // Common headers
124 #include <grp.h>
125 #include <pwd.h>
126 #include <sys/ioctl.h>
127 #ifdef HAVE_SYS_STATVFS_H
128 #include <sys/statvfs.h>
129 #endif
130 #ifdef HAVE_SYS_MOUNT_H
131 #include <sys/mount.h>
132 #endif
133 #ifdef HAVE_UNISTD_H
134 #include <sys/types.h>
135 #include <unistd.h>
136 #endif
137 #ifdef HAVE_SYS_FILIO_H // Get FIONREAD on Solaris
138 #include <sys/filio.h>
139 #endif
140 #ifdef HAVE_SYS_WAIT_H
141 #include <sys/wait.h>
142 #endif
143 #ifdef HAVE_SYS_PARAM_H
144 #include <sys/param.h>
145 #endif
146 #ifdef HAVE_DIRENT_H
147 #include <dirent.h>
148 #define NAMLEN(dirent) strlen((dirent)->d_name)
149 #else
150 #define dirent direct
151 #define NAMLEN(dirent) (dirent)->d_namlen
152 #ifdef HAVE_SYS_NDIR_H
153 #include <sys/ndir.h>
154 #endif
155 #ifdef HAVE_SYS_DIR_H
156 #include <sys/dir.h>
157 #endif
158 #ifdef HAVE_NDIR_H
159 #include <ndir.h>
160 #endif
161 #endif
162 #ifdef TIME_WITH_SYS_TIME
163 #include <sys/time.h>
164 #include <time.h>
165 #else
166 #ifdef HAVE_SYS_TIME_H
167 #include <sys/time.h>
168 #else
169 #include <time.h>
170 #endif
171 #endif
172 #ifdef HAVE_SYS_SELECT_H
173 #include <sys/select.h>
174 #endif
175 #ifdef HAVE_SYS_EPOLL_H
176 #include <sys/epoll.h>
177 #endif
178 #ifdef HAVE_SYS_TIMERFD_H
179 #include <sys/timerfd.h>
180 #endif
181 #ifdef HAVE_SYS_IPC_H
182 #include <sys/ipc.h>
183 #endif
184 #ifdef HAVE_SYS_SHM_H
185 #include <sys/shm.h>
186 #endif
187 #ifdef HAVE_SYS_MMAN_H
188 #include <sys/mman.h>
189 #endif
190 #ifdef HAVE_SYS_SYSCTL_H
191 #include <sys/sysctl.h>
192 #endif
193 #ifdef HAVE_SYS_PSTAT_H
194 #include <sys/pstat.h>
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_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 #endif
281 #endif
282 
283 
284 // X11 includes
285 #include <X11/X.h>
286 #include <X11/Xlib.h>
287 #include <X11/Xcms.h>
288 #include <X11/Xutil.h>
289 #include <X11/Xresource.h>
290 #include <X11/Xatom.h>
291 #include <X11/cursorfont.h>
292 #ifdef HAVE_XSHM_H
293 #include <X11/extensions/XShm.h>
294 #endif
295 #ifdef HAVE_XCURSOR_H
296 #include <X11/Xcursor/Xcursor.h>
297 #endif
298 #ifdef HAVE_XFT_H
299 #include <X11/Xft/Xft.h>
300 #endif
301 #ifdef HAVE_XSHAPE_H
302 #include <X11/extensions/shape.h>
303 #endif
304 #ifdef HAVE_XRANDR_H
305 #include <X11/extensions/Xrandr.h>
306 #endif
307 #ifdef HAVE_XFIXES_H
308 #include <X11/extensions/Xfixes.h>
309 #endif
310 #ifdef HAVE_XRENDER_H
311 #include <X11/extensions/Xrender.h>
312 #endif
313 #ifdef HAVE_XINPUT2_H
314 #include <X11/extensions/XInput2.h>
315 #endif
316 #ifndef NO_XIM
317 #ifndef XlibSpecificationRelease // Not defined until X11R5
318 #define NO_XIM
319 #elif XlibSpecificationRelease < 6 // Need at least Xlib X11R6
320 #define NO_XIM
321 #endif
322 #endif
323 
324 // OpenGL includes
325 #ifdef HAVE_GL_H
326 #ifndef SUN_OGL_NO_VERTEX_MACROS
327 #define SUN_OGL_NO_VERTEX_MACROS
328 #endif
329 #ifndef HPOGL_SUPPRESS_FAST_API
330 #define HPOGL_SUPPRESS_FAST_API
331 #endif
332 #include <GL/gl.h>
333 #ifdef HAVE_GLX_H
334 #include <GL/glx.h>
335 #endif
336 #endif
337 //#ifdef HAVE_GLU_H
338 //#include <GL/glu.h>
339 //#endif
340 
341 #endif
342 
343 // Maximum path length
344 #ifndef MAXPATHLEN
345 #if defined(PATH_MAX)
346 #define MAXPATHLEN PATH_MAX
347 #elif defined(_MAX_PATH)
348 #define MAXPATHLEN _MAX_PATH
349 #elif defined(MAX_PATH)
350 #define MAXPATHLEN MAX_PATH
351 #else
352 #define MAXPATHLEN 2048
353 #endif
354 #endif
355 
356 // Maximum host name length
357 #ifndef MAXHOSTNAMELEN
358 #define MAXHOSTNAMELEN 256
359 #endif
360 
361 // Some systems don't have it
362 #ifndef SEEK_SET
363 #define SEEK_SET 0
364 #endif
365 #ifndef SEEK_CUR
366 #define SEEK_CUR 1
367 #endif
368 #ifndef SEEK_END
369 #define SEEK_END 2
370 #endif
371 
372 // Remove crap
373 #ifdef VOID
374 #undef VOID
375 #endif
376 
377 #endif

Copyright © 1997-2016 Jeroen van der Zijp