1 |
/* |
2 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
3 |
* Rights to this code are documented in doc/pod/gplicense.pod. |
4 |
* |
5 |
* Compile-time configuration and some sysconf #defines. |
6 |
* dbg, the ermyth debug output, also lives in this file. |
7 |
* |
8 |
* $Id: stdinc.h,v 1.2 2007-07-21 01:29:07 pippijn Exp $ |
9 |
*/ |
10 |
|
11 |
#ifndef CONFIG_H |
12 |
#define CONFIG_H |
13 |
|
14 |
#include <sysconf.h> |
15 |
|
16 |
/* Compile-time configuration */ |
17 |
|
18 |
#define PURE_ISO 1 |
19 |
#define DEBUG 1 |
20 |
|
21 |
/* End configuration */ |
22 |
|
23 |
#define E extern |
24 |
|
25 |
#if __GNUC__ >= 3 |
26 |
# define expect(expr,value) __builtin_expect ((expr),(value)) |
27 |
# define is_const(expr) __builtin_constant_p ((expr)) |
28 |
#else |
29 |
# define expect(expr,value) (expr) |
30 |
# define is_const(expr) 0 |
31 |
#endif |
32 |
|
33 |
#define expect_false(expr) expect ((expr) != 0, 0) |
34 |
#define expect_true(expr) expect ((expr) != 0, 1) |
35 |
|
36 |
#if SIZEOF_TIME_T == SIZEOF_LONG |
37 |
#define TTP "%ld" |
38 |
#elif SIZEOF_TIME_T == SIZEOF_INT |
39 |
#define TTP "%d" |
40 |
#else |
41 |
#error Size of time_t not known |
42 |
#endif |
43 |
|
44 |
#if SIZEOF_SIZE_T == SIZEOF_INT |
45 |
#define STP "%u" |
46 |
#elif SIZEOF_SIZE_T == SIZEOF_LONG |
47 |
#define STP "%lu" |
48 |
#else |
49 |
#error Size of size_t not known |
50 |
#endif |
51 |
|
52 |
/** |
53 |
* Debug stuff... |
54 |
*/ |
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 |
|
66 |
#include <iostream> // even needed when DEBUG is 0 |
67 |
|
68 |
#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__ << ": " |
73 |
#endif |
74 |
#else |
75 |
# define dbg if (0) std::cerr |
76 |
#endif |
77 |
|
78 |
#if CALLBACK_DEBUG |
79 |
# ifdef __GNUC__ |
80 |
# define dout std::cerr << __PRETTY_FUNCTION__ << ": " << std::dec << "#" << __LINE__ << ": " |
81 |
# else |
82 |
# define dout std::cerr << __LINE__ << ": " << std::dec << "#" << __LINE__ << ": " |
83 |
# endif |
84 |
#else |
85 |
# define dout if (0) std::cerr |
86 |
#endif |
87 |
|
88 |
#endif // CONFIG_H |