/** * svsconfig.h: Compile-time configuration and some sysconf #defines. dbg, the ermyth debug output, also lives in this file. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * $Id: svsconfig.h,v 1.5 2007/09/16 18:54:42 pippijn Exp $ */ #ifndef CONFIG_H #define CONFIG_H #include /* Compile-time configuration */ #define PURE_ISO 1 #define DEBUG 1 #define CALLBACK_DEBUG 0 /* End configuration */ #define E extern /* GNU extensions */ #if __GNUC__ >= 3 # define expect(expr, value) __builtin_expect ((expr), (value)) # define is_const(expr) __builtin_constant_p ((expr)) #else # define expect(expr, value) (expr) # define is_const(expr) 0 #endif #define expect_false(expr) expect ((expr) != 0, 0) #define expect_true(expr) expect ((expr) != 0, 1) /* Get current function if available */ #ifdef __GNUC__ # define CURFUNC __PRETTY_FUNCTION__ #elif defined(__BORLANDC__) # define CURFUNC __FUNC__ #elif defined(_MSC_VER) # if _MSC_VER >= 1300 # define CURFUNC __FUNCDNAME__ # else # define CURFUNC __FUNCTION__ # endif #else # ifdef __FUNCTION__ # define CURFUNC __FUNCTION__ # else # define CURFUNC "" # endif #endif /* printf formats */ #if SIZEOF_TIME_T == SIZEOF_LONG #define PRItime "ld" #elif SIZEOF_TIME_T == SIZEOF_INT #define PRItime "d" #else #error Size of time_t not known #endif #if SIZEOF_SIZE_T == SIZEOF_LONG #define PRIsize "lu" #elif SIZEOF_SIZE_T == SIZEOF_INT #define PRIsize "u" #else #error Size of size_t not known #endif /** * Debug stuff... */ #include // even needed when DEBUG is 0 #if DEBUG # define dbg std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": " #else # define dbg if (0) std::cerr #endif #if CALLBACK_DEBUG # define dout std::cerr << CURFUNC << ": " << std::dec << "#" << __LINE__ << ": " #else # define dout if (0) std::cerr #endif #endif // CONFIG_H