~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/univ.i

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
4
 
Copyright (c) 2008, Google Inc.
5
 
Copyright (c) 2009, Sun Microsystems, Inc.
6
 
 
7
 
Portions of this file contain modifications contributed and copyrighted by
8
 
Google, Inc. Those modifications are gratefully acknowledged and are described
9
 
briefly in the InnoDB documentation. The contributions by Google are
10
 
incorporated with their permission, and subject to the conditions contained in
11
 
the file COPYING.Google.
12
 
 
13
 
Portions of this file contain modifications contributed and copyrighted by
14
 
Sun Microsystems, Inc. Those modifications are gratefully acknowledged and
15
 
are described briefly in the InnoDB documentation. The contributions by
16
 
Sun Microsystems are incorporated with their permission, and subject to the
17
 
conditions contained in the file COPYING.Sun_Microsystems.
18
 
 
19
 
This program is free software; you can redistribute it and/or modify it under
20
 
the terms of the GNU General Public License as published by the Free Software
21
 
Foundation; version 2 of the License.
22
 
 
23
 
This program is distributed in the hope that it will be useful, but WITHOUT
24
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
25
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26
 
 
27
 
You should have received a copy of the GNU General Public License along with
28
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
29
 
St, Fifth Floor, Boston, MA 02110-1301 USA
30
 
 
31
 
*****************************************************************************/
32
 
 
33
 
/***********************************************************************//**
34
 
@file include/univ.i
35
 
Version control for database, common definitions, and include files
36
 
 
37
 
Created 1/20/1994 Heikki Tuuri
38
 
****************************************************************************/
39
 
 
40
 
#ifndef univ_i
41
 
#define univ_i
42
 
 
43
 
#include "config.h"
44
 
 
45
 
#ifndef __cplusplus
46
 
# include <stdbool.h>
47
 
#endif
48
 
 
49
 
#ifdef UNIV_HOTBACKUP
50
 
#include "hb_univ.i"
51
 
#endif /* UNIV_HOTBACKUP */
52
 
 
53
 
#define INNODB_VERSION_MAJOR    1
54
 
#define INNODB_VERSION_MINOR    1
55
 
#define INNODB_VERSION_BUGFIX   3
56
 
 
57
 
/* The following is the InnoDB version as shown in
58
 
SELECT plugin_version FROM information_schema.plugins;
59
 
calculated in make_version_string() in sql/sql_show.cc like this:
60
 
"version >> 8" . "version & 0xff"
61
 
because the version is shown with only one dot, we skip the last
62
 
component, i.e. we show M.N.P as M.N */
63
 
