drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
ut0dbg.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/*****************************************************************/
25
26#pragma once
27#ifndef ut0dbg_h
28#define ut0dbg_h
29
30#include "univ.i"
31#include <stdlib.h>
32#include "os0thread.h"
33
34#if defined(__GNUC__) && (__GNUC__ > 2)
38# define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
39#else
41extern ulint ut_dbg_zero;
45# define UT_DBG_FAIL(EXPR) !((ulint)(EXPR) + ut_dbg_zero)
46#endif
47
48/*************************************************************/
50#ifdef __cplusplus
51extern "C"
52#endif
53UNIV_INTERN
54void
56/*====================*/
57 const char* expr,
58 const char* file,
59 ulint line);
60
61#if defined(__WIN__) || defined(__INTEL_COMPILER)
62# undef UT_DBG_USE_ABORT
63#elif defined(__GNUC__) && (__GNUC__ > 2)
64# define UT_DBG_USE_ABORT
65#endif
66
67#ifndef UT_DBG_USE_ABORT
69extern ulint* ut_dbg_null_ptr;
70#endif
71
72#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
75extern ibool ut_dbg_stop_threads;
76
77/*************************************************************/
79UNIV_INTERN
80void
82/*===============*/
83 const char* file,
84 ulint line);
85#endif
86
87#ifdef UT_DBG_USE_ABORT
89# define UT_DBG_PANIC abort()
91# define UT_DBG_STOP do {} while (0)
92#else /* UT_DBG_USE_ABORT */
94# define UT_DBG_PANIC \
95 if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
96
97# define UT_DBG_STOP do \
98 if (UNIV_UNLIKELY(ut_dbg_stop_threads)) { \
99 ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
100 } while (0)
101#endif /* UT_DBG_USE_ABORT */
102
105#define ut_a(EXPR) do { \
106 if (UT_DBG_FAIL(EXPR)) { \
107 ut_dbg_assertion_failed(#EXPR, \
108 __FILE__, (ulint) __LINE__); \
109 UT_DBG_PANIC; \
110 } \
111 UT_DBG_STOP; \
112} while (0)
113
115#define ut_error do { \
116 ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
117 UT_DBG_PANIC; \
118} while (0)
119
120#ifdef UNIV_DEBUG
122#define ut_ad(EXPR) ut_a(EXPR)
124#define ut_d(EXPR) do {EXPR;} while (0)
125#else
127#define ut_ad(EXPR)
129#define ut_d(EXPR)
130#endif
131
134#define UT_NOT_USED(A) A = A
135
136#ifdef UNIV_COMPILE_TEST_FUNCS
137
138#include <sys/types.h>
139#include <sys/time.h>
140#include <sys/resource.h>
141
143typedef struct speedo_struct {
144 struct rusage ru;
145 struct timeval tv;
146} speedo_t;
147
148/*******************************************************************/
150UNIV_INTERN
151void
152speedo_reset(
153/*=========*/
154 speedo_t* speedo);
155
156/*******************************************************************/
159UNIV_INTERN
160void
161speedo_show(
162/*========*/
163 const speedo_t* speedo);
164
165#endif /* UNIV_COMPILE_TEST_FUNCS */
166
167#endif
ulint * ut_dbg_null_ptr
Definition ut0dbg.cc:43
UNIV_INTERN void ut_dbg_stop_thread(const char *file, ulint line)
Definition ut0dbg.cc:94
ulint ut_dbg_zero
Definition ut0dbg.cc:33
ibool ut_dbg_stop_threads
Definition ut0dbg.cc:39
UNIV_INTERN void ut_dbg_assertion_failed(const char *expr, const char *file, ulint line)
Definition ut0dbg.cc:53