~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ut0dbg.h

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************************
2
 
Debug utilities for Innobase
3
 
 
4
 
(c) 1994, 1995 Innobase Oy
5
 
 
6
 
Created 1/30/1994 Heikki Tuuri
7
 
**********************************************************************/
8
 
 
9
 
#ifndef ut0dbg_h
10
 
#define ut0dbg_h
11
 
 
12
 
#include "univ.i"
13
 
#include <stdlib.h>
14
 
#include "os0thread.h"
15
 
 
16
 
#if defined(__GNUC__) && (__GNUC__ > 2)
17
 
# define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
18
 
#else
19
 
extern ulint    ut_dbg_zero; /* This is used to eliminate
20
 
                                compiler warnings */
21
 
# define UT_DBG_FAIL(EXPR) !((ulint)(EXPR) + ut_dbg_zero)
22
 
#endif
23
 
 
24
 
/*****************************************************************
25
 
Report a failed assertion. */
26
 
 
27
 
void
28
 
ut_dbg_assertion_failed(
29
 
/*====================*/
30
 
        const char* expr,       /* in: the failed assertion */
31
 
        const char* file,       /* in: source file containing the assertion */
32
 
        ulint line);            /* in: line number of the assertion */
33
 
 
34
 
# if defined(__WIN__) || defined(__INTEL_COMPILER)
35
 
#  undef UT_DBG_USE_ABORT
36
 
# elif defined(__GNUC__) && (__GNUC__ > 2)
37
 
#  define UT_DBG_USE_ABORT
38
 
# endif
39
 
 
40
 
# ifndef UT_DBG_USE_ABORT
41
 
/* A null pointer that will be dereferenced to trigger a memory trap */
42
 
extern ulint*   ut_dbg_null_ptr;
43
 
# endif
44
 
 
45
 
# if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
46
 
/* Flag for indicating that all threads should stop.  This will be set
47
 
by ut_dbg_assertion_failed(). */
48
 
extern ibool    ut_dbg_stop_threads;
49
 
 
50
 
/*****************************************************************
51
 
Stop a thread after assertion failure. */
52
 
 
53
 
void
54
 
ut_dbg_stop_thread(
55
 
/*===============*/
56
 
        const char*     file,
57
 
        ulint           line);
58
 
# endif
59
 
 
60
 
# ifdef UT_DBG_USE_ABORT
61
 
/* Abort the execution. */
62
 
#  define UT_DBG_PANIC abort()
63
 
/* Stop threads (null operation) */
64
 
#  define UT_DBG_STOP while (0)
65
 
# else /* UT_DBG_USE_ABORT */
66
 
/* Abort the execution. */
67
 
#  define UT_DBG_PANIC                                  \
68
 
        if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
69
 
/* Stop threads in ut_a(). */
70
 
#  define UT_DBG_STOP do                                                \
71
 
        if (UNIV_UNLIKELY(ut_dbg_stop_threads)) {               \
72
 
                ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
73
 
        } while (0)
74
 
# endif /* UT_DBG_USE_ABORT */
75
 
 
76
 
/* Abort execution if EXPR does not evaluate to nonzero. */
77
 
#define ut_a(EXPR) do {                                         \
78
 
        if (UT_DBG_FAIL(EXPR)) {                                \
79
 
                ut_dbg_assertion_failed(#EXPR,                  \
80
 
                                __FILE__, (ulint) __LINE__);    \
81
 
                UT_DBG_PANIC;                                   \
82
 
        }                                                       \
83
 
        UT_DBG_STOP;                                            \
84
 
} while (0)
85
 
 
86
 
/* Abort execution. */
87
 
#define ut_error do {                                           \
88
 
        ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
89
 
        UT_DBG_PANIC;                                           \
90
 
} while (0)
91
 
 
92
 
#ifdef UNIV_DEBUG
93
 
#define ut_ad(EXPR)     ut_a(EXPR)
94
 
#define ut_d(EXPR)      do {EXPR;} while (0)
95
 
#else
96
 
#define ut_ad(EXPR)
97
 
#define ut_d(EXPR)
98
 
#endif
99
 
 
100
 
#define UT_NOT_USED(A)  A = A
101
 
 
102
 
#endif