X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=src%2Fbase%2Fcl_macros.h;h=29787c0507ee71b431cdd0ed49d25ff5379ee628;hb=795eaad1187ec695cfbff001c89091c1da453334;hp=d4a19593ed15d8269374eca3f0bfb9b0f988ffe4;hpb=dd9e0f894eec7e2a8cf85078330ddc0a6639090b;p=cln.git diff --git a/src/base/cl_macros.h b/src/base/cl_macros.h index d4a1959..29787c0 100644 --- a/src/base/cl_macros.h +++ b/src/base/cl_macros.h @@ -3,6 +3,8 @@ #ifndef _CL_MACROS_H #define _CL_MACROS_H +#include "cln/types.h" + // Concatenation of macroexpanded tokens. // Example: // #undef x @@ -29,7 +31,7 @@ // Declare functions that don't return. // nonreturning_function(extern,exit,(void)); == extern void exit (void); #ifdef __GNUC__ - #if (__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 90)) + #if (__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 9)) #define nonreturning_function(storclass,funname,arguments) \ storclass void funname arguments __attribute__((__noreturn__)) #else @@ -72,7 +74,9 @@ // Denotes a point where control flow can never arrive. // NOTREACHED #define NOTREACHED cl_notreached_abort(__FILE__,__LINE__); +namespace cln { nonreturning_function(extern,cl_notreached_abort, (const char* filename, int lineno)); +} // namespace cln // Check an arithmetic expression. // ASSERT(expr) @@ -106,10 +110,18 @@ #undef NULL #define NULL 0 -// Bit number n (0<=n<32) - #define bit(n) (1L<<(n)) +// Bit number n (0<=n<32 or 0<=n<64) + #ifdef HAVE_FAST_LONGLONG + #define bit(n) (1LL<<(n)) + #else + #define bit(n) (1L<<(n)) + #endif // Bit number n (0=long_bitsize. - #define bitc(n) (1UL << (((n) >= 0 && (n) < long_bitsize) ? (n) : 0)) +// Same as bit(n), but undefined if n<0 or n>={long_}long_bitsize. + #ifdef HAVE_FAST_LONGLONG + #define bitc(n) (1ULL << (((n) >= 0 && (n) < long_long_bitsize) ? (n) : 0)) + #else + #define bitc(n) (1UL << (((n) >= 0 && (n) < long_bitsize) ? (n) : 0)) + #endif // floor(a,b) for a>=0, b>0 returns floor(a/b). // b should be a constant expression. #define floor(a_from_floor,b_from_floor) ((a_from_floor) / (b_from_floor)) -// Save the macro in case we need to include . +// Save the macro in case we need to include . #define cln_floor(a_from_floor,b_from_floor) ((a_from_floor) / (b_from_floor)) // ceiling(a,b) for a>=0, b>0 returns ceiling(a/b) = floor((a+b-1)/b). @@ -224,17 +248,17 @@ #define ALLOCATE_ANYWHERE(classname) \ /* Ability to place an object at a given address. */ \ public: \ - void* operator new (size_t size) { return cl_malloc_hook(size); } \ + void* operator new (size_t size) { return malloc_hook(size); } \ void* operator new (size_t size, classname* ptr) { unused size; return ptr; } \ - void operator delete (void* ptr) { cl_free_hook(ptr); } + void operator delete (void* ptr) { free_hook(ptr); } #else // For some compilers, work around template problem with "classname". #define ALLOCATE_ANYWHERE(classname) \ /* Ability to place an object at a given address. */ \ public: \ - void* operator new (size_t size) { return cl_malloc_hook(size); } \ + void* operator new (size_t size) { return malloc_hook(size); } \ void* operator new (size_t size, void* ptr) { unused size; return ptr; } \ - void operator delete (void* ptr) { cl_free_hook(ptr); } + void operator delete (void* ptr) { free_hook(ptr); } #endif // init1(type, object) (value);