ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/svsconfig.h
Revision: 1.3
Committed: Wed Aug 29 21:01:18 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +33 -29 lines
Log Message:
- reduced ifdefs by moving __GNUC__ and friends to svsconfig.h
- #define to enum { } in tools.h
- corrected log levels a bit
- made timersub an inline function instead of a macro
- added a simple garbage collection mechanism for postponed freeing of lost
  memory chunks
- enhanced type_traits
- merged inspircd1.2 support with upstream
- reformatting
- renamed TTP to a more "standard" PRItime and STP to PRIsize

File Contents

# Content
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: svsconfig.h,v 1.2 2007-08-28 17:08: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 #define CALLBACK_DEBUG 0
21
22 /* End configuration */
23
24 #define E extern
25
26 /* GNU extensions */
27 #if __GNUC__ >= 3
28 # define expect(expr, value) __builtin_expect ((expr), (value))
29 # define is_const(expr) __builtin_constant_p ((expr))
30 #else
31 # define expect(expr, value) (expr)
32 # define is_const(expr) 0
33 #endif
34
35 #define expect_false(expr) expect ((expr) != 0, 0)
36 #define expect_true(expr) expect ((expr) != 0, 1)
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 */
58 #if SIZEOF_TIME_T == SIZEOF_LONG
59 #define PRItime "ld"
60 #elif SIZEOF_TIME_T == SIZEOF_INT
61 #define PRItime "d"
62 #else
63 #error Size of time_t not known
64 #endif
65
66 #if SIZEOF_SIZE_T == SIZEOF_LONG
67 #define PRIsize "lu"
68 #elif SIZEOF_SIZE_T == SIZEOF_INT
69 #define PRIsize "u"
70 #else
71 #error Size of size_t not known
72 #endif
73
74 /**
75 * Debug stuff...
76 */
77
78 #include <iostream> // even needed when DEBUG is 0
79
80 #if DEBUG
81 # define dbg std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": "
82 #else
83 # define dbg if (0) std::cerr
84 #endif
85
86 #if CALLBACK_DEBUG
87 # define dout std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": "
88 #else
89 # define dout if (0) std::cerr
90 #endif
91
92 #endif // CONFIG_H