Rewritten Debug.h by Vasilis Kaoutsis.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20473 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-03-30 14:43:25 +00:00
parent e24e2c66c9
commit 9c62a6ed7d
+13 -33
View File
@@ -1,25 +1,20 @@
/****************************************************************************** /*
/ * Copyright 2007, Haiku, Inc. All Rights Reserved.
/ File: Debug.h * Distributed under the terms of the MIT License.
/ */
/ Description: Compile time and runtime switchable debug macros.
/
/ Copyright 1993-98, Be Incorporated
/
******************************************************************************/
#ifndef _DEBUG_H #ifndef _DEBUG_H
#define _DEBUG_H #define _DEBUG_H
#include <BeBuild.h> #include <BeBuild.h>
#include <SupportDefs.h> #include <OS.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <OS.h>
/*------------------------------*/
/*----- Private... -------------*/ /* Private */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -35,13 +30,8 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/*-------- ...to here ----------*/
/*-------------------------------------------------------------*/
/*----- Debug macros ------------------------------------------*/
/* Debug macros */
#if DEBUG #if DEBUG
#define SET_DEBUG_ENABLED(FLAG) _setDebugFlag(FLAG) #define SET_DEBUG_ENABLED(FLAG) _setDebugFlag(FLAG)
#define IS_DEBUG_ENABLED() _debugFlag() #define IS_DEBUG_ENABLED() _debugFlag()
@@ -86,29 +76,19 @@ extern "C" {
#if !defined(ASSERT) #if !defined(ASSERT)
#define ASSERT(E) (void)0 #define ASSERT(E) (void)0
#endif #endif
#define ASSERT_WITH_MESSAGE(expr, msg) \ #define ASSERT_WITH_MESSAGE(expr, msg) (void)0
(void)0
#define TRESPASS() (void)0 #define TRESPASS() (void)0
#define DEBUG_ONLY(x) #define DEBUG_ONLY(x)
#endif #endif
/* STATIC_ASSERT is a compile-time check that can be used to */
#if !__MWERKS__ /* verify static expressions such as: STATIC_ASSERT(sizeof(int64) == 8); */
// STATIC_ASSERT is a compile-time check that can be used to
// verify static expressions such as: STATIC_ASSERT(sizeof(int64) == 8);
#define STATIC_ASSERT(x) \ #define STATIC_ASSERT(x) \
do { \ do { \
struct __staticAssertStruct__ { \ struct __staticAssertStruct__ { \
char __static_assert_failed__[2*(x) - 1]; \ char __static_assert_failed__[2*(x) - 1]; \
}; \ }; \
} while (false) } while (false)
#else
#define STATIC_ASSERT(x)
// the STATIC_ASSERT above doesn't work too well with mwcc because
// of scoping bugs; for now make it do nothing
#endif
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _DEBUG_H */ #endif /* _DEBUG_H */