ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/svsconfig.h
Revision: 1.5
Committed: Sun Sep 16 18:54:42 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +5 -6 lines
Log Message:
#defines to enum

File Contents

# User Rev Content
1 pippijn 1.5 /**
2     * svsconfig.h: Compile-time configuration and some sysconf #defines. dbg, the ermyth debug output, also lives in this file.
3     *
4 pippijn 1.2 * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5 pippijn 1.5 * Rights to this code are as documented in COPYING.
6 pippijn 1.2 *
7 pippijn 1.5 * $Id: svsconfig.h,v 1.4 2007-09-05 11:23:13 pippijn Exp $
8 pippijn 1.2 */
9    
10 pippijn 1.1 #ifndef CONFIG_H
11     #define CONFIG_H
12    
13 pippijn 1.2 #include <sysconf.h>
14    
15 pippijn 1.1 /* Compile-time configuration */
16    
17     #define PURE_ISO 1
18     #define DEBUG 1
19 pippijn 1.3 #define CALLBACK_DEBUG 0
20 pippijn 1.1
21     /* End configuration */
22    
23     #define E extern
24    
25 pippijn 1.3 /* GNU extensions */
26 pippijn 1.1 #if __GNUC__ >= 3
27 pippijn 1.3 # define expect(expr, value) __builtin_expect ((expr), (value))
28 pippijn 1.1 # define is_const(expr) __builtin_constant_p ((expr))
29     #else
30 pippijn 1.3 # define expect(expr, value) (expr)
31 pippijn 1.1 # 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 pippijn 1.3 /* 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 pippijn 1.1 #if SIZEOF_TIME_T == SIZEOF_LONG
58 pippijn 1.3 #define PRItime "ld"
59 pippijn 1.1 #elif SIZEOF_TIME_T == SIZEOF_INT
60 pippijn 1.3 #define PRItime "d"
61 pippijn 1.1 #else
62     #error Size of time_t not known
63     #endif
64    
65 pippijn 1.3 #if SIZEOF_SIZE_T == SIZEOF_LONG
66     #define PRIsize "lu"
67     #elif SIZEOF_SIZE_T == SIZEOF_INT
68     #define PRIsize "u"
69 pippijn 1.1 #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 pippijn 1.3 # define dbg std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": "
81 pippijn 1.1 #else
82     # define dbg if (0) std::cerr
83     #endif
84    
85     #if CALLBACK_DEBUG
86 pippijn 1.3 # define dout std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": "
87 pippijn 1.1 #else
88     # define dout if (0) std::cerr
89     #endif
90    
91     #endif // CONFIG_H