Improved memory debugger -> added memory re-initialization at free time -> added...
authorBenjamin Segovia <segovia.benjamin@gmail.com>
Mon, 13 Feb 2012 14:47:09 +0000 (14:47 +0000)
committerKeith Packard <keithp@keithp.com>
Fri, 10 Aug 2012 23:15:15 +0000 (16:15 -0700)
backend/CMakeLists.txt
backend/src/CMakeLists.txt
backend/src/blob.cpp [new file with mode: 0644]
backend/src/sys/alloc.cpp
backend/src/sys/alloc.hpp
backend/src/sys/assert.cpp [new file with mode: 0644]
backend/src/sys/assert.hpp [new file with mode: 0644]
backend/src/sys/exception.hpp
backend/src/sys/vector.hpp

index 4b2ffca..81274c4 100644 (file)
@@ -10,8 +10,8 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GBE_CMAKE_DIR}")
 ##############################################################
 
 set (GBE_DEBUG_MEMORY false CACHE bool "Activate the memory debugger")
+set (GBE_COMPILE_UTEST false CACHE bool "Will compile the unit tests")
 set (GBE_USE_BLOB false CACHE bool "Compile everything from one big file")
-set (GBE_VERBOSE_VECTORIZER false CACHE bool "Output vectorizer diagnostic (GCC only)")
 
 ##############################################################
 # Compiler
@@ -36,6 +36,12 @@ else (GBE_DEBUG_MEMORY)
   set (GBE_DEBUG_MEMORY_FLAG "${DEF}GBE_DEBUG_MEMORY=0")
 endif (GBE_DEBUG_MEMORY)
 
+if (GBE_COMPILE_UTEST)
+  set (GBE_COMPILE_UTESTS_FLAG "${DEF}GBE_COMPILE_UTESTS=1")
+else (GBE_COMPILE_UTEST)
+  set (GBE_COMPILE_UTESTS_FLAG "${DEF}GBE_COMPILE_UTESTS=0")
+endif (GBE_COMPILE_UTEST)
+
 ## Linux compilation
 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
   # Hide all symbols and allows the symbols declared as visible to be exported
@@ -44,11 +50,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
   if (COMPILER STREQUAL "GCC")
     set (CMAKE_CXX_FLAGS "-Wstrict-aliasing=2 -Wno-invalid-offsetof -fno-strict-aliasing -msse2 -ffast-math -fPIC -Wall -fno-rtti -std=c++0x")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISIBILITY_FLAG} -Wl,-E")
+    if (NOT GBE_COMPILE_UTEST)
+      set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
+    endif (NOT GBE_COMPILE_UTEST)
     set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -ftree-vectorize")
-    if (GBE_VERBOSE_VECTORIZER)
-      set (CMAKE_CXX_FLAGS "-ftree-vectorizer-verbose=2")
-    endif (GBE_VERBOSE_VECTORIZER)
   elseif (COMPILER STREQUAL "CLANG")
     set (CMAKE_C_COMPILER             "clang")
     set (CMAKE_C_FLAGS                "-Wall -std=c99")
@@ -59,6 +66,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
     set (CMAKE_CXX_COMPILER             "clang++")
     set (CMAKE_CXX_FLAGS "-fno-strict-aliasing -msse2 -ffast-math -fPIC -Wall -Wno-format-security -Wno-invalid-offsetof -std=c++0x")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISIBILITY_FLAG}")
     set (CMAKE_CXX_FLAGS_DEBUG          "-g")
     set (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
@@ -74,6 +82,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
     set (CMAKE_C_COMPILER "icc")
     set (CMAKE_CXX_FLAGS "-std=c++0x -wd2928 -Wall -fPIC -fno-strict-aliasing -fp-model fast -xSSE2")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISIBILITY_FLAG} -Wl,-E")
     set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
     set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2")
@@ -85,10 +94,9 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
 ## Windows compilation
 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
   if (MINGW)
-     if (GBE_VERBOSE_VECTORIZER)
-      set (CMAKE_CXX_FLAGS "-ftree-vectorizer-verbose=2")
-    endif (GBE_VERBOSE_VECTORIZER)
-    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG} -Wno-invalid-offsetof -fstrict-aliasing -msse2 -ffast-math -Wall -fno-rtti -std=c++0x")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -fstrict-aliasing -msse2 -ffast-math -Wall -fno-rtti -std=c++0x")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
     set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
   else (MINGW)
     set (COMMON_FLAGS "${GBE_DEBUG_MEMORY_FLAG} /arch:SSE2 /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /GR- /GS- /W3 /wd4275")
