1 /* 2 * ============================================================================ 3 * Title: Project-Wide Config 4 * Author: J. Zbiciak 5 * $Id: config.h,v 1.14 2001/11/02 02:00:02 im14u2c Exp $ 6 * ============================================================================ 7 * _BIG_ENDIAN -- Host machine is big endian 8 * _LITTLE_ENDIAN -- Host machine is little endian 9 * ============================================================================ 10 * 11 * ============================================================================ 12 */ 13 14 #ifndef _CONFIG_H 15 #define _CONFIG_H 16 17 18 /* 19 * ============================================================================ 20 * If you get an error here, define BYTE_BE or BYTE_LE as is required for 21 * your host machine! You can do that in your Makefile by adding it to 22 * CFLAGS, or by uncommenting the appropriate #define below. 23 * ============================================================================ 24 */ 25 26 /* #define BYTE_BE */ /* Uncomment for big endian */ 27 /* #define BYTE_LE */ /* Uncomment for little endian */ 28 29 #if !defined(BYTE_BE) && !defined(BYTE_LE) 30 31 # if defined(__BIG_ENDIAN__) 32 # define BYTE_BE 33 # endif 34 35 # if defined(__LITTLE_ENDIAN__) 36 # define BYTE_LE 37 # endif 38 39 # if !(defined(BYTE_BE) || defined(BYTE_LE)) && \ 40 (defined(sparc) || defined(__sparc) || defined(__sparc__) || \ 41 defined(sparc64) || defined(__sparc64) || defined(__sparc64__) || \ 42 defined(ppc) || defined(__ppc) || defined(__ppc__) || \ 43 defined(ppc64) || defined(__ppc64) || defined(__ppc64__) || \ 44 defined(POWERPC) || defined(__POWERPC) || defined(__POWERPC__)) 45 # define BYTE_BE 46 # endif 47 48 # if !(defined(BYTE_BE) || defined(BYTE_LE)) && \ 49 (defined(i386) || defined(__i386) || defined(__i386__) || \ 50 defined(x86_64) || defined(__x86_64) || defined(__x86_64__) || \ 51 defined(amd64) || defined(__amd64) || defined(__amd64__) || \ 52 defined(ia64) || defined(__ia64) || defined(__ia64__) || \ 53 defined(alpha) || defined(__alpha) || defined(__alpha__)) 54 # define BYTE_LE 55 # endif 56 57 # if !defined(BYTE_BE) && !defined(BYTE_LE) 58 # include <endian.h> 59 # ifndef __BYTE_ORDER 60 # error Please manually set your machine endian in 'config.h' 61 # endif 62 # if __BYTE_ORDER==4321 63 # define BYTE_BE 64 # endif 65 # if __BYTE_ORDER==1234 66 # define BYTE_LE 67 # endif 68 # if !defined(BYTE_BE) && !defined(BYTE_LE) 69 # error Cannot determine target endian. See 'config.h' for details. 70 # endif 71 # endif 72 73 #endif 74 75 #if defined(BYTE_BE) && defined(BYTE_LE) 76 # error Both BYTE_BE and BYTE_LE defined. Pick only 1! 77 #endif 78 79 #if !defined(BYTE_BE) && !defined(BYTE_LE) 80 # error One of BYTE_BE or BYTE_LE must be defined. 81 #endif 82 83 /* --------------------------------------------------------------------- */ 84 /* BFE -- Builds a `B'it`F'ield structure in the correct order */ 85 /* as required for the host machine's `E'ndian. */ 86 /* --------------------------------------------------------------------- */ 87 88 #ifdef BYTE_BE 89 # define BFE(x,y) y; x 90 #else /* BYTE_LE */ 91 # define BFE(x,y) x; y 92 #endif 93 94 95 /* 96 * ============================================================================ 97 * If we're using GCC/EGCS, suppress some silly compiler warnings. 98 * ============================================================================ 99 */ 100 101 #ifdef __GNUC__ 102 # define UNUSED __attribute__ ((unused)) 103 # define GNU_RESTRICT 104 #else 105 # define UNUSED 106 #endif 107 108 /* 109 * ============================================================================ 110 * If our compiler supports 'inline', enable it here. 111 * ============================================================================ 112 */ 113 #if defined(GNUC) || defined(_TMS320C6X) 114 # define INLINE inline 115 #else 116 # define INLINE 117 #endif 118 119 /* 120 * ============================================================================ 121 * Target-specific types, according to size. 122 * ============================================================================ 123 */ 124 #ifdef _TMS320C6X 125 typedef unsigned char uint_8; 126 typedef unsigned short uint_16; 127 typedef unsigned int uint_32; 128 typedef unsigned long uint_64; /* Note: Really only 40 bits. */ 129 130 typedef signed char sint_8; 131 typedef signed short sint_16; 132 typedef signed int sint_32; 133 typedef signed long sint_64; /* Note: Really only 40 bits. */ 134 #else 135 typedef unsigned char uint_8; 136 typedef unsigned short uint_16; 137 typedef unsigned int uint_32; 138 typedef unsigned long long uint_64; 139 140 typedef signed char sint_8; 141 typedef signed short sint_16; 142 typedef signed int sint_32; 143 typedef signed long long sint_64; 144 #endif 145 146 typedef volatile uint_8 v_uint_8; 147 typedef volatile uint_16 v_uint_16; 148 typedef volatile uint_32 v_uint_32; 149 typedef volatile uint_64 v_uint_64; 150 151 typedef volatile sint_8 v_sint_8; 152 typedef volatile sint_16 v_sint_16; 153 typedef volatile sint_32 v_sint_32; 154 typedef volatile sint_64 v_sint_64; 155 156 157 /* 158 * ============================================================================ 159 * Target-specific library compatibility issues 160 * ============================================================================ 161 */ 162 163 #if defined (__APPLE__) && defined(__MACH__) && !defined(macosx) 164 # define macosx 165 #endif 166 167 #ifdef linux 168 # define USE_STRCASECMP 169 # define DEFAULT_ROM_PATH ".:=../rom:/usr/local/share/jzintv/rom" 170 # define HAS_LINK 171 #endif 172 173 #ifdef SOLARIS 174 /*# define NO_SNPRINTF*/ 175 # define NO_GETOPT_LONG 176 # define NO_INOUT 177 # define USE_STRCASECMP 178 # define DEFAULT_ROM_PATH ".:=../rom:/usr/local/share/jzintv/rom" 179 # define HAS_LINK 180 #endif 181 182 #ifdef WIN32 183 # define NO_GETTIMEOFDAY 184 /*# define NO_SNPRINTF*/ 185 # define NO_GETOPT_LONG 186 # define NOGETOPT 187 # define NO_SETUID 188 # define NO_NANOSLEEP 189 # define NO_RAND48 190 # define NO_FCNTL 191 # define USE_MKTEMP 192 # define NEED_INOUT 193 # define DEFAULT_ROM_PATH ".;=..\\rom" 194 # define PATH_SEP '\\' 195 # define PATH_COMPONENT_SEP ";" 196 #endif 197 198 #ifdef macintosh 199 # define NO_GETTIMEOFDAY 200 # define NO_STRDUP 201 # define NO_SYS_TIME_H 202 # define NO_SDL_DELAY 203 # define NO_SETUID 204 # define NO_NANOSLEEP 205 # define NO_RAND48 206 # define NO_INOUT 207 # define NO_STRICMP /* ? */ 208 # define NO_FCNTL 209 # define DEFAULT_ROM_PATH "." 210 # define PATH_SEP ':' 211 # define PATH_COMPONENT_SEP ";" 212 #endif 213 214 #ifdef macosx 215 # define NO_RAND48 216 # define NO_INOUT 217 # define NO_GETOPT_LONG 218 # define NOGETOPT 219 # define USE_STRCASECMP /* ? */ 220 # define DEFAULT_ROM_PATH ".:=../rom" 221 # define HAS_LINK 222 #endif 223 224 #ifdef __FreeBSD__ 225 # define NO_INOUT 226 # define USE_STRCASECMP 227 # define DEFAULT_ROM_PATH ".:=../rom:/usr/local/share/jzintv/rom" 228 # define HAS_LINK 229 #endif 230 231 #ifdef _TMS320C6X 232 # define NO_GETTIMEOFDAY 233 # define NO_STRDUP 234 # define NO_SYS_TIME_H 235 # define NO_UNISTD_H 236 # define NO_GETOPT_LONG 237 # define NO_SETUID 238 # define NO_NANOSLEEP 239 # define NO_RAND48 240 # define NO_INOUT 241 # define NO_STRICMP 242 # define HAVE_RESTRICT 243 # define NO_FCNTL 244 # ifndef CLK_TCK 245 # define CLK_TCK 200000000 /* Assume 200MHz C6201 device */ 246 # endif 247 # define DEFAULT_ROM_PATH "." 248 # define FULLSC_START_DLY (0) 249 #endif 250 251 #ifdef GP2X 252 # define FULLSC_START_DLY (0) 253 #endif 254 255 256 /* 257 * ============================================================================ 258 * Clean up per-arch configs w/ some defaults. 259 * ============================================================================ 260 */ 261 262 #ifndef PATH_SEP 263 # define PATH_SEP '/' 264 #endif 265 266 #ifndef PATH_COMPONENT_SEP 267 # define PATH_COMPONENT_SEP ":" 268 #endif 269 270 #ifndef DEFAULT_ROM_PATH 271 # define DEFAULT_ROM_PATH NULL 272 #endif 273 274 #ifndef FULLSC_START_DLY 275 # define FULLSC_START_DLY (500) 276 #endif 277 278 /* 279 * ============================================================================ 280 * CGC support configuration 281 * ============================================================================ 282 */ 283 284 #if defined(WIN32) 285 #define CGC_SUPPORTED 286 #define CGC_DLL 287 #endif 288 289 #if defined(linux) 290 #define CGC_SUPPORTED 291 #define CGC_THREAD 292 #endif 293 294 /* 295 * ============================================================================ 296 * Standard #includes that almost everyone needs 297 * ============================================================================ 298 */ 299 300 #include <stdio.h> 301 #include <stdlib.h> 302 #include <string.h> 303 #include <time.h> 304 #include <ctype.h> 305 #include <assert.h> 306 #include <limits.h> 307 #include <errno.h> 308 #include <math.h> 309 310 #ifndef NO_SYS_TIME_H 311 # include <sys/time.h> 312 #endif 313 314 #ifndef NO_UNISTD_H 315 # include <unistd.h> 316 #endif 317 318 #ifdef _TMS320C6X /* This seems to be TI-specific. */ 319 # include <file.h> 320 #endif 321 322 #ifdef linux 323 # include <sys/io.h> 324 #endif 325 326 327 #ifdef USE_STRCASECMP 328 # define stricmp strcasecmp 329 #endif 330 331 #ifndef NO_FCNTL 332 # include <fcntl.h> 333 #endif 334 335 #ifndef M_PI 336 # ifdef PI 337 # define M_PI PI 338 # else 339 # define M_PI (3.14159265358979323846) 340 # endif 341 #endif 342 343 344 /* 345 * ============================================================================ 346 * If this compiler implements the C99 'restrict' keyword, then enable it. 347 * ============================================================================ 348 */ 349 #ifdef HAVE_RESTRICT 350 # define RESTRICT restrict 351 #endif 352 353 #ifdef GNU_RESTRICT 354 # define RESTRICT __restrict__ 355 #endif 356 357 #ifndef RESTRICT 358 # define RESTRICT 359 #endif 360 361 /* 362 * ============================================================================ 363 * Allow exposing "local" symbols by using LOCAL instead of static 364 * ============================================================================ 365 */ 366 #ifndef LOCAL 367 # define LOCAL static 368 #endif 369 370 /* 371 * ============================================================================ 372 * Include the "platform library" to handle missing functions 373 * ============================================================================ 374 */ 375 376 377 378 /* 379 * ============================================================================ 380 * Version number 381 * ============================================================================ 382 */ 383 384 #ifndef JZINTV_VERSION_MAJOR 385 # define JZINTV_VERSION_MAJOR (0) 386 #endif 387 388 #ifndef JZINTV_VERSION_MINOR 389 # define JZINTV_VERSION_MINOR (0) 390 #endif 391 392 #define JZINTV_VERSION ((JZINTV_VERSION_MAJOR << 8) | JZINTV_VERSION_MINOR) 393 394 #endif /* CONFIG_H */ 395 396 /* ======================================================================== */ 397 /* This program is free software; you can redistribute it and/or modify */ 398 /* it under the terms of the GNU General Public License as published by */ 399 /* the Free Software Foundation; either version 2 of the License, or */ 400 /* (at your option) any later version. */ 401 /* */ 402 /* This program is distributed in the hope that it will be useful, */ 403 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 404 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 405 /* General Public License for more details. */ 406 /* */ 407 /* You should have received a copy of the GNU General Public License */ 408 /* along with this program; if not, write to the Free Software */ 409 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 410 /* ======================================================================== */ 411 /* Copyright (c) 1998-2006, Joseph Zbiciak */ 412 /* ======================================================================== */ 413