Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027 #ifndef ut0dbg_h
00028 #define ut0dbg_h
00029
00030 #include "univ.i"
00031 #include <stdlib.h>
00032 #include "os0thread.h"
00033
00034 #if defined(__GNUC__) && (__GNUC__ > 2)
00035
00038 # define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
00039 #else
00040
00041 extern ulint ut_dbg_zero;
00045 # define UT_DBG_FAIL(EXPR) !((ulint)(EXPR) + ut_dbg_zero)
00046 #endif
00047
00048
00050 #ifdef __cplusplus
00051 extern "C"
00052 #endif
00053 UNIV_INTERN
00054 void
00055 ut_dbg_assertion_failed(
00056
00057 const char* expr,
00058 const char* file,
00059 ulint line);
00061 #if defined(__WIN__) || defined(__INTEL_COMPILER)
00062 # undef UT_DBG_USE_ABORT
00063 #elif defined(__GNUC__) && (__GNUC__ > 2)
00064 # define UT_DBG_USE_ABORT
00065 #endif
00066
00067 #ifndef UT_DBG_USE_ABORT
00068
00069 extern ulint* ut_dbg_null_ptr;
00070 #endif
00071
00072 #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
00073
00075 extern ibool ut_dbg_stop_threads;
00076
00077
00079 UNIV_INTERN
00080 void
00081 ut_dbg_stop_thread(
00082
00083 const char* file,
00084 ulint line);
00085 #endif
00086
00087 #ifdef UT_DBG_USE_ABORT
00088
00089 # define UT_DBG_PANIC abort()
00090
00091 # define UT_DBG_STOP do {} while (0)
00092 #else
00093
00094 # define UT_DBG_PANIC \
00095 if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
00096
00097 # define UT_DBG_STOP do \
00098 if (UNIV_UNLIKELY(ut_dbg_stop_threads)) { \
00099 ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
00100 } while (0)
00101 #endif
00102
00105 #define ut_a(EXPR) do { \
00106 if (UT_DBG_FAIL(EXPR)) { \
00107 ut_dbg_assertion_failed(#EXPR, \
00108 __FILE__, (ulint) __LINE__); \
00109 UT_DBG_PANIC; \
00110 } \
00111 UT_DBG_STOP; \
00112 } while (0)
00113
00115 #define ut_error do { \
00116 ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
00117 UT_DBG_PANIC; \
00118 } while (0)
00119
00120 #ifdef UNIV_DEBUG
00121
00122 #define ut_ad(EXPR) ut_a(EXPR)
00123
00124 #define ut_d(EXPR) do {EXPR;} while (0)
00125 #else
00126
00127 #define ut_ad(EXPR)
00128
00129 #define ut_d(EXPR)
00130 #endif
00131
00134 #define UT_NOT_USED(A) A = A
00135
00136 #ifdef UNIV_COMPILE_TEST_FUNCS
00137
00138 #include <sys/types.h>
00139 #include <sys/time.h>
00140 #include <sys/resource.h>
00141
00143 typedef struct speedo_struct {
00144 struct rusage ru;
00145 struct timeval tv;
00146 } speedo_t;
00147
00148
00150 UNIV_INTERN
00151 void
00152 speedo_reset(
00153
00154 speedo_t* speedo);
00156
00159 UNIV_INTERN
00160 void
00161 speedo_show(
00162
00163 const speedo_t* speedo);
00165 #endif
00166
00167 #endif