index 30fbfe4..71601a6 100644 (file)
@@ -1,40 +1,43 @@
-set (GBE_SRC
-  sys/vector.hpp
-  sys/hash_map.hpp
-  sys/map.hpp
-  sys/set.hpp
-  sys/exception.hpp
-  sys/assert.cpp
-  sys/assert.hpp
-  sys/string.cpp
-  sys/string.hpp
-  sys/alloc.cpp
-  sys/alloc.hpp
-  sys/sysinfo.cpp
-  sys/sysinfo.hpp
-  sys/mutex.cpp
-  sys/mutex.hpp
-  sys/condition.cpp
-  sys/condition.hpp
-  sys/platform.cpp
-  sys/platform.hpp
-  ir/context.cpp
-  ir/context.hpp
-  ir/unit.cpp
-  ir/unit.hpp
-  ir/constant.cpp
-  ir/constant.hpp
-  ir/instruction.cpp
-  ir/instruction.hpp
-  ir/register.cpp
-  ir/register.hpp
-  ir/function.cpp
-  ir/function.hpp)
+if (GBE_USE_BLOB)
+  set (GBE_SRC blob.cpp)
+else (GBE_USE_BLOB)
+  set (GBE_SRC
+    sys/vector.hpp
+    sys/hash_map.hpp
+    sys/map.hpp
+    sys/set.hpp
+    sys/exception.hpp
+    sys/assert.cpp
+    sys/assert.hpp
+    sys/string.cpp
+    sys/string.hpp
+    sys/alloc.cpp
+    sys/alloc.hpp
+    sys/sysinfo.cpp
+    sys/sysinfo.hpp
+    sys/mutex.cpp
+    sys/mutex.hpp
+    sys/condition.cpp
+    sys/condition.hpp
+    sys/platform.cpp
+    sys/platform.hpp
+    ir/context.cpp
+    ir/context.hpp
+    ir/unit.cpp
+    ir/unit.hpp
+    ir/constant.cpp
+    ir/constant.hpp
+    ir/instruction.cpp
+    ir/instruction.hpp
+    ir/register.cpp
+    ir/register.hpp
+    ir/function.cpp
+    ir/function.hpp)
 
-set (COMPILE_UTEST false CACHE bool "Compile or not the unit tests")
-if (COMPILE_UTEST)
-  set (GBE_SRC ${GBE_SRC})
-endif (COMPILE_UTEST)
+  if (GBE_COMPILE_UTEST)
+    set (GBE_SRC ${GBE_SRC})
+  endif (GBE_COMPILE_UTEST)
+endif (GBE_USE_BLOB)
 
 include_directories (.)
 add_library (gbe SHARED ${GBE_SRC})
diff --git a/backend/src/blob.cpp b/backend/src/blob.cpp
new file mode 100644 (file)
index 0000000..3477f08
--- /dev/null
@@ -0,0 +1,45 @@
+/* 
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+/**
+ * \file blob.cpp
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ *
+ * Compile the complete project from one file. This allows pretty aggresive
+ * optimization from the compiler and decreases the binary size
+ */
+
+#include "sys/assert.cpp"
+#include "sys/string.cpp"
+#include "sys/alloc.cpp"
+#include "sys/sysinfo.cpp"
+#include "sys/mutex.cpp"
+#include "sys/condition.cpp"
+#include "sys/platform.cpp"
+#include "ir/context.cpp"
+#include "ir/unit.cpp"
+#include "ir/constant.cpp"
+#include "ir/instruction.cpp"
+#include "ir/register.cpp"
+#include "ir/function.cpp"
+
+#if GBE_COMPILE_UTEST
+
+#endif /* GBE_COMPILE_UTEST */
+
index d253e47..11b91ef 100644 (file)
 
 /**
  * \file alloc.cpp
- *
  * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ *
+ *  Provides facilities to track allocations and pre-initialize memory at
+ *  memory allocation and memory free time
  */
 #include "sys/alloc.hpp"
 #include "sys/atomic.hpp"
