You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

555 lines
19 KiB

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