#define INNODB_VERSION_SHORT    \
64
 
        (INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
65
 
 
66
 
/* auxiliary macros to help creating the version as string */
67
 
#define __INNODB_VERSION(a, b, c)       (#a "." #b "." #c)
68
 
#define _INNODB_VERSION(a, b, c)        __INNODB_VERSION(a, b, c)
69
 
 
70
 
#define INNODB_VERSION_STR                      \
71
 
        _INNODB_VERSION(INNODB_VERSION_MAJOR,   \
72
 
                        INNODB_VERSION_MINOR,   \
73
 
                        INNODB_VERSION_BUGFIX)
74
 
 
75
 
#define REFMAN "http://dev.mysql.com/doc/refman/5.1/en/"
76
 
 
77
 
#ifdef MYSQL_DYNAMIC_PLUGIN
78
 
/* In the dynamic plugin, redefine some externally visible symbols
79
 
in order not to conflict with the symbols of a builtin InnoDB. */
80
 
 
81
 
/* Rename all C++ classes that contain virtual functions, because we
82
 
have not figured out how to apply the visibility=hidden attribute to
83
 
the virtual method table (vtable) in GCC 3. */
84
 
# define ha_innobase ha_innodb
85
 
#endif /* MYSQL_DYNAMIC_PLUGIN */
86
 
 
87
 
#if (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)) && !defined(MYSQL_SERVER) && !defined(__WIN__)
88
 
# undef __WIN__
89
 
# define __WIN__
90
 
 
91
 
# include <windows.h>
92
 
 
93
 
# ifdef _NT_
94
 
#  define __NT__
95
 
# endif
96
 
 
97
 
#else
98
 
/* The defines used with MySQL */
99
 
 
100
 
/* Include two header files from MySQL to make the Unix flavor used
101
 
in compiling more Posix-compatible. These headers also define __WIN__
102
 
if we are compiling on Windows. */
103
 
 
104
 
# if !defined(BUILD_DRIZZLE)
105
 
#  ifndef UNIV_HOTBACKUP
106
 
#   include <my_global.h>
107
 
#   include <my_pthread.h>
108
 
#  endif /* UNIV_HOTBACKUP */
109
 
# endif
110
 
 
111
 
#ifdef HAVE_PTHREAD
112
 
#include <pthread.h>
113
 
#endif
114
 
 
115
 
/* Include <sys/stat.h> to get S_I... macros defined for os0file.c */
116
 
# include <sys/stat.h>
117
 
# if !defined(__WIN__) 
118
 
#  include <sys/mman.h> /* mmap() for os0proc.c */
119
 
# endif
120
 
 
121
 
/* Include the header file generated by GNU autoconf */
122
 
# if !defined(__WIN__) && !defined(BUILD_DRIZZLE)
123
 
#  ifndef UNIV_HOTBACKUP
124
 
#   include <config.h>
125
 
#  endif /* UNIV_HOTBACKUP */
126
 
# endif
127
 
 
128
 
# ifdef HAVE_SCHED_H
129
 
#  include <sched.h>
130
 
# endif
131
 
 
132
 
/* We only try to do explicit inlining of functions with gcc and
133
 
Sun Studio */
134
 
 
135
 
# if !defined(__GNUC__) && !(defined(__SUNPRO_C) || defined(__SUNPRO_CC))
136
 
#  undef  UNIV_MUST_NOT_INLINE                  /* Remove compiler warning */
137
 
#  define UNIV_MUST_NOT_INLINE
138
 
# endif
139
 
 
140
 
# if defined(__GNUC__)
141
 
#  define UNIV_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
142
 
#else
143
 
#  define UNIV_WARN_UNUSED_RESULT
144
 
#endif
145
 
 
146
 
# ifdef HAVE_PREAD
147
 
#  define HAVE_PWRITE
148
 
# endif
149
 
 
150
 
#endif /* #if (defined(WIN32) || ... */
151
 
 
152
 
/* Following defines are to enable performance schema
153
 
instrumentation in each of four InnoDB modules if
154
 
HAVE_PSI_INTERFACE is defined. */
155
 
#ifdef HAVE_PSI_INTERFACE
156
 
# define UNIV_PFS_MUTEX
157
 
# define UNIV_PFS_RWLOCK
158
 
/* For I/O instrumentation, performance schema rely
159
 
on a native descriptor to identify the file, this
160
 
descriptor could conflict with our OS level descriptor.
161
 
Disable IO instrumentation on Windows until this is
162
 
resolved */
163
 
# ifndef __WIN__
164
 
#  define UNIV_PFS_IO
165
 
# endif
166
 
# define UNIV_PFS_THREAD
167
 
#endif /* HAVE_PSI_INTERFACE */
168
 
 
169
 
/*                      DEBUG VERSION CONTROL
170
 
                        ===================== */
171
 
 
172
 
/* The following flag will make InnoDB to initialize
173
 
all memory it allocates to zero. It hides Purify
174
 
warnings about reading unallocated memory unless
175
 
memory is read outside the allocated blocks. */
176
 
/*
177
 
#define UNIV_INIT_MEM_TO_ZERO
178
 
*/
179
 
 
180
 
/* When this macro is defined then additional test functions will be
181
 
compiled. These functions live at the end of each relevant source file
182
 
and have "test_" prefix. These functions are not called from anywhere in
183
 
the code, they can be called from gdb after
184
 
innobase_start_or_create_for_mysql() has executed using the call
185
 
command. Not tested on Windows. */
186
 
/*
187
 
#define UNIV_COMPILE_TEST_FUNCS
188
 
*/
189
 
 
190
 
#if defined HAVE_VALGRIND
191
 
# define UNIV_DEBUG_VALGRIND
192
 
#endif /* HAVE_VALGRIND */
193
 
#if 0
194
 
#define UNIV_DEBUG_VALGRIND                     /* Enable extra
195
 
                                                Valgrind instrumentation */
196
 
#define UNIV_DEBUG_PRINT                        /* Enable the compilation of
197
 
                                                some debug print functions */
198
 
#define UNIV_AHI_DEBUG                          /* Enable adaptive hash index
199
 
                                                debugging without UNIV_DEBUG */
200
 
#define UNIV_BUF_DEBUG                          /* Enable buffer pool
201
 
                                                debugging without UNIV_DEBUG */
202
 
#define UNIV_DEBUG                              /* Enable ut_ad() assertions
203
 
                                                and disable UNIV_INLINE */
204
 
#define UNIV_DEBUG_LOCK_VALIDATE                /* Enable
205
 
                                                ut_ad(lock_rec_validate_page())
206
 
                                                assertions. */
207
 
#define UNIV_DEBUG_FILE_ACCESSES                /* Debug .ibd file access
208
 
                                                (field file_page_was_freed
209
 
                                                in buf_page_t) */
210
 
#define UNIV_LRU_DEBUG                          /* debug the buffer pool LRU */
211
 
#define UNIV_HASH_DEBUG                         /* debug HASH_ macros */
212
 
#define UNIV_LIST_DEBUG                         /* debug UT_LIST_ macros */
213
 
#define UNIV_LOG_LSN_DEBUG                      /* write LSN to the redo log;
214
 
this will break redo log file compatibility, but it may be useful when
215
 
debugging redo log application problems. */
216
 
#define UNIV_MEM_DEBUG                          /* detect memory leaks etc */
217
 
#define UNIV_IBUF_DEBUG                         /* debug the insert buffer */
218
 
#define UNIV_IBUF_COUNT_DEBUG                   /* debug the insert buffer;
219
 
this limits the database to IBUF_COUNT_N_SPACES and IBUF_COUNT_N_PAGES,
220
 
and the insert buffer must be empty when the database is started */
221
 
#define UNIV_SYNC_DEBUG                         /* debug mutex and latch
222
 
operations (very slow); also UNIV_DEBUG must be defined */
223
 
#define UNIV_SEARCH_DEBUG                       /* debug B-tree comparisons */
224
 
#define UNIV_SYNC_PERF_STAT                     /* operation counts for
225
 
                                                rw-locks and mutexes */
226
 
#define UNIV_SEARCH_PERF_STAT                   /* statistics for the
227
 
                                                adaptive hash index */
228
 
#define UNIV_SRV_PRINT_LATCH_WAITS              /* enable diagnostic output
229
 
                                                in sync0sync.c */
230
 
#define UNIV_BTR_PRINT                          /* enable functions for
231
 
                                                printing B-trees */
232
 
#define UNIV_ZIP_DEBUG                          /* extensive consistency checks
233
 
                                                for compressed pages */
234
 
#define UNIV_ZIP_COPY                           /* call page_zip_copy_recs()
235
 
                                                more often */
236
 
#define UNIV_AIO_DEBUG                          /* prints info about
237
 
                                                submitted and reaped AIO
238
 
                                                requests to the log. */
239
 
#endif
240
 
 
241
 
#define UNIV_BTR_DEBUG                          /* check B-tree links */
242
 
#define UNIV_LIGHT_MEM_DEBUG                    /* light memory debugging */
243
 
 
244
 
#ifdef HAVE_VALGRIND
245
 
/* The following sets all new allocated memory to zero before use:
246
 
this can be used to eliminate unnecessary Purify warnings, but note that
247
 
it also masks many bugs Purify could detect. For detailed Purify analysis it
248
 
is best to remove the define below and look through the warnings one
249
 
by one. */
250
 
#define UNIV_SET_MEM_TO_ZERO
251
 
#endif
252
 
 
253
 
/*
254
 
#define UNIV_SQL_DEBUG
255
 
#define UNIV_LOG_DEBUG
256
 
*/
257
 
                        /* the above option prevents forcing of log to disk
258
 
                        at a buffer page write: it should be tested with this
259
 
                        option off; also some ibuf tests are suppressed */
260
 
 
261
 
/* Linkage specifier for non-static InnoDB symbols (variables and functions)
262
 
that are only referenced from within InnoDB, not from MySQL */
263
 
#if defined(HAVE_ATTR_HIDDEN)
264
 
# define UNIV_INTERN __attribute__((visibility ("hidden")))
265
 
#else
266
 
# define UNIV_INTERN
267
 
#endif
268
 
 
269
 
#if (!defined(UNIV_DEBUG) && !defined(UNIV_MUST_NOT_INLINE))
270
 
/* Definition for inline version */
271
 
 
272
 
#ifdef __WIN__
273
 
# define UNIV_INLINE    __inline
274
 
#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
275
 
# define UNIV_INLINE static inline
276
 
#else
277
 
# define UNIV_INLINE static __inline__
278
 
#endif
279
 
 
280
 
#else
281
 
/* If we want to compile a noninlined version we use the following macro
282
 
definitions: */
283
 
 
284
 
#define UNIV_NONINL
285
 
#define UNIV_INLINE     UNIV_INTERN
286
 
 
287
 
#endif  /* UNIV_DEBUG */
288
 
 
289
 
#ifdef _WIN32
290
 
#define UNIV_WORD_SIZE          4
291
 
#elif defined(_WIN64)
292
 
#define UNIV_WORD_SIZE          8
293
 
#else
294
 
/* MySQL config.h generated by GNU autoconf will define SIZEOF_LONG in Posix */
295
 
#define UNIV_WORD_SIZE          SIZEOF_LONG
296
 
#endif
297
 
 
298
 
/* The following alignment is used in memory allocations in memory heap
299
 
management to ensure correct alignment for doubles etc. */
300
 
#define UNIV_MEM_ALIGNMENT      8
301
 
 
302
 
/* The following alignment is used in aligning lints etc. */
303
 
#define UNIV_WORD_ALIGNMENT     UNIV_WORD_SIZE
304
 
 
305
 
/* The maximum length of a table name. This is the MySQL limit and is
306
 
defined in mysql_com.h like NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN, the
307
 
number does not include a terminating '\0'. InnoDB probably can handle
308
 
longer names internally */
309
 
#define MAX_TABLE_NAME_LEN      192
310
 
 
311
 
/*
312
 
                        DATABASE VERSION CONTROL
313
 
                        ========================
314
 
*/
315
 
 
316
 
/* The 2-logarithm of UNIV_PAGE_SIZE: */
317
 
#define UNIV_PAGE_SIZE_SHIFT    14
318
 
/* The universal page size of the database */
319
 
#define UNIV_PAGE_SIZE          (1 << UNIV_PAGE_SIZE_SHIFT)
320
 
 
321
 
/* Maximum number of parallel threads in a parallelized operation */
322
 
#define UNIV_MAX_PARALLELISM    32
323
 
 
324
 
/* The maximum length of a table name. This is the MySQL limit and is
325
 
defined in mysql_com.h like NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN, the
326
 
number does not include a terminating '\0'. InnoDB probably can handle
327
 
longer names internally */
328
 
#define MAX_TABLE_NAME_LEN      192
329
 
 
330
 
/*
331
 
                        UNIVERSAL TYPE DEFINITIONS
332
 
                        ==========================
333
 
*/
334
 
 
335
 
/* Note that inside MySQL 'byte' is defined as char on Linux! */
336
 
#define byte                    unsigned char
337
 
 
338
 
/* Define an unsigned integer type that is exactly 32 bits. */
339
 
 
340
 
#if SIZEOF_INT == 4
341
 
typedef unsigned int            ib_uint32_t;
342
 
#elif SIZEOF_LONG == 4
343
 
typedef unsigned long           ib_uint32_t;
344
 
#else
345
 
#error "Neither int or long is 4 bytes"
346
 
#endif
347
 
 
348
 
/* Another basic type we use is unsigned long integer which should be equal to
349
 
the word size of the machine, that is on a 32-bit platform 32 bits, and on a
350
 
64-bit platform 64 bits. We also give the printf format for the type as a
351
 
macro ULINTPF. */
352
 
 
353
 
#ifdef _WIN64
354
 
typedef unsigned __int64        ulint;
355
 
#define ULINTPF                 "%I64u"
356
 
typedef __int64                 lint;
357
 
#else
358
 
typedef unsigned long int       ulint;
359
 
#define ULINTPF                 "%lu"
360
 
typedef long int                lint;
361
 
#endif
362
 
 
363
 
#ifdef __WIN__
364
 
typedef __int64                 ib_int64_t;
365
 
typedef unsigned __int64        ib_uint64_t;
366
 
#elif !defined(UNIV_HOTBACKUP)
367
 
/* Note: longlong and ulonglong come from MySQL headers. */
368
 
# if defined(BUILD_DRIZZLE)
369
 
typedef int64_t                 ib_int64_t;
370
 
typedef uint64_t                ib_uint64_t;
371
 
typedef uint16_t                uint16;
372
 
typedef bool                    my_bool;
373
 
typedef uint32_t                uint32;
374
 
# else
375
 
typedef longlong                ib_int64_t;
376
 
typedef ulonglong               ib_uint64_t;
377
 
#define PRIu64                  "llu"
378
 
# endif // DRIZZLE
379
 
#endif
380
 
 
381
 
#ifndef UNIV_HOTBACKUP
382
 
typedef unsigned long long int  ullint;
383
 
#endif /* UNIV_HOTBACKUP */
384
 
 
385
 
#ifndef __WIN__
386
 
#if SIZEOF_LONG != SIZEOF_VOIDP
387
 
#error "Error: InnoDB's ulint must be of the same size as void*"
388
 
#endif
389
 
#endif
390
 
 
391
 
/* The 'undefined' value for a ulint */
392
 
#define ULINT_UNDEFINED         ((ulint)(-1))
393
 
 
394
 
/** The bitmask of 32-bit unsigned integer */
395
 
#define ULINT32_MASK            0xFFFFFFFF
396
 
/* The undefined 32-bit unsigned integer */
397
 
#define ULINT32_UNDEFINED       ULINT32_MASK
398
 
 
399
 
/* Maximum value for a ulint */
400
 
#define ULINT_MAX               ((ulint)(-2))
401
 
 
402
 
/* Maximum value for ib_uint64_t */
403
 
#define IB_ULONGLONG_MAX        ((ib_uint64_t) (~0ULL))
404
 
 
405
 
/** The generic InnoDB system object identifier data type */
406
 
typedef ib_uint64_t     ib_id_t;
407
 
 
408
 
/* This 'ibool' type is used within Innobase. Remember that different included
409
 
headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */
410
 
#define ibool                   ulint
411
 
 
412
 
#ifndef TRUE
413
 
 
414
 
#define TRUE    1
415
 
#define FALSE   0
416
 
 
417
 
#endif
418
 
 
419
 
/* The following number as the length of a logical field means that the field
420
 
has the SQL NULL as its value. NOTE that because we assume that the length
421
 
of a field is a 32-bit integer when we store it, for example, to an undo log
422
 
on disk, we must have also this number fit in 32 bits, also in 64-bit
423
 
computers! */
424
 
 
425
 
#define UNIV_SQL_NULL ULINT32_UNDEFINED
426
 
 
427
 
/* Lengths which are not UNIV_SQL_NULL, but bigger than the following
428
 
number indicate that a field contains a reference to an externally
429
 
stored part of the field in the tablespace. The length field then
430
 
contains the sum of the following flag and the locally stored len. */
431
 
 
432
 
#define UNIV_EXTERN_STORAGE_FIELD (UNIV_SQL_NULL - UNIV_PAGE_SIZE)
433
 
 
434
 
/* Some macros to improve branch prediction and reduce cache misses */
435
 
#if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER)
436
 
/* Tell the compiler that 'expr' probably evaluates to 'constant'. */
437
 
# define UNIV_EXPECT(expr,constant) __builtin_expect(expr, constant)
438
 
/* Tell the compiler that a pointer is likely to be NULL */
439
 
# define UNIV_LIKELY_NULL(ptr) __builtin_expect((ulint) ptr, 0)
440
 
/* Minimize cache-miss latency by moving data at addr into a cache before
441
 
it is read. */
442
 
# define UNIV_PREFETCH_R(addr) __builtin_prefetch(addr, 0, 3)
443
 
/* Minimize cache-miss latency by moving data at addr into a cache before
444
 
it is read or written. */
445
 
# define UNIV_PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 3)
446
 
/* Sun Studio includes sun_prefetch.h as of version 5.9 */
447
 
#elif (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) \
448
 
       || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
449
 
# include <sun_prefetch.h>
450
 
#if __SUNPRO_C >= 0x550
451
 
# undef UNIV_INTERN
452
 
# define UNIV_INTERN __hidden
453
 
#endif /* __SUNPRO_C >= 0x550 */
454
 
/* Use sun_prefetch when compile with Sun Studio */
455
 
# define UNIV_EXPECT(expr,value) (expr)
456
 
# define UNIV_LIKELY_NULL(expr) (expr)
457
 
# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many((void *)(addr))
458
 
# define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many((void *)(addr))
459
 
#else
460
 
/* Dummy versions of the macros */
461
 
# define UNIV_EXPECT(expr,value) (expr)
462
 
# define UNIV_LIKELY_NULL(expr) (expr)
463
 
# define UNIV_PREFETCH_R(addr) ((void) 0)
464
 
# define UNIV_PREFETCH_RW(addr) ((void) 0)
465
 
#endif
466
 
/* Tell the compiler that cond is likely to hold */
467
 
#define UNIV_LIKELY(cond) UNIV_EXPECT(cond, TRUE)
468
 
/* Tell the compiler that cond is unlikely to hold */
469
 
#define UNIV_UNLIKELY(cond) UNIV_EXPECT(cond, FALSE)
470
 
 
471
 
/* Compile-time constant of the given array's size. */
472
 
#define UT_ARR_SIZE(a) (sizeof(a) / sizeof((a)[0]))
473
 
 
474
 
/* The return type from a thread's start function differs between Unix and
475
 
Windows, so define a typedef for it and a macro to use at the end of such
476
 
functions. */
477
 
 
478
 
#ifdef __WIN__
479
 
typedef ulint os_thread_ret_t;
480
 
#define OS_THREAD_DUMMY_RETURN return(0)
481
 
#else
482
 
typedef void* os_thread_ret_t;
483
 
#define OS_THREAD_DUMMY_RETURN return(NULL)
484
 
#endif
485
 
 
486
 
#include <stdio.h>
487
 
#include "ut0dbg.h"
488
 
#include "ut0ut.h"
489
 
#include "db0err.h"
490
 
#ifdef UNIV_DEBUG_VALGRIND
491
 
# include <valgrind/memcheck.h>
492
 
# define UNIV_MEM_VALID(addr, size) VALGRIND_MAKE_MEM_DEFINED(addr, size)
493
 
# define UNIV_MEM_INVALID(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
494
 
# define UNIV_MEM_FREE(addr, size) VALGRIND_MAKE_MEM_NOACCESS(addr, size)
495
 
# define UNIV_MEM_ALLOC(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
496
 
# define UNIV_MEM_DESC(addr, size, b) VALGRIND_CREATE_BLOCK(addr, size, b)
497
 
# define UNIV_MEM_UNDESC(b) VALGRIND_DISCARD(b)
498
 
# define UNIV_MEM_ASSERT_RW(addr, size) do {                            \
499
 
        const void* _p = (const void*) (ulint)                          \
500
 
                VALGRIND_CHECK_MEM_IS_DEFINED(addr, size);              \
501
 
        if (UNIV_LIKELY_NULL(_p))                                       \
502
 
                fprintf(stderr, "%s:%d: %p[%u] undefined at %ld\n",     \
503
 
                        __FILE__, __LINE__,                             \
504
 
                        (const void*) (addr), (unsigned) (size), (long) \
505
 
                        (((const char*) _p) - ((const char*) (addr)))); \
506
 
        } while (0)
