merge the formfield patch from ooo-build
[ooovba.git] / sal / inc / osl / diagnose.h
blobcd5b50c60bdedcabf3c462d0c7ca5885e41156ee
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: diagnose.h,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _OSL_DIAGNOSE_H_
33 #define _OSL_DIAGNOSE_H_
35 #include <sal/types.h>
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
41 /* //////////////////////////////////////////////////////////////////////////
42 Diagnostic support
45 void SAL_CALL osl_breakDebug(void);
46 sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const sal_Char* pszMessage);
47 void SAL_CALL osl_trace(const sal_Char* pszFormat, ...);
48 sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszErrorMessage);
51 For message delivery
54 /** a message delivery function which receives a pre-formatted message string
56 typedef void (SAL_CALL *pfunc_osl_printDebugMessage)( const sal_Char * pszMessage );
58 /** a message delivery function which receives detailed information about where the message was triggered
60 typedef void (SAL_CALL *pfunc_osl_printDetailedDebugMessage)( const sal_Char * pszFileName, sal_Int32 nLine, const sal_Char* pszMessage );
62 /** sets a message delivery function
64 The function set here is ignored if a function for detailed message information
65 (pfunc_osl_printDetailedDebugMessage) has been set.
67 The given message handler must be able to cope with a <NULL/> message.
69 pfunc_osl_printDebugMessage SAL_CALL osl_setDebugMessageFunc( pfunc_osl_printDebugMessage pNewFunc );
71 /** sets a delivery function for detailed message information.
73 The given message handler must be able to cope with a <NULL/> message.
75 pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pfunc_osl_printDetailedDebugMessage pNewFunc );
77 #ifdef __cplusplus
79 #endif
81 #define OSL_THIS_FILE __FILE__
83 /* the macro OSL_THIS_FUNC is intended to be an office internal macro for now */
84 #ifdef __func__
85 #define OSL_THIS_FUNC __func__
86 #elifdef __PRETTY_FUNCTION__
87 #define OSL_THIS_FUNC __PRETTY_FUNCTION__
88 #elifdef __FUNCTION__
89 #define OSL_THIS_FUNC __FUNCTION__
90 #else
91 #define OSL_THIS_FUNC " "
92 #endif
94 /* the macro OSL_TO_STRING is intended to be an office internal macro for now */
95 #define OSL_TO_STRING( x ) #x
97 /* the macro OSL_MACRO_VALUE_TO_STRING is intended to be an office internal macro for now */
98 #define OSL_MACRO_VALUE_TO_STRING( x ) OSL_TO_STRING( x )
100 /* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now */
101 #define OSL_LOG_PREFIX OSL_THIS_FILE ":" OSL_THIS_FUNC ":" OSL_MACRO_VALUE_TO_STRING( __LINE__ ) "; "
103 #define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
104 #define OSL_TRACE _OSL_TRACE
105 #define OSL_ASSERT(c) _OSL_ASSERT(c, OSL_THIS_FILE, __LINE__)
106 #define OSL_ENSURE(c, m) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
108 #define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
109 #define OSL_PRECOND(c, m) OSL_ENSURE(c, m)
110 #define OSL_POSTCOND(c, m) OSL_ENSURE(c, m)
113 #ifdef __cplusplus
114 #define _OSL_GLOBAL ::
115 #else
116 #define _OSL_GLOBAL
117 #endif /* __cplusplus */
119 #ifdef _WIN16
120 #if OSL_DEBUG_LEVEL > 0
121 #undef OSL_DEBUG_LEVEL
122 #define OSL_DEBUG_LEVEL 0
123 #endif
124 #endif
128 #if OSL_DEBUG_LEVEL > 0
130 #define _OSL_DEBUG_ONLY(f) (f)
131 #define _OSL_ASSERT(c, f, l) \
132 do \
134 if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, 0)) \
135 _OSL_GLOBAL osl_breakDebug(); \
136 } while (0)
138 #define _OSL_ENSURE(c, f, l, m) \
139 do \
141 if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \
142 _OSL_GLOBAL osl_breakDebug(); \
143 } while (0)
145 #else
147 #define _OSL_DEBUG_ONLY(f) ((void)0)
148 #define _OSL_ASSERT(c, f, l) ((void)0)
149 #define _OSL_ENSURE(c, f, l, m) ((void)0)
151 #endif /* OSL_DEBUG_LEVEL */
153 #if OSL_DEBUG_LEVEL > 1
155 #define _OSL_TRACE _OSL_GLOBAL osl_trace
157 #else
159 #define _OSL_TRACE 1 ? ((void)0) : _OSL_GLOBAL osl_trace
161 #endif /* OSL_DEBUG_LEVEL */
163 #endif /* _OSL_DIAGNOSE_H_ */