00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XINCS_H
00022 #define XINCS_H
00023
00024
00026
00027
00028 #ifndef _POSIX_PTHREAD_SEMANTICS
00029 #define _POSIX_PTHREAD_SEMANTICS
00030 #endif
00031
00032
00033 #ifndef _GNU_SOURCE
00034 #define _GNU_SOURCE
00035 #endif
00036
00037
00038 #ifndef WIN32
00039 #ifndef _FILE_OFFSET_BITS
00040 #define _FILE_OFFSET_BITS 64
00041 #endif
00042 #endif
00043
00044
00045
00046 #include <stdio.h>
00047 #include <stdlib.h>
00048 #include <stdarg.h>
00049 #include <limits.h>
00050 #include <math.h>
00051 #include <float.h>
00052 #include <string.h>
00053 #include <errno.h>
00054 #include <signal.h>
00055 #include <time.h>
00056 #include <locale.h>
00057 #include <fcntl.h>
00058 #include <sys/stat.h>
00059
00060
00061 #if defined(WIN32) /////////////// Windows /////////////////////////////////////
00062
00063
00064 #if _WIN32_WINNT < 0x0400
00065 #define _WIN32_WINNT 0x0400
00066 #endif
00067 #ifndef STRICT
00068 #define STRICT
00069 #endif
00070 #ifndef WIN32_LEAN_AND_MEAN
00071 #define WIN32_LEAN_AND_MEAN
00072 #endif
00073 #include <windows.h>
00074 #include <winspool.h>
00075 #ifndef __CYGWIN__
00076 #include <winsock2.h>
00077 #endif
00078 #include <commctrl.h>
00079 #include <shellapi.h>
00080 #include <imm.h>
00081 #ifdef UNICODE
00082 #include <wchar.h>
00083 #endif
00084 #ifndef PROCESS_SUSPEND_RESUME
00085 #define PROCESS_SUSPEND_RESUME 0x0800
00086 #endif
00087 #ifndef INVALID_FILE_ATTRIBUTES
00088 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
00089 #endif
00090 #if (_MSC_VER >= 1400) // VC++ 2005 or newer
00091 #include <intrin.h>
00092 #endif
00093
00094
00095 #ifdef HAVE_GL_H
00096 #include <GL/gl.h>
00097 #endif
00098 #ifndef GLAPIENTRY
00099 #define GLAPIENTRY
00100 #endif
00101 #ifndef GLAPI
00102 #define GLAPI
00103 #endif
00104 #ifndef GL_BGRA
00105 #define GL_BGRA GL_BGRA_EXT
00106 #endif
00107 #ifdef HAVE_GLU_H
00108 #include <GL/glu.h>
00109 #endif
00110
00111 #else ////////////////////////////// Unix ///////////////////////////////////////
00112
00113
00114 #include <grp.h>
00115 #include <pwd.h>
00116 #include <sys/ioctl.h>
00117 #ifdef HAVE_SYS_STATFS_H
00118 #include <sys/statfs.h>
00119 #endif
00120 #ifdef HAVE_SYS_MOUNT_H
00121 #include <sys/mount.h>
00122 #endif
00123 #ifdef HAVE_UNISTD_H
00124 #include <sys/types.h>
00125 #include <unistd.h>
00126 #endif
00127 #ifdef HAVE_SYS_FILIO_H // Get FIONREAD on Solaris
00128 #include <sys/filio.h>
00129 #endif
00130 #ifdef HAVE_SYS_WAIT_H
00131 #include <sys/wait.h>
00132 #endif
00133 #ifdef HAVE_SYS_PARAM_H
00134 #include <sys/param.h>
00135 #endif
00136 #ifdef HAVE_DIRENT_H
00137 #include <dirent.h>
00138 #define NAMLEN(dirent) strlen((dirent)->d_name)
00139 #else
00140 #define dirent direct
00141 #define NAMLEN(dirent) (dirent)->d_namlen
00142 #ifdef HAVE_SYS_NDIR_H
00143 #include <sys/ndir.h>
00144 #endif
00145 #ifdef HAVE_SYS_DIR_H
00146 #include <sys/dir.h>
00147 #endif
00148 #ifdef HAVE_NDIR_H
00149 #include <ndir.h>
00150 #endif
00151 #endif
00152 #ifdef TIME_WITH_SYS_TIME
00153 #include <sys/time.h>
00154 #include <time.h>
00155 #else
00156 #ifdef HAVE_SYS_TIME_H
00157 #include <sys/time.h>
00158 #else
00159 #include <time.h>
00160 #endif
00161 #endif
00162 #ifdef HAVE_SYS_SELECT_H
00163 #include <sys/select.h>
00164 #endif
00165 #ifdef HAVE_SYS_IPC_H
00166 #include <sys/ipc.h>
00167 #endif
00168 #ifdef HAVE_SYS_SHM_H
00169 #include <sys/shm.h>
00170 #endif
00171 #ifdef HAVE_SYS_MMAN_H
00172 #include <sys/mman.h>
00173 #endif
00174 #ifdef HAVE_SYS_SYSCTL_H
00175 #include <sys/sysctl.h>
00176 #endif
00177 #ifdef HAVE_SYS_PSTAT_H
00178 #include <sys/pstat.h>
00179 #endif
00180 #if defined(__APPLE__)
00181 #include <libkern/OSAtomic.h>
00182 #endif
00183 #include <pthread.h>
00184 #ifdef HAVE_SEMAPHORE_H
00185 #include <semaphore.h>
00186 #endif
00187 #if defined(HAVE_PTHREAD_SETAFFINITY_NP)
00188 #if defined(__FreeBSD__)
00189 #include <osreldate.h>
00190 #if __FreeBSD_version >= 702000
00191 #include <pthread_np.h>
00192 #include <sys/cpuset.h>
00193 typedef cpuset_t cpu_set_t;
00194 #endif
00195 #endif
00196 #endif
00197 #if defined(__minix) // MINIX
00198 #ifdef sleep
00199 #undef sleep // We mean sleep not __pthread_sleep
00200 #endif
00201 #ifdef read
00202 #undef read // We mean read not __pthread_read
00203 #endif
00204 #ifdef write
00205 #undef write // We mean write not __pthread_write
00206 #endif
00207 #ifdef select
00208 #undef select // We mean select not __pthread_select
00209 #endif
00210 #endif
00211
00212
00213 #ifdef HAVE_SHL_LOAD
00214 #include <dl.h>
00215 #ifndef DYNAMIC_PATH
00216 #define DYNAMIC_PATH 0
00217 #endif
00218 #ifndef BIND_RESTRICTED
00219 #define BIND_RESTRICTED 0
00220 #endif
00221 #else
00222 #ifdef HAVE_DLFCN_H
00223 #include <dlfcn.h>
00224 #endif
00225 #endif
00226 #ifndef RTLD_GLOBAL
00227 #define RTLD_GLOBAL 0 // Does not exist on DEC
00228 #endif
00229 #ifndef RTLD_NOLOAD // Older GLIBC libraries
00230 #define RTLD_NOLOAD 0
00231 #endif
00232 #ifndef RTLD_NOW // for OpenBSD
00233 #define RTLD_NOW DL_LAZY
00234 #endif
00235
00236
00237 #if (defined(__GNUC__) || defined(__INTEL_COMPILER))
00238 #if (defined(__SSE__) && defined(HAVE_XMMINTRIN_H))
00239 #include <xmmintrin.h>
00240 #define FOX_HAS_SSE // FOX_HAS_SSE: SSE code generated AND Intrinsics supported
00241 #endif
00242 #if (defined(__SSE2__) && defined(HAVE_EMMINTRIN_H))
00243 #include <emmintrin.h>
00244 #define FOX_HAS_SSE2 // FOX_HAS_SSE2: SSE2 code generated AND Intrinsics supported
00245 #endif
00246 #if (defined(__SSE3__) && defined(HAVE_PMMINTRIN_H))
00247 #include <pmmintrin.h>
00248 #define FOX_HAS_SSE3 // FOX_HAS_SSE3: SSE3 code generated AND Intrinsics supported
00249 #endif
00250 #endif
00251
00252
00253 #include <X11/X.h>
00254 #include <X11/Xlib.h>
00255 #include <X11/Xcms.h>
00256 #include <X11/Xutil.h>
00257 #include <X11/Xresource.h>
00258 #include <X11/Xatom.h>
00259 #include <X11/cursorfont.h>
00260 #ifdef HAVE_XSHM_H
00261 #include <X11/extensions/XShm.h>
00262 #endif
00263 #ifdef HAVE_XCURSOR_H
00264 #include <X11/Xcursor/Xcursor.h>
00265 #endif
00266 #ifdef HAVE_XFT_H
00267 #include <X11/Xft/Xft.h>
00268 #endif
00269 #ifdef HAVE_XSHAPE_H
00270 #include <X11/extensions/shape.h>
00271 #endif
00272 #ifdef HAVE_XRANDR_H
00273 #include <X11/extensions/Xrandr.h>
00274 #endif
00275 #ifdef HAVE_XFIXES_H
00276 #include <X11/extensions/Xfixes.h>
00277 #endif
00278 #ifdef HAVE_XRENDER_H
00279 #include <X11/extensions/Xrender.h>
00280 #endif
00281 #ifdef HAVE_XINPUT2_H
00282 #include <X11/extensions/XInput2.h>
00283 #endif
00284 #ifndef NO_XIM
00285 #ifndef XlibSpecificationRelease // Not defined until X11R5
00286 #define NO_XIM
00287 #elif XlibSpecificationRelease < 6 // Need at least Xlib X11R6
00288 #define NO_XIM
00289 #endif
00290 #endif
00291
00292
00293 #ifdef HAVE_GL_H
00294 #ifndef SUN_OGL_NO_VERTEX_MACROS
00295 #define SUN_OGL_NO_VERTEX_MACROS
00296 #endif
00297 #ifndef HPOGL_SUPPRESS_FAST_API
00298 #define HPOGL_SUPPRESS_FAST_API
00299 #endif
00300 #include <GL/gl.h>
00301 #ifdef HAVE_GLX_H
00302 #include <GL/glx.h>
00303 #endif
00304 #endif
00305 #ifdef HAVE_GLU_H
00306 #include <GL/glu.h>
00307 #endif
00308
00309 #endif //////////////////////////////////////////////////////////////////////////
00310
00311
00312 #ifndef MAXPATHLEN
00313 #if defined(PATH_MAX)
00314 #define MAXPATHLEN PATH_MAX
00315 #elif defined(_MAX_PATH)
00316 #define MAXPATHLEN _MAX_PATH
00317 #elif defined(MAX_PATH)
00318 #define MAXPATHLEN MAX_PATH
00319 #else
00320 #define MAXPATHLEN 2048
00321 #endif
00322 #endif
00323
00324
00325 #ifndef MAXHOSTNAMELEN
00326 #define MAXHOSTNAMELEN 256
00327 #endif
00328
00329
00330 #ifndef SEEK_SET
00331 #define SEEK_SET 0
00332 #endif
00333 #ifndef SEEK_CUR
00334 #define SEEK_CUR 1
00335 #endif
00336 #ifndef SEEK_END
00337 #define SEEK_END 2
00338 #endif
00339
00340
00341 #ifdef VOID
00342 #undef VOID
00343 #endif
00344
00345 #endif