507
 
# define UNIV_MEM_ASSERT_W(addr, size) do {                             \
508
 
        const void* _p = (const void*) (ulint)                          \
509
 
                VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, size);          \
510
 
        if (UNIV_LIKELY_NULL(_p))                                       \
511
 
                fprintf(stderr, "%s:%d: %p[%u] unwritable at %ld\n",    \
512
 
                        __FILE__, __LINE__,                             \
513
 
                        (const void*) (addr), (unsigned) (size), (long) \
514
 
                        (((const char*) _p) - ((const char*) (addr)))); \
515
 
        } while (0)
516
 
#else
517
 
# define UNIV_MEM_VALID(addr, size) do {} while(0)
518
 
# define UNIV_MEM_INVALID(addr, size) do {} while(0)
519
 
# define UNIV_MEM_FREE(addr, size) do {} while(0)
520
 
# define UNIV_MEM_ALLOC(addr, size) do {} while(0)
521
 
# define UNIV_MEM_DESC(addr, size, b) do {} while(0)
522
 
# define UNIV_MEM_UNDESC(b) do {} while(0)
523
 
# define UNIV_MEM_ASSERT_RW(addr, size) do {} while(0)
524
 
# define UNIV_MEM_ASSERT_W(addr, size) do {} while(0)
525
 
#endif
526
 
#define UNIV_MEM_ASSERT_AND_FREE(addr, size) do {       \
527
 
        UNIV_MEM_ASSERT_W(addr, size);                  \
528
 
        UNIV_MEM_FREE(addr, size);                      \
529
 
} while (0)
530
 
#define UNIV_MEM_ASSERT_AND_ALLOC(addr, size) do {      \
531
 
        UNIV_MEM_ASSERT_W(addr, size);                  \
532
 
        UNIV_MEM_ALLOC(addr, size);                     \
533
 
} while (0)
534
 
 
535
 
#endif