Zero  0.1.0
Classes | Macros
w_base.h File Reference
#include "w_defines.h"
#include "w_workaround.h"
#include "w_fill.h"
#include "w_error.h"
#include "w_rc.h"

Go to the source code of this file.

Classes

class  w_base_t
 
class  w_vbase_t
 Class that adds virtual destructor to w_base_t. More...
 
struct  CompileTimeAssertion< B >
 
struct  CompileTimeAssertion< true >
 Compile-time assertion trick. More...
 
struct  compile_time_assert< T >
 Compile-time assertion trick. More...
 

Macros

#define CAST(t, o)   ((t)(o))
 
#define W_UNUSED(x)
 
#define W_IFDEBUG1(x)
 
#define W_IFNDEBUG1(x)   x
 
#define W_IFDEBUG2(x)
 
#define W_IFNDEBUG2(x)   x
 
#define W_IFDEBUG3(x)
 
#define W_IFNDEBUG3(x)   x
 
#define W_IFDEBUG4(x)
 
#define W_IFNDEBUG4(x)   x
 
#define W_IFDEBUG5(x)
 
#define W_IFNDEBUG5(x)   x
 
#define W_IFDEBUG9(x)
 
#define W_IFNDEBUG9(x)   x
 
#define W_IFDEBUG(x)
 
#define W_IFNDEBUG(x)   x
 
#define W_IFTRACE(x)
 
#define W_IFNTRACE(x)   x
 
#define w_assert0(x)
 Default assert/debug level is 0. More...
 
#define w_assert0_msg(x, msg)
 
#define W_DEBUG_LEVEL   0
 
#define w_assert1(x)   if (false) { (void)(x); }
 Level 1 should not add significant extra time. More...
 
#define w_assert2(x)   if (false) { (void)(x); }
 Level 2 adds some time. More...
 
#define w_assert3(x)   if (false) { (void)(x); }
 Level 3 definitely adds significant time. More...
 
#define w_assert4(x)   if (false) { (void)(x); }
 Level 4 can be a hog. More...
 
#define w_assert5(x)   if (false) { (void)(x); }
 Level 5 is not yet used. More...
 
#define w_assert9(x)   if (false) { (void)(x); }
 changing an assert to an assert9 turns it off. More...
 
#define W_ENUM(x)   ((int)(x))
 Cast to treat an enum as integer value. More...
 
#define W_ADDR(x)   ((void *)(x))
 Cast to treat a pointer as a non-(char *) value. More...
 
#define alignonarg(a)   (((ptrdiff_t)(a))-1)
 helper for alignon More...
 
#define alignon(p, a)   (((ptrdiff_t)((ptrdiff_t)(p) + alignonarg(a))) & ~alignonarg(a))
 aligns a pointer p on a size a More...
 
#define ALIGNON   0x8
 
#define ALIGNON1   (ALIGNON-1)
 
#define ALIGN_BYTE(sz)   ((size_t)((sz + ALIGNON1) & ~ALIGNON1))
 
#define ASSERT_FITS_IN_POINTER(T)
 
#define ASSERT_FITS_IN_LONGLONG(T)
 

Detailed Description

Basic types.

Macro Definition Documentation

§ ALIGN_BYTE

#define ALIGN_BYTE (   sz)    ((size_t)((sz + ALIGNON1) & ~ALIGNON1))

§ alignon

#define alignon (   p,
 
)    (((ptrdiff_t)((ptrdiff_t)(p) + alignonarg(a))) & ~alignonarg(a))

aligns a pointer p on a size a

§ ALIGNON

#define ALIGNON   0x8

§ ALIGNON1

#define ALIGNON1   (ALIGNON-1)

§ alignonarg

#define alignonarg (   a)    (((ptrdiff_t)(a))-1)

helper for alignon

§ ASSERT_FITS_IN_LONGLONG

#define ASSERT_FITS_IN_LONGLONG (   T)

§ ASSERT_FITS_IN_POINTER

#define ASSERT_FITS_IN_POINTER (   T)

§ CAST

#define CAST (   t,
 
)    ((t)(o))

§ W_ADDR

#define W_ADDR (   x)    ((void *)(x))

Cast to treat a pointer as a non-(char *) value.

This is used when a operator<< is used on a pointer. Without this cast, some values would bind to 'char *' and attempt to print a string, rather than printing the desired pointer value.

§ w_assert0

#define w_assert0 (   x)
Value:
do { \
if (!(x)) w_base_t::assert_failed(#x, __FILE__, __LINE__); \
} while(0)
Definition: w_base.h:266

Default assert/debug level is 0.

§ w_assert0_msg

#define w_assert0_msg (   x,
  msg 
)
Value:
do { \
if(!(x)) { \
std::stringstream s; \
s << #x ; \
s << " (detail: " << msg << ")"; \
w_base_t::assert_failed(s.str().c_str(), __FILE__, __LINE__); \
} \
}while(0) \
static void assert_failed(const char *desc, const char *file, uint32_t line)
print a message and abort
Definition: w_base.cpp:124

§ w_assert1

#define w_assert1 (   x)    if (false) { (void)(x); }

Level 1 should not add significant extra time.

§ w_assert2

#define w_assert2 (   x)    if (false) { (void)(x); }

Level 2 adds some time.

§ w_assert3

#define w_assert3 (   x)    if (false) { (void)(x); }

Level 3 definitely adds significant time.

§ w_assert4

#define w_assert4 (   x)    if (false) { (void)(x); }

Level 4 can be a hog.

§ w_assert5

#define w_assert5 (   x)    if (false) { (void)(x); }

Level 5 is not yet used.

§ w_assert9

#define w_assert9 (   x)    if (false) { (void)(x); }

changing an assert to an assert9 turns it off.

§ W_DEBUG_LEVEL

#define W_DEBUG_LEVEL   0

§ W_ENUM

#define W_ENUM (   x)    ((int)(x))

Cast to treat an enum as integer value.

This is used when a operator<< doesn't exist for the enum. The use of the macro indicates that this enum would be printed if it had a printer, rather than wanting the integer value of the enum

§ W_IFDEBUG

#define W_IFDEBUG (   x)

§ W_IFDEBUG1

#define W_IFDEBUG1 (   x)

§ W_IFDEBUG2

#define W_IFDEBUG2 (   x)

§ W_IFDEBUG3

#define W_IFDEBUG3 (   x)

§ W_IFDEBUG4

#define W_IFDEBUG4 (   x)

§ W_IFDEBUG5

#define W_IFDEBUG5 (   x)

§ W_IFDEBUG9

#define W_IFDEBUG9 (   x)

§ W_IFNDEBUG

#define W_IFNDEBUG (   x)    x

§ W_IFNDEBUG1

#define W_IFNDEBUG1 (   x)    x

§ W_IFNDEBUG2

#define W_IFNDEBUG2 (   x)    x

§ W_IFNDEBUG3

#define W_IFNDEBUG3 (   x)    x

§ W_IFNDEBUG4

#define W_IFNDEBUG4 (   x)    x

§ W_IFNDEBUG5

#define W_IFNDEBUG5 (   x)    x

§ W_IFNDEBUG9

#define W_IFNDEBUG9 (   x)    x

§ W_IFNTRACE

#define W_IFNTRACE (   x)    x

§ W_IFTRACE

#define W_IFTRACE (   x)

§ W_UNUSED

#define W_UNUSED (   x)