]> www.ginac.de Git - cln.git/blobdiff - src/base/cl_macros.h
[build] Move CLN version info into the include/cln/version.h file...
[cln.git] / src / base / cl_macros.h
index ec4999522c04b658175df14117f3f76e0ccddc37..4b4ba0dcf2540545ad0bbce0256b7b688770d9bb 100644 (file)
@@ -4,6 +4,7 @@
 #define _CL_MACROS_H
 
 #include "cln/types.h"
+#include "cln/exception.h"
 
 // Concatenation of macroexpanded tokens.
 // Example:
   #define TRUE   1
 
 // Ignore a value (instead of assigning it to a variable).
-// unused ...
+// cl_unused ...
   #if defined(__GNUC__) || defined(__KCC) // avoid a gcc warning "statement with no effect"
-    #define unused  (void)
+    #define cl_unused  (void)
   #else
-    #define unused
+    #define cl_unused
   #endif
 
 // 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
+  #define NOTREACHED  throw notreached_exception(__FILE__,__LINE__);
 
 // Check an arithmetic expression.
 // ASSERT(expr)
@@ -112,15 +110,15 @@ namespace cln {
 
 // Bit number n (0<=n<32 or 0<=n<64)
   #ifdef HAVE_FAST_LONGLONG
-    #define bit(n)  (1LL<<(n))
+    #define bit(n)  (long long)(1ULL<<(n))
   #else
-    #define bit(n)  (1L<<(n))
+    #define bit(n)  (long)(1UL<<(n))
   #endif
 // Bit number n (0<n<=32) mod 2^32
   #ifdef HAVE_FAST_LONGLONG
-    #define bitm(n)  (2LL<<((n)-1))
+    #define bitm(n)  (long long)(2ULL<<((n)-1))
   #else
-    #define bitm(n)  (2L<<((n)-1))
+    #define bitm(n)  (long)(2UL<<((n)-1))
   #endif
 // Test bit n in x, n constant, x a cl_uint:
   #if !(defined(__sparc__) || defined(__sparc64__))
@@ -139,15 +137,15 @@ namespace cln {
   #endif
 // minus bit number n (0<=n<32 or 0<=n<64)
   #ifdef HAVE_FAST_LONGLONG
-    #define minus_bit(n)  (-1LL<<(n))
+    #define minus_bit(n)  (long long)(-1ULL<<(n))
   #else
-    #define minus_bit(n)  (-1L<<(n))
+    #define minus_bit(n)  (long)(-1UL<<(n))
   #endif
 // minus bit number n (0<n<=32) mod 2^32
   #ifdef HAVE_FAST_LONGLONG
-    #define minus_bitm(n)  (-2LL<<((n)-1))
+    #define minus_bitm(n)  (long long)(-2ULL<<((n)-1))
   #else
-    #define minus_bitm(n)  (-2L<<((n)-1))
+    #define minus_bitm(n)  (long)(-2UL<<((n)-1))
   #endif
 
 // Return 2^n, n a constant expression.
@@ -196,7 +194,7 @@ namespace cln {
     }
 
 // doconsttimes(count,statement);
-// führt statement count mal aus (count mal der Code!),
+// führt statement count mal aus (count mal der Code!),
 // wobei count eine constant-expression >=0, <=8 ist.
   #define doconsttimes(count_from_doconsttimes,statement_from_doconsttimes)  \
     { if (0 < (count_from_doconsttimes)) { statement_from_doconsttimes; } \
@@ -212,7 +210,7 @@ namespace cln {
 // DOCONSTTIMES(count,macroname);
 // ruft count mal den Macro macroname auf (count mal der Code!),
 // wobei count eine constant-expression >=0, <=8 ist.
-// Dabei bekommt macroname der Reihe nach die Werte 0,...,count-1 übergeben.
+// Dabei bekommt macroname der Reihe nach die Werte 0,...,count-1 übergeben.
   #define DOCONSTTIMES(count_from_DOCONSTTIMES,macroname_from_DOCONSTTIMES)  \
     { if (0 < (count_from_DOCONSTTIMES)) { macroname_from_DOCONSTTIMES((0 < (count_from_DOCONSTTIMES) ? 0 : 0)); } \
       if (1 < (count_from_DOCONSTTIMES)) { macroname_from_DOCONSTTIMES((1 < (count_from_DOCONSTTIMES) ? 1 : 0)); } \
@@ -244,22 +242,12 @@ namespace cln {
 
 // Inside a class definition:
 // Overload `new' so that a class object can be allocated anywhere.
-#if !((defined(__rs6000__) || defined(__alpha__)) && !defined(__GNUC__))
 #define ALLOCATE_ANYWHERE(classname)  \
     /* Ability to place an object at a given address. */               \
 public:                                                                        \
     void* operator new (size_t size) { return malloc_hook(size); }     \
-    void* operator new (size_t size, classname* ptr) { unused size; return ptr; } \
+    void* operator new (size_t size, classname* ptr) { cl_unused size; return 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 malloc_hook(size); }     \
-    void* operator new (size_t size, void* ptr) { unused size; return ptr; } \
-    void operator delete (void* ptr) { free_hook(ptr); }
-#endif
 
 // init1(type, object) (value);
 // initializes `object' with `value', by calling `type''s constructor.
@@ -267,9 +255,6 @@ public:                                                                     \
 // it's a shame!)
 #define init1(type,lvalue)  (void) new (&(lvalue)) type
 
-// MAYBE_INLINE normally expands to nothing.
-// Useful for including the implementation of some file inline into another.
-  #define MAYBE_INLINE
-  #define MAYBE_INLINE2
+#include "base/cl_maybe_inline.h"
 
 #endif /* _CL_MACROS_H */