| 1 |
/** |
| 2 |
* svsconfig.h: Compile-time configuration and some sysconf #defines. dbg, the ermyth debug output, also lives in this file. |
| 3 |
* |
| 4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
| 5 |
* Rights to this code are as documented in COPYING. |
| 6 |
* |
| 7 |
* $Id: svsconfig.h,v 1.4 2007-09-05 11:23:13 pippijn Exp $ |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef CONFIG_H |
| 11 |
#define CONFIG_H |
| 12 |
|
| 13 |
#include <sysconf.h> |
| 14 |
|
| 15 |
/* Compile-time configuration */ |
| 16 |
|
| 17 |
#define PURE_ISO 1 |
| 18 |
#define DEBUG 1 |
| 19 |
#define CALLBACK_DEBUG 0 |
| 20 |
|
| 21 |
/* End configuration */ |
| 22 |
|
| 23 |
#define E extern |
| 24 |
|
| 25 |
/* GNU extensions */ |
| 26 |
#if __GNUC__ >= 3 |
| 27 |
# define expect(expr, value) __builtin_expect ((expr), (value)) |
| 28 |
# define is_const(expr) __builtin_constant_p ((expr)) |
| 29 |
#else |
| 30 |
# define expect(expr, value) (expr) |
| 31 |
# define is_const(expr) 0 |
| 32 |
#endif |
| 33 |
|
| 34 |
#define expect_false(expr) expect ((expr) != 0, 0) |
| 35 |
#define expect_true(expr) expect ((expr) != 0, 1) |
| 36 |
|
| 37 |
/* Get current function if available */ |
| 38 |
#ifdef __GNUC__ |
| 39 |
# define CURFUNC __PRETTY_FUNCTION__ |
| 40 |
#elif defined(__BORLANDC__) |
| 41 |
# define CURFUNC __FUNC__ |
| 42 |
#elif defined(_MSC_VER) |
| 43 |
# if _MSC_VER >= 1300 |
| 44 |
# define CURFUNC __FUNCDNAME__ |
| 45 |
# else |
| 46 |
# define CURFUNC __FUNCTION__ |
| 47 |
# endif |
| 48 |
#else |
| 49 |
# ifdef __FUNCTION__ |
| 50 |
# define CURFUNC __FUNCTION__ |
| 51 |
# else |
| 52 |
# define CURFUNC "<unknown function>" |
| 53 |
# endif |
| 54 |
#endif |
| 55 |
|
| 56 |
/* printf formats */ |
| 57 |
#if SIZEOF_TIME_T == SIZEOF_LONG |
| 58 |
#define PRItime "ld" |
| 59 |
#elif SIZEOF_TIME_T == SIZEOF_INT |
| 60 |
#define PRItime "d" |
| 61 |
#else |
| 62 |
#error Size of time_t not known |
| 63 |
#endif |
| 64 |
|
| 65 |
#if SIZEOF_SIZE_T == SIZEOF_LONG |
| 66 |
#define PRIsize "lu" |
| 67 |
#elif SIZEOF_SIZE_T == SIZEOF_INT |
| 68 |
#define PRIsize "u" |
| 69 |
#else |
| 70 |
#error Size of size_t not known |
| 71 |
#endif |
| 72 |
|
| 73 |
/** |
| 74 |
* Debug stuff... |
| 75 |
*/ |
| 76 |
|
| 77 |
#include <iostream> // even needed when DEBUG is 0 |
| 78 |
|
| 79 |
#if DEBUG |
| 80 |
# define dbg std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": " |
| 81 |
#else |
| 82 |
# define dbg if (0) std::cerr |
| 83 |
#endif |
| 84 |
|
| 85 |
#if CALLBACK_DEBUG |
| 86 |
# define dout std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": " |
| 87 |
#else |
| 88 |
# define dout if (0) std::cerr |
| 89 |
#endif |
| 90 |
|
| 91 |
#endif // CONFIG_H |