@@ -135,15 +137,37 @@ namespace gbe
 
   /*! Declare C like interface functions here */
   static MemDebugger *memDebugger = NULL;
+
+  /*! Stop the memory debugger */
+  static void MemDebuggerEnd(void) {
+    MemDebugger *_debug = memDebugger;
+    memDebugger = NULL;
+    delete _debug;
+  }
+
+  /*! Use this to serialize multiple starts of the debugger */
+  static MutexSys startMemDebuggerMutex;
+
+  /*! Start the memory debugger */
+  static void MemDebuggerStart(void) {
+    Lock<MutexSys> lock(startMemDebuggerMutex);
+    if (memDebugger == NULL) {
+      atexit(MemDebuggerEnd);
+      memDebugger = new MemDebugger;
+    }
+  }
+
   void* MemDebuggerInsertAlloc(void *ptr, const char *file, const char *function, int line) {
-    if (memDebugger) return memDebugger->insertAlloc(ptr, file, function, line);
-    return ptr;
+    if (memDebugger == NULL) MemDebuggerStart();
+    return memDebugger->insertAlloc(ptr, file, function, line);
   }
   void MemDebuggerRemoveAlloc(void *ptr) {
-    if (memDebugger) memDebugger->removeAlloc(ptr);
+    if (memDebugger == NULL) MemDebuggerStart();
+    memDebugger->removeAlloc(ptr);
   }
   void MemDebuggerDumpAlloc(void) {
-    if (memDebugger) memDebugger->dumpAlloc();
+    if (memDebugger == NULL) MemDebuggerStart();
+    memDebugger->dumpAlloc();
   }
   void MemDebuggerEnableMemoryInitialization(bool enabled) {
     memoryInitializationEnabled = enabled;
@@ -151,47 +175,65 @@ namespace gbe
   void MemDebuggerInitializeMem(void *mem, size_t sz) {
     if (memoryInitializationEnabled) std::memset(mem, 0xcd, sz);
   }
-  void MemDebuggerStart(void) {
-    if (memDebugger) MemDebuggerEnd();
-    memDebugger = new MemDebugger;
-  }
-  void MemDebuggerEnd(void) {
-    MemDebugger *_debug = memDebugger;
-    memDebugger = NULL;
-    delete _debug;
-  }
+} /* namespace gbe */
+
 #endif /* GBE_DEBUG_MEMORY */
-}
 
 namespace gbe
 {
+#if GBE_DEBUG_MEMORY
   void* malloc(size_t size) {
-    void *ptr = std::malloc(size);
-    MemDebuggerInitializeMem(ptr, size);
-    return ptr;
+    void *ptr = std::malloc(size + sizeof(size_t));
+    *(size_t *) ptr = size;
+    MemDebuggerInitializeMem((char*) ptr + sizeof(size_t), size);
+    return (char *) ptr + sizeof(size_t);
+  }
+  void free(void *ptr) {
+    if (ptr != NULL) {
+      char *toFree = (char*) ptr - sizeof(size_t);
+      const size_t size = *(size_t *) toFree;
+      MemDebuggerInitializeMem(ptr, size);
+      std::free(toFree);
+    }
   }
+#else
+  void* malloc(size_t size) { return  std::malloc(size); }
+  void free(void *ptr) { if (ptr != NULL) std::free(ptr); }
+#endif /* GBE_DEBUG_MEMORY */
+
+} /* namespace gbe */
 
-  void* realloc(void *ptr, size_t size) {
 #if GBE_DEBUG_MEMORY
-    if (ptr) MemDebuggerRemoveAlloc(ptr);
-#endif /* GBE_DEBUG_MEMORY */
-    GBE_ASSERT(size);
-    if (ptr == NULL) {
-      ptr = std::realloc(ptr, size);
+
+namespace gbe
+{
+  void* alignedMalloc(size_t size, size_t align) {
+    void* mem = malloc(size+(align-1)+sizeof(uintptr_t) + sizeof(void*));
+    FATAL_IF (!mem && size, "memory allocation failed");
+    char* aligned = (char*) mem + sizeof(uintptr_t) + sizeof(void*);
+    aligned += align - ((uintptr_t)aligned & (align - 1));
+    ((void**)aligned)[-1] = mem;
+    ((uintptr_t*)aligned)[-2] = uintptr_t(size);
+    MemDebuggerInitializeMem(aligned, size);
+    return aligned;
+  }
+
+  void alignedFree(void* ptr) {
+    if (ptr) {
+      const size_t size = ((uintptr_t*)ptr)[-2];
       MemDebuggerInitializeMem(ptr, size);
-      return ptr;
-    } else
-      return std::realloc(ptr, size);
+      free(((void**)ptr)[-2]);
+    }
   }
+} /* namespace gbe */
 
-  void free(void *ptr) { if (ptr != NULL) std::free(ptr); }
-}
+#else
 
 ////////////////////////////////////////////////////////////////////////////////
 /// Windows Platform
 ////////////////////////////////////////////////////////////////////////////////
 
