[Libreoffice-commits] .: 3 commits - sal/inc
David Tardon
dtardon at kemper.freedesktop.org
Fri Feb 25 09:25:58 PST 2011
sal/inc/osl/diagnose.h | 55 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 46 insertions(+), 9 deletions(-)
New commits:
commit 57433b40f0feef1e73254ff49ff4f6b279fa7796
Author: David Tardon <dtardon at redhat.com>
Date: Fri Feb 25 18:25:17 2011 +0100
shortly describe diagnostic macros
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
index b7b8e43..6cba3f7 100644
--- a/sal/inc/osl/diagnose.h
+++ b/sal/inc/osl/diagnose.h
@@ -32,6 +32,50 @@
#include <sal/types.h>
+/** provides simple diagnostic support
+
+ The functions defined in this header are not intended to be used directly,
+ but through defined macros. The macros can be divided into three categories:
+ assertions, traces and other stuff .-) Their usability depends on the value
+ of OSL_DEBUG_LEVEL macro: assertions are only active if OSL_DEBUG_LEVEL is 1
+ or greater, traces if OSL_DEBUG_LEVEL is 2 or greater.
+
+ Assertions (cond is bool, msg is char*):
+ OSL_ASSERT(cond)
+ If cond is false, reports an error.
+
+ OSL_ENSURE(cond, msg)
+ If cond is false, reports an error with message msg.
+
+ OSL_FAIL(msg)
+ Reports an error with message msg unconditionally.
+
+ OSL_PRECOND(cond, msg)
+ OSL_POSTCOND(cond, msg)
+ These two are functionally equivalent to OSL_ENSURE(cond, msg). They are
+ intended to be used for checking pre- and postconditions of functions.
+
+ Traces:
+ OSL_TRACE(fmt, args...)
+ Prints trace message. The arguments have the same meaning as the
+ arguments of printf.
+
+ Other:
+ OSL_VERIFY(expr)
+ Evaluates the expression and if it is false, reports an error. The
+ expression is evaluated once without regard of the value of
+ OSL_DEBUG_LEVEL.
+
+ Example:
+
+ void extractBool(Any const& rAny, bool& rBool)
+ {
+ OSL_VERIFY(rAny >>= rBool);
+ }
+
+ OSL_DEBUG_ONLY(expr)
+ */
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
commit 6d1d93a1b8be2581bb197e0763ab9f496c4905fe
Author: David Tardon <dtardon at redhat.com>
Date: Fri Feb 25 17:23:02 2011 +0100
define OSL_FAIL as replacement for DBG_ERROR
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
index 989b597..b7b8e43 100644
--- a/sal/inc/osl/diagnose.h
+++ b/sal/inc/osl/diagnose.h
@@ -91,6 +91,7 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#define OSL_TRACE _OSL_TRACE
#define OSL_ASSERT(c) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, 0)
#define OSL_ENSURE(c, m) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
+#define OSL_FAIL(m) _OSL_ENSURE(0, OSL_THIS_FILE, __LINE__, m)
#define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
#define OSL_PRECOND(c, m) OSL_ENSURE(c, m)
commit a4c7aed449e6cf589f184e8a8f3710d24f030325
Author: David Tardon <dtardon at redhat.com>
Date: Fri Feb 25 17:15:58 2011 +0100
use _OSL_ENSURE to define OSL_ASSERT
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
index a821266..989b597 100644
--- a/sal/inc/osl/diagnose.h
+++ b/sal/inc/osl/diagnose.h
@@ -89,7 +89,7 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
#define OSL_TRACE _OSL_TRACE
-#define OSL_ASSERT(c) _OSL_ASSERT(c, OSL_THIS_FILE, __LINE__)
+#define OSL_ASSERT(c) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, 0)
#define OSL_ENSURE(c, m) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
#define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
@@ -106,13 +106,6 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#if OSL_DEBUG_LEVEL > 0
#define _OSL_DEBUG_ONLY(f) (f)
-#define _OSL_ASSERT(c, f, l) \
- do \
- { \
- if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, 0)) \
- _OSL_GLOBAL osl_breakDebug(); \
- } while (0)
-
#define _OSL_ENSURE(c, f, l, m) \
do \
{ \
@@ -123,7 +116,6 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf
#else
#define _OSL_DEBUG_ONLY(f) ((void)0)
-#define _OSL_ASSERT(c, f, l) ((void)0)
#define _OSL_ENSURE(c, f, l, m) ((void)0)
#endif /* OSL_DEBUG_LEVEL */
More information about the Libreoffice-commits
mailing list