1 /***************************************************************************** 2 3 Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. 4 Copyright (c) 2013, 2022, MariaDB Corporation. 5 Copyright (c) 2008, Google 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 This program is free software; you can redistribute it and/or modify it under 14 the terms of the GNU General Public License as published by the Free Software 15 Foundation; version 2 of the License. 16 17 This program is distributed in the hope that it will be useful, but WITHOUT 18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 20 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 Street, Fifth Floor, Boston, MA 02110-1335 USA 24 25 *****************************************************************************/ 26 27 /***********************************************************************//** 28 @file include/univ.i 29 Version control for database, common definitions, and include files 30 31 Created 1/20/1994 Heikki Tuuri 32 ****************************************************************************/ 33 34 #ifndef univ_i 35 #define univ_i 36 37 /* aux macros to convert M into "123" (string) if M is defined like 38 #define M 123 */ 39 #define _IB_TO_STR(s) #s 40 #define IB_TO_STR(s) _IB_TO_STR(s) 41 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 (MYSQL_VERSION_MAJOR << 8 | MYSQL_VERSION_MINOR) 50 51 #define INNODB_VERSION_STR \ 52 IB_TO_STR(MYSQL_VERSION_MAJOR) "." \ 53 IB_TO_STR(MYSQL_VERSION_MINOR) "." \ 54 IB_TO_STR(MYSQL_VERSION_PATCH) 55 56 /** How far ahead should we tell the service manager the timeout 57 (time in seconds) */ 58 #define INNODB_EXTEND_TIMEOUT_INTERVAL 30 59 60 #ifdef MYSQL_DYNAMIC_PLUGIN 61 /* In the dynamic plugin, redefine some externally visible symbols 62 in order not to conflict with the symbols of a builtin InnoDB. */ 63 64 /* Rename all C++ classes that contain virtual functions, because we 65 have not figured out how to apply the visibility=hidden attribute to 66 the virtual method table (vtable) in GCC 3. */ 67 # define ha_innobase ha_innodb 68 #endif /* MYSQL_DYNAMIC_PLUGIN */ 69 70 #if defined(_WIN32) 71 # include <windows.h> 72 #endif /* _WIN32 */ 73 74 /* Include a minimum number of SQL header files so that few changes 75 made in SQL code cause a complete InnoDB rebuild. These headers are 76 used throughout InnoDB but do not include too much themselves. They 77 support cross-platform development and expose comonly used SQL names. */ 78 79 #include <my_global.h> 80 81 /* JAN: TODO: missing 5.7 header */ 82 #ifdef HAVE_MY_THREAD_H 83 //# include <my_thread.h> 84 #endif 85 86 #ifndef UNIV_INNOCHECKSUM 87 # include <m_string.h> 88 # include <mysqld_error.h> 89 #endif /* !UNIV_INNOCHECKSUM */ 90 91 /* Include <sys/stat.h> to get S_I... macros defined for os0file.cc */ 92 #include <sys/stat.h> 93 94 #ifndef _WIN32 95 # include <sched.h> 96 # include "my_config.h" 97 #endif 98 99 #include <stdint.h> 100 #include <inttypes.h> 101 #ifdef HAVE_UNISTD_H 102 #include <unistd.h> 103 #endif 104 105 #include "my_pthread.h" 106 107 /* Following defines are to enable performance schema 108 instrumentation in each of five InnoDB modules if 109 HAVE_PSI_INTERFACE is defined. */ 110 #ifdef HAVE_PSI_INTERFACE 111 # define UNIV_PFS_MUTEX 112 # define UNIV_PFS_RWLOCK 113 # define UNIV_PFS_IO 114 # define UNIV_PFS_THREAD 115 116 // JAN: TODO: MySQL 5.7 PSI 117 // # include "mysql/psi/psi.h" /* HAVE_PSI_MEMORY_INTERFACE */ 118 # ifdef HAVE_PSI_MEMORY_INTERFACE 119 # define UNIV_PFS_MEMORY 120 # endif /* HAVE_PSI_MEMORY_INTERFACE */ 121 122 /* There are mutexes/rwlocks that we want to exclude from 123 instrumentation even if their corresponding performance schema 124 define is set. And this PFS_NOT_INSTRUMENTED is used 125 as the key value to identify those objects that would 126 be excluded from instrumentation. */ 127 # define PFS_NOT_INSTRUMENTED ULINT32_UNDEFINED 128 129 # define PFS_IS_INSTRUMENTED(key) ((key) != PFS_NOT_INSTRUMENTED) 130 131 /* JAN: TODO: missing 5.7 header */ 132 #ifdef HAVE_PFS_THREAD_PROVIDER_H 133 /* For PSI_MUTEX_CALL() and similar. */ 134 #include "pfs_thread_provider.h" 135 #endif 136 137 #include "mysql/psi/mysql_thread.h" 138 /* For PSI_FILE_CALL(). */ 139 /* JAN: TODO: missing 5.7 header */ 140 #ifdef HAVE_PFS_FILE_PROVIDER_H 141 #include "pfs_file_provider.h" 142 #endif 143 144 #include "mysql/psi/mysql_file.h" 145 146 #endif /* HAVE_PSI_INTERFACE */ 147 148 #ifdef _WIN32 149 # define YY_NO_UNISTD_H 1 150 /* VC++ tries to optimise for size by default, from V8+. The size of 151 the pointer to member depends on whether the type is defined before the 152 compiler sees the type in the translation unit. This default behaviour 153 can cause the pointer to be a different size in different translation 154 units, depending on the above rule. We force optimise for size behaviour 155 for all cases. This is used by ut0lst.h related code. */ 156 # pragma pointers_to_members(full_generality, multiple_inheritance) 157 #endif /* _WIN32 */ 158 159 /* DEBUG VERSION CONTROL 160 ===================== */ 161 162 /* When this macro is defined then additional test functions will be 163 compiled. These functions live at the end of each relevant source file 164 and have "test_" prefix. These functions can be called from the end of 165 innodb_init() or they can be called from gdb after srv_start() has executed 166 using the call command. */ 167 /* 168 #define UNIV_COMPILE_TEST_FUNCS 169 #define UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR 170 #define UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH 171 #define UNIV_ENABLE_UNIT_TEST_DICT_STATS 172 #define UNIV_ENABLE_UNIT_TEST_ROW_RAW_FORMAT_INT 173 */ 174 175 #ifdef DBUG_OFF 176 # undef UNIV_DEBUG 177 #elif !defined UNIV_DEBUG 178 # define UNIV_DEBUG 179 #endif 180 181 #if 0 182 #define UNIV_DEBUG_PRINT /* Enable the compilation of 183 some debug print functions */ 184 #define UNIV_AHI_DEBUG /* Enable adaptive hash index 185 debugging without UNIV_DEBUG */ 186 #define UNIV_BUF_DEBUG /* Enable buffer pool 187 debugging without UNIV_DEBUG */ 188 #define UNIV_BLOB_LIGHT_DEBUG /* Enable off-page column 189 debugging without UNIV_DEBUG */ 190 #define UNIV_DEBUG_LOCK_VALIDATE /* Enable 191 ut_ad(lock_rec_validate_page()) 192 assertions. */ 193 #define UNIV_LRU_DEBUG /* debug the buffer pool LRU */ 194 #define UNIV_HASH_DEBUG /* debug HASH_ macros */ 195 #define UNIV_LOG_LSN_DEBUG /* write LSN to the redo log; 196 this will break redo log file compatibility, but it may be useful when 197 debugging redo log application problems. */ 198 #define UNIV_IBUF_DEBUG /* debug the insert buffer */ 199 #define UNIV_PERF_DEBUG /* debug flag that enables 200 light weight performance 201 related stuff. */ 202 #define UNIV_SEARCH_PERF_STAT /* statistics for the 203 adaptive hash index */ 204 #define UNIV_SRV_PRINT_LATCH_WAITS /* enable diagnostic output 205 in sync0sync.cc */ 206 #define UNIV_BTR_PRINT /* enable functions for 207 printing B-trees */ 208 #define UNIV_ZIP_DEBUG /* extensive consistency checks 209 for compressed pages */ 210 #define UNIV_ZIP_COPY /* call page_zip_copy_recs() 211 more often */ 212 #define UNIV_AIO_DEBUG /* prints info about 213 submitted and reaped AIO 214 requests to the log. */ 215 #define UNIV_STATS_DEBUG /* prints various stats 216 related debug info from 217 dict0stats.c */ 218 #define FTS_INTERNAL_DIAG_PRINT /* FTS internal debugging 219 info output */ 220 #endif 221 222 #define UNIV_BTR_DEBUG /* check B-tree links */ 223 #define UNIV_LIGHT_MEM_DEBUG /* light memory debugging */ 224 225 // #define UNIV_SQL_DEBUG 226 227 /* Linkage specifier for non-static InnoDB symbols (variables and functions) 228 that are only referenced from within InnoDB, not from MySQL. We disable the 229 GCC visibility directive on all Sun operating systems because there is no 230 easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ 231 #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(sun) || defined(__INTEL_COMPILER) 232 # define UNIV_INTERN __attribute__((visibility ("hidden"))) 233 #else 234 # define UNIV_INTERN 235 #endif 236 237 #if defined(__GNUC__) && (__GNUC__ >= 11) 238 # define ATTRIBUTE_ACCESS(X) __attribute__((access X)) 239 #else 240 # define ATTRIBUTE_ACCESS(X) 241 #endif 242 243 #ifndef MY_ATTRIBUTE 244 #if defined(__GNUC__) 245 # define MY_ATTRIBUTE(A) __attribute__(A) 246 #else 247 # define MY_ATTRIBUTE(A) 248 #endif 249 #endif 250 251 #define UNIV_INLINE static inline 252 253 #define UNIV_WORD_SIZE SIZEOF_SIZE_T 254 255 /** The following alignment is used in memory allocations in memory heap 256 management to ensure correct alignment for doubles etc. */ 257 #define UNIV_MEM_ALIGNMENT 8U 258 259 /* 260 DATABASE VERSION CONTROL 261 ======================== 262 */ 263 264 #ifdef HAVE_LZO 265 #define IF_LZO(A,B) A 266 #else 267 #define IF_LZO(A,B) B 268 #endif 269 270 #ifdef HAVE_LZ4 271 #define IF_LZ4(A,B) A 272 #else 273 #define IF_LZ4(A,B) B 274 #endif 275 276 #ifdef HAVE_LZMA 277 #define IF_LZMA(A,B) A 278 #else 279 #define IF_LZMA(A,B) B 280 #endif 281 282 #ifdef HAVE_BZIP2 283 #define IF_BZIP2(A,B) A 284 #else 285 #define IF_BZIP2(A,B) B 286 #endif 287 288 #ifdef HAVE_SNAPPY 289 #define IF_SNAPPY(A,B) A 290 #else 291 #define IF_SNAPPY(A,B) B 292 #endif 293 294 #if defined (HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32) 295 #define IF_PUNCH_HOLE(A,B) A 296 #else 297 #define IF_PUNCH_HOLE(A,B) B 298 #endif 299 300 /** log2 of smallest compressed page size (1<<10 == 1024 bytes) 301 Note: This must never change! */ 302 #define UNIV_ZIP_SIZE_SHIFT_MIN 10U 303 304 /** log2 of largest compressed page size (1<<14 == 16384 bytes). 305 A compressed page directory entry reserves 14 bits for the start offset 306 and 2 bits for flags. This limits the uncompressed page size to 16k. 307 */ 308 #define UNIV_ZIP_SIZE_SHIFT_MAX 14U 309 310 /* Define the Min, Max, Default page sizes. */ 311 /** Minimum Page Size Shift (power of 2) */ 312 #define UNIV_PAGE_SIZE_SHIFT_MIN 12U 313 /** log2 of largest page size (1<<16 == 64436 bytes). */ 314 /** Maximum Page Size Shift (power of 2) */ 315 #define UNIV_PAGE_SIZE_SHIFT_MAX 16U 316 /** log2 of default page size (1<<14 == 16384 bytes). */ 317 /** Default Page Size Shift (power of 2) */ 318 #define UNIV_PAGE_SIZE_SHIFT_DEF 14U 319 /** Original 16k InnoDB Page Size Shift, in case the default changes */ 320 #define UNIV_PAGE_SIZE_SHIFT_ORIG 14U 321 /** Original 16k InnoDB Page Size as an ssize (log2 - 9) */ 322 #define UNIV_PAGE_SSIZE_ORIG (UNIV_PAGE_SIZE_SHIFT_ORIG - 9U) 323 324 /** Minimum page size InnoDB currently supports. */ 325 #define UNIV_PAGE_SIZE_MIN (1U << UNIV_PAGE_SIZE_SHIFT_MIN) 326 /** Maximum page size InnoDB currently supports. */ 327 #define UNIV_PAGE_SIZE_MAX (1U << UNIV_PAGE_SIZE_SHIFT_MAX) 328 /** Default page size for InnoDB tablespaces. */ 329 #define UNIV_PAGE_SIZE_DEF (1U << UNIV_PAGE_SIZE_SHIFT_DEF) 330 /** Original 16k page size for InnoDB tablespaces. */ 331 #define UNIV_PAGE_SIZE_ORIG (1U << UNIV_PAGE_SIZE_SHIFT_ORIG) 332 333 /** Smallest compressed page size */ 334 #define UNIV_ZIP_SIZE_MIN (1U << UNIV_ZIP_SIZE_SHIFT_MIN) 335 336 /** Largest compressed page size */ 337 #define UNIV_ZIP_SIZE_MAX (1U << UNIV_ZIP_SIZE_SHIFT_MAX) 338 339 /** Largest possible ssize for an uncompressed page. 340 (The convention 'ssize' is used for 'log2 minus 9' or the number of 341 shifts starting with 512.) 342 This max number varies depending on srv_page_size. */ 343 #define UNIV_PAGE_SSIZE_MAX \ 344 ulint(srv_page_size_shift - UNIV_ZIP_SIZE_SHIFT_MIN + 1U) 345 346 /** Smallest possible ssize for an uncompressed page. */ 347 #define UNIV_PAGE_SSIZE_MIN \ 348 ulint(UNIV_PAGE_SIZE_SHIFT_MIN - UNIV_ZIP_SIZE_SHIFT_MIN + 1U) 349 350 /** Maximum number of parallel threads in a parallelized operation */ 351 #define UNIV_MAX_PARALLELISM 32 352 353 /** This is the "mbmaxlen" for my_charset_filename (defined in 354 strings/ctype-utf8.c), which is used to encode File and Database names. */ 355 #define FILENAME_CHARSET_MAXNAMLEN 5 356 357 /** The maximum length of an encode table name in bytes. The max 358 table and database names are NAME_CHAR_LEN (64) characters. After the 359 encoding, the max length would be NAME_CHAR_LEN (64) * 360 FILENAME_CHARSET_MAXNAMLEN (5) = 320 bytes. The number does not include a 361 terminating '\0'. InnoDB can handle longer names internally */ 362 #define MAX_TABLE_NAME_LEN 320 363 364 /** The maximum length of a database name. Like MAX_TABLE_NAME_LEN this is 365 the MySQL's NAME_LEN, see check_and_convert_db_name(). */ 366 #define MAX_DATABASE_NAME_LEN MAX_TABLE_NAME_LEN 367 368 /** MAX_FULL_NAME_LEN defines the full name path including the 369 database name and table name. In addition, 14 bytes is added for: 370 2 for surrounding quotes around table name 371 1 for the separating dot (.) 372 9 for the #mysql50# prefix */ 373 #define MAX_FULL_NAME_LEN \ 374 (MAX_TABLE_NAME_LEN + MAX_DATABASE_NAME_LEN + 14) 375 376 /** Maximum length of the compression alogrithm string. Currently we support 377 only (NONE | ZLIB | LZ4). */ 378 #define MAX_COMPRESSION_LEN 4 379 380 /** The maximum length in bytes that a database name can occupy when stored in 381 UTF8, including the terminating '\0', see dict_fs2utf8(). You must include 382 mysql_com.h if you are to use this macro. */ 383 #define MAX_DB_UTF8_LEN (NAME_LEN + 1) 384 385 /** The maximum length in bytes that a table name can occupy when stored in 386 UTF8, including the terminating '\0', see dict_fs2utf8(). You must include 387 mysql_com.h if you are to use this macro. */ 388 #define MAX_TABLE_UTF8_LEN (NAME_LEN + sizeof(srv_mysql50_table_name_prefix)) 389 390 /* 391 UNIVERSAL TYPE DEFINITIONS 392 ========================== 393 */ 394 395 /** Unsigned octet of bits */ 396 typedef unsigned char byte; 397 /** Machine-word-width unsigned integer */ 398 typedef size_t ulint; 399 /** Machine-word-width signed integer */ 400 typedef ssize_t lint; 401 402 /** ulint format for the printf() family of functions */ 403 #define ULINTPF "%zu" 404 /** ulint hexadecimal format for the printf() family of functions */ 405 #define ULINTPFx "%zx" 406 407 #ifdef _WIN32 408 /* Use the integer types and formatting strings defined in Visual Studio. */ 409 # define UINT32PF "%u" 410 # define INT64PF "%lld" 411 # define UINT64scan "llu" 412 # define UINT64PFx "%016llx" 413 #elif defined __APPLE__ 414 /* Apple prefers to call the 64-bit types 'long long' 415 in both 32-bit and 64-bit environments. */ 416 # define UINT32PF "%" PRIu32 417 # define INT64PF "%lld" 418 # define UINT64scan "llu" 419 # define UINT64PFx "%016llx" 420 #else 421 /* Use the integer types and formatting strings defined in the C99 standard. */ 422 # define UINT32PF "%" PRIu32 423 # define INT64PF "%" PRId64 424 # define UINT64scan PRIu64 425 # define UINT64PFx "%016" PRIx64 426 #endif 427 428 #ifdef UNIV_INNOCHECKSUM 429 extern bool strict_verify; 430 extern FILE* log_file; 431 extern uint32_t cur_page_num; 432 #endif /* UNIV_INNOCHECKSUM */ 433 434 typedef int64_t ib_int64_t; 435 typedef uint64_t ib_uint64_t; 436 typedef uint32_t ib_uint32_t; 437 438 #define UINT64PF "%" UINT64scan 439 #define IB_ID_FMT UINT64PF 440 441 /** Log sequence number (also used for redo log byte arithmetics) */ 442 typedef ib_uint64_t lsn_t; 443 444 /** The 'undefined' value for a ulint */ 445 #define ULINT_UNDEFINED ((ulint)(-1)) 446 447 #define ULONG_UNDEFINED ((ulong)(-1)) 448 449 /** The 'undefined' value for a ib_uint64_t */ 450 #define UINT64_UNDEFINED ((ib_uint64_t)(-1)) 451 452 /** The bitmask of 32-bit unsigned integer */ 453 #define ULINT32_MASK 0xFFFFFFFFU 454 /** The undefined 32-bit unsigned integer */ 455 #define ULINT32_UNDEFINED ULINT32_MASK 456 457 /** Maximum value for a ulint */ 458 #define ULINT_MAX ((ulint)(-2)) 459 460 /** Maximum value for ib_uint64_t */ 461 #define IB_UINT64_MAX ((ib_uint64_t) (~0ULL)) 462 463 /** The generic InnoDB system object identifier data type */ 464 typedef ib_uint64_t ib_id_t; 465 #define IB_ID_MAX (~(ib_id_t) 0) 466 #define IB_ID_FMT UINT64PF 467 468 #ifndef UINTMAX_MAX 469 #define UINTMAX_MAX IB_UINT64_MAX 470 #endif 471 /** This 'ibool' type is used within Innobase. Remember that different included 472 headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */ 473 #define ibool ulint 474 475 #ifndef TRUE 476 477 #define TRUE 1 478 #define FALSE 0 479 480 #endif 481 482 #define UNIV_NOTHROW 483 484 /** The following number as the length of a logical field means that the field 485 has the SQL NULL as its value. NOTE that because we assume that the length 486 of a field is a 32-bit integer when we store it, for example, to an undo log 487 on disk, we must have also this number fit in 32 bits, also in 64-bit 488 computers! */ 489 490 #define UNIV_SQL_NULL ULINT32_UNDEFINED 491 492 /** Lengths which are not UNIV_SQL_NULL, but bigger than the following 493 number indicate that a field contains a reference to an externally 494 stored part of the field in the tablespace. The length field then 495 contains the sum of the following flag and the locally stored len. */ 496 497 #define UNIV_EXTERN_STORAGE_FIELD (UNIV_SQL_NULL - UNIV_PAGE_SIZE_DEF) 498 499 #if defined(__GNUC__) 500 /* Tell the compiler that variable/function is unused. */ 501 # define UNIV_UNUSED MY_ATTRIBUTE ((unused)) 502 #else 503 # define UNIV_UNUSED 504 #endif /* CHECK FOR GCC VER_GT_2 */ 505 506 /* Some macros to improve branch prediction and reduce cache misses */ 507 #if defined(COMPILER_HINTS) && defined(__GNUC__) 508 /* Tell the compiler that 'expr' probably evaluates to 'constant'. */ 509 # define UNIV_EXPECT(expr,constant) __builtin_expect(expr, constant) 510 /* Tell the compiler that a pointer is likely to be NULL */ 511 # define UNIV_LIKELY_NULL(ptr) __builtin_expect((ptr) != 0, 0) 512 /* Minimize cache-miss latency by moving data at addr into a cache before 513 it is read. */ 514 # define UNIV_PREFETCH_R(addr) __builtin_prefetch(addr, 0, 3) 515 /* Minimize cache-miss latency by moving data at addr into a cache before 516 it is read or written. */ 517 # define UNIV_PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 3) 518 519 /* Sun Studio includes sun_prefetch.h as of version 5.9 */ 520 #elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) 521 522 # include <sun_prefetch.h> 523 524 # define UNIV_EXPECT(expr,value) (expr) 525 # define UNIV_LIKELY_NULL(expr) (expr) 526 527 # if defined(COMPILER_HINTS) 528 //# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many((void*) addr) 529 # define UNIV_PREFETCH_R(addr) ((void) 0) 530 # define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many(addr) 531 # else 532 # define UNIV_PREFETCH_R(addr) ((void) 0) 533 # define UNIV_PREFETCH_RW(addr) ((void) 0) 534 # endif /* COMPILER_HINTS */ 535 536 # elif defined __WIN__ && defined COMPILER_HINTS 537 # include <xmmintrin.h> 538 # define UNIV_EXPECT(expr,value) (expr) 539 # define UNIV_LIKELY_NULL(expr) (expr) 540 // __MM_HINT_T0 - (temporal data) 541 // prefetch data into all levels of the cache hierarchy. 542 # define UNIV_PREFETCH_R(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) 543 # define UNIV_PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) 544 #else 545 /* Dummy versions of the macros */ 546 # define UNIV_EXPECT(expr,value) (expr) 547 # define UNIV_LIKELY_NULL(expr) (expr) 548 # define UNIV_PREFETCH_R(addr) ((void) 0) 549 # define UNIV_PREFETCH_RW(addr) ((void) 0) 550 #endif 551 552 /* Tell the compiler that cond is likely to hold */ 553 #define UNIV_LIKELY(cond) UNIV_EXPECT(cond, TRUE) 554 /* Tell the compiler that cond is unlikely to hold */ 555 #define UNIV_UNLIKELY(cond) UNIV_EXPECT(cond, FALSE) 556 557 /* Compile-time constant of the given array's size. */ 558 #define UT_ARR_SIZE(a) (sizeof(a) / sizeof((a)[0])) 559 560 /* The return type from a thread's start function differs between Unix and 561 Windows, so define a typedef for it and a macro to use at the end of such 562 functions. */ 563 564 #ifdef _WIN32 565 typedef DWORD os_thread_ret_t; 566 # define OS_THREAD_DUMMY_RETURN return(0) 567 # define OS_PATH_SEPARATOR '\\' 568 # define OS_PATH_SEPARATOR_ALT '/' 569 #else 570 typedef void* os_thread_ret_t; 571 # define OS_THREAD_DUMMY_RETURN return(NULL) 572 # define OS_PATH_SEPARATOR '/' 573 # define OS_PATH_SEPARATOR_ALT '\\' 574 #endif 575 576 #include <stdio.h> 577 #include "db0err.h" 578 #include "ut0dbg.h" 579 #include "ut0lst.h" 580 #include "ut0ut.h" 581 #include "sync0types.h" 582 583 extern ulong srv_page_size_shift; 584 extern ulong srv_page_size; 585 586 static const size_t UNIV_SECTOR_SIZE = 512; 587 588 /* Dimension of spatial object we support so far. It has its root in 589 myisam/sp_defs.h. We only support 2 dimension data */ 590 #define SPDIMS 2 591 592 #endif 593