-#ifdef __WIN32__
+#if defined(__WIN32__)
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -205,15 +247,16 @@ namespace gbe
     return ptr;
   }
 
-  void alignedFree(void *ptr) { _mm_free(ptr); }
-}
-#endif
+  void alignedFree(void *ptr) { if (ptr) _mm_free(ptr); }
+} /* namespace gbe */
+
+#endif /* __WIN32__ */
 
 ////////////////////////////////////////////////////////////////////////////////
 /// Linux Platform
 ////////////////////////////////////////////////////////////////////////////////
 
-#ifdef __LINUX__
+#if defined(__LINUX__)
 
 #include <unistd.h>
 #include <sys/mman.h>
@@ -230,16 +273,16 @@ namespace gbe
     return ptr;
   }
 
-  void alignedFree(void *ptr) { free(ptr); }
-}
+  void alignedFree(void *ptr) { if (ptr) free(ptr); }
+} /* namespace gbe */
 
-#endif
+#endif /* __LINUX__ */
 
 ////////////////////////////////////////////////////////////////////////////////
 /// MacOS Platform
 ////////////////////////////////////////////////////////////////////////////////
 
-#ifdef __MACOSX__
+#if defined(__MACOSX__)
 
 #include <cstdlib>
 
@@ -255,11 +298,10 @@ namespace gbe
     return aligned;
   }
 
-  void alignedFree(void* ptr) {
-    GBE_ASSERT(ptr);
-    free(((void**)ptr)[-1]);
-  }
-}
+  void alignedFree(void* ptr) { if (ptr) free(((void**)ptr)[-1]); }
+} /* namespace gbe */
+
+#endif /* __MACOSX__ */
 
-#endif
+#endif /* GBE_DEBUG_MEMORY */
 
index a03ab1a..b61efa7 100644 (file)
@@ -19,7 +19,6 @@
 
 /**
  * \file alloc.hpp
- *
  * \author Benjamin Segovia <benjamin.segovia@intel.com>
  */
 #ifndef __GBE_ALLOC_HPP__
