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