@@ -33,7 +32,6 @@ namespace gbe
 {
   /*! regular allocation */
   void* malloc(size_t size);
-  void* realloc(void *ptr, size_t size);
   void  free(void *ptr);
 
   /*! Aligned allocation */
@@ -47,16 +45,12 @@ namespace gbe
   void  MemDebuggerDumpAlloc(void);
   void  MemDebuggerInitializeMem(void *mem, size_t sz);
   void  MemDebuggerEnableMemoryInitialization(bool enabled);
-  void  MemDebuggerStart(void);
-  void  MemDebuggerEnd(void);
 #else
   INLINE void* MemDebuggerInsertAlloc(void *ptr, const char*, const char*, int) {return ptr;}
   INLINE void  MemDebuggerRemoveAlloc(void *ptr) {}
   INLINE void  MemDebuggerDumpAlloc(void) {}
   INLINE void  MemDebuggerInitializeMem(void *mem, size_t sz) {}
   INLINE void  MemDebuggerEnableMemoryInitialization(bool enabled) {}
-  INLINE void  MemDebuggerStart(void) {}
-  INLINE void  MemDebuggerEnd(void) {}
 #endif /* GBE_DEBUG_MEMORY */
 
   /*! Properly handle the allocated type */
@@ -96,20 +90,20 @@ namespace gbe
 
 /*! Declare a class with custom allocators */
 #define GBE_CLASS(TYPE) \
-public:                \
+public:                 \
   GBE_STRUCT(TYPE)      \
 private:
 
 /*! Declare an aligned structure */
-#define GBE_ALIGNED_STRUCT(ALIGN)                                              \
-  void* operator new(size_t size)   { return gbe::alignedMalloc(size, ALIGN); }\
-  void* operator new[](size_t size) { return gbe::alignedMalloc(size, ALIGN); }\
-  void  operator delete(void* ptr)   { gbe::alignedFree(ptr); }                \
+#define GBE_ALIGNED_STRUCT(ALIGN)                                               \
+  void* operator new(size_t size)   { return gbe::alignedMalloc(size, ALIGN); } \
+  void* operator new[](size_t size) { return gbe::alignedMalloc(size, ALIGN); } \
+  void  operator delete(void* ptr)   { gbe::alignedFree(ptr); }                 \
   void  operator delete[](void* ptr) { gbe::alignedFree(ptr); }
 
 /*! Declare an aligned class */
 #define GBE_ALIGNED_CLASS(ALIGN)    \
-public:                            \
+public:                             \
   GBE_ALIGNED_STRUCT(ALIGN)         \
 private:
 
@@ -132,9 +126,6 @@ private:
 #define GBE_MALLOC(SZ)               \
   gbe::MemDebuggerInsertAlloc(gbe::malloc(SZ),__FILE__, __FUNCTION__, __LINE__)
 
-#define GBE_REALLOC(PTR, SZ)         \
-  gbe::MemDebuggerInsertAlloc(gbe::realloc(PTR, SZ),__FILE__, __FUNCTION__, __LINE__)
-
 #define GBE_FREE(X)                  \
   do { gbe::MemDebuggerRemoveAlloc(X); gbe::free(X); } while (0)
 
diff --git a/backend/src/sys/assert.cpp b/backend/src/sys/assert.cpp
new file mode 100644 (file)
index 0000000..ff17f54
--- /dev/null
@@ -0,0 +1,62 @@
+/* 
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+/**
+ * \file assert.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#if GBE_COMPILE_UTESTS
+
+#include "assert.hpp"
+#include "exception.hpp"
+namespace gbe
+{
+  void onFailedAssert(const char *file, const char *fn, int line)
+  {
+    char lineString[256];
+    sprintf(lineString, "%i", line);
+    const std::string msg = "file " + std::string(file)
+                          + ", function " + std::string(fn)
+                          + ", line " + std::string(lineString);
+    throw Exception(msg);
+  }
+} /* namespace gbe */
+
+#else
+
+#include "sys/assert.hpp"
+#include "sys/exception.hpp"
+#include "sys/platform.hpp"
+#include <cstdio>
+
+namespace gbe
+{
+  void onFailedAssert(const char *file, const char *fn, int32_t line)
+  {
+    fprintf(stderr, " ASSERTION FAILED: file %s, function %s, line %i\n",
+            file, fn, line);
+    fflush(stdout);
+    DEBUGBREAK();
+    _exit(-1);
+  }
+} /* namespace gbe */
+
+#endif /* GBE_COMPILE_UTESTS */
+
diff --git a/backend/src/sys/assert.hpp b/backend/src/sys/assert.hpp
new file mode 100644 (file)
index 0000000..9b031c0
--- /dev/null
@@ -0,0 +1,35 @@
+/* 
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+/**
+ * \file assert.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#ifndef __GBE_ASSERT_HPP__
+#define __GBE_ASSERT_HPP__
+
+namespace gbe
+{
+  /*! To ensure that condition truth. Optional message is supported */
+  void onFailedAssert(const char *file, const char *fn, int line);
+} /* namespace gbe */
+
+#endif /* __GBE_ASSERT_HPP__ */
+
index f0ba32e..373b687 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef __GBE_EXCEPTION_HPP__
 #define __GBE_EXCEPTION_HPP__
 
-#if defined(GBE_COMPILE_UTEST)
+#if GBE_COMPILE_UTESTS
 
 #include "string.hpp"
 #include <exception>
@@ -50,6 +50,6 @@ namespace gbe
 
 } /* namespace gbe */
 
-#endif /* GBE_COMPILE_UTEST */
+#endif /* GBE_COMPILE_UTESTS */
 #endif /* __GBE_EXCEPTION_HPP__ */
 
index d4ad2a8..6632d19 100644 (file)
@@ -19,7 +19,6 @@
 
 /**
  * \file vector.hpp
- *
  * \author Benjamin Segovia <benjamin.segovia@intel.com>
  */