libmdbx 0.14.1.569 (2026-04-13T16:13:04+03:00)
One of the fastest compact embeddable key-value ACID storage engine without WAL.
Loading...
Searching...
No Matches
options.h
Go to the documentation of this file.
1
3
4/*******************************************************************************
5 *******************************************************************************
6 *
7 * BUILD TIME
8 *
9 * #### ##### ##### # #### # # ####
10 * # # # # # # # # ## # #
11 * # # # # # # # # # # # ####
12 * # # ##### # # # # # # # #
13 * # # # # # # # # ## # #
14 * #### # # # #### # # ####
15 *
16 *
17 */
18
19#pragma once
20
21#include "essentials.h"
22
26
28#define MDBX_OSX_WANNA_DURABILITY 0
30#define MDBX_OSX_WANNA_SPEED 1
31
32#ifndef MDBX_APPLE_SPEED_INSTEADOF_DURABILITY
35#define MDBX_APPLE_SPEED_INSTEADOF_DURABILITY MDBX_OSX_WANNA_DURABILITY
36#endif /* MDBX_APPLE_SPEED_INSTEADOF_DURABILITY */
37
39#ifndef MDBX_ENV_CHECKPID
40#if defined(MADV_DONTFORK) || defined(_WIN32) || defined(_WIN64)
41/* PID check could be omitted:
42 * - on Linux when madvise(MADV_DONTFORK) is available, i.e. after the fork()
43 * mapped pages will not be available for child process.
44 * - in Windows where fork() not available. */
45#define MDBX_ENV_CHECKPID 0
46#else
47#define MDBX_ENV_CHECKPID 1
48#endif
49#define MDBX_ENV_CHECKPID_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_ENV_CHECKPID)
50#elif !(MDBX_ENV_CHECKPID == 0 || MDBX_ENV_CHECKPID == 1)
51#error MDBX_ENV_CHECKPID must be defined as 0 or 1
52#else
53#define MDBX_ENV_CHECKPID_CONFIG MDBX_STRINGIFY(MDBX_ENV_CHECKPID)
54#endif /* MDBX_ENV_CHECKPID */
55
58#ifndef MDBX_TXN_CHECKOWNER
59#define MDBX_TXN_CHECKOWNER 1
60#define MDBX_TXN_CHECKOWNER_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_TXN_CHECKOWNER)
61#elif !(MDBX_TXN_CHECKOWNER == 0 || MDBX_TXN_CHECKOWNER == 1)
62#error MDBX_TXN_CHECKOWNER must be defined as 0 or 1
63#else
64#define MDBX_TXN_CHECKOWNER_CONFIG MDBX_STRINGIFY(MDBX_TXN_CHECKOWNER)
65#endif /* MDBX_TXN_CHECKOWNER */
66
68#ifndef MDBX_TRUST_RTC
69#if defined(__linux__) || defined(__gnu_linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
70#define MDBX_TRUST_RTC 0 /* a lot of embedded systems have a fake RTC */
71#else
72#define MDBX_TRUST_RTC 1
73#endif
74#define MDBX_TRUST_RTC_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_TRUST_RTC)
75#elif !(MDBX_TRUST_RTC == 0 || MDBX_TRUST_RTC == 1)
76#error MDBX_TRUST_RTC must be defined as 0 or 1
77#else
78#define MDBX_TRUST_RTC_CONFIG MDBX_STRINGIFY(MDBX_TRUST_RTC)
79#endif /* MDBX_TRUST_RTC */
80
82#ifndef MDBX_ENABLE_REFUND
83#define MDBX_ENABLE_REFUND 1
84#elif !(MDBX_ENABLE_REFUND == 0 || MDBX_ENABLE_REFUND == 1)
85#error MDBX_ENABLE_REFUND must be defined as 0 or 1
86#endif /* MDBX_ENABLE_REFUND */
87
89#ifndef MDBX_ENABLE_PROFGC
90#define MDBX_ENABLE_PROFGC 0
91#elif !(MDBX_ENABLE_PROFGC == 0 || MDBX_ENABLE_PROFGC == 1)
92#error MDBX_ENABLE_PROFGC must be defined as 0 or 1
93#endif /* MDBX_ENABLE_PROFGC */
94
96#ifndef MDBX_ENABLE_PGOP_STAT
97#define MDBX_ENABLE_PGOP_STAT 1
98#elif !(MDBX_ENABLE_PGOP_STAT == 0 || MDBX_ENABLE_PGOP_STAT == 1)
99#error MDBX_ENABLE_PGOP_STAT must be defined as 0 or 1
100#endif /* MDBX_ENABLE_PGOP_STAT */
101
103#ifndef MDBX_ENABLE_PGET_STAT
104#define MDBX_ENABLE_PGET_STAT 1
105#elif !(MDBX_ENABLE_PGET_STAT == 0 || MDBX_ENABLE_PGET_STAT == 1)
106#error MDBX_ENABLE_PGET_STAT must be defined as 0 or 1
107#endif /* MDBX_ENABLE_PGET_STAT */
108
111#ifndef MDBX_USE_MINCORE
112#if defined(MINCORE_INCORE) || !(defined(_WIN32) || defined(_WIN64))
113#define MDBX_USE_MINCORE 1
114#else
115#define MDBX_USE_MINCORE 0
116#endif
117#define MDBX_USE_MINCORE_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_USE_MINCORE)
118#elif !(MDBX_USE_MINCORE == 0 || MDBX_USE_MINCORE == 1)
119#error MDBX_USE_MINCORE must be defined as 0 or 1
120#endif /* MDBX_USE_MINCORE */
121
124#ifndef MDBX_ENABLE_BIGFOOT
125#define MDBX_ENABLE_BIGFOOT 1
126#elif !(MDBX_ENABLE_BIGFOOT == 0 || MDBX_ENABLE_BIGFOOT == 1)
127#error MDBX_ENABLE_BIGFOOT must be defined as 0 or 1
128#endif /* MDBX_ENABLE_BIGFOOT */
129
131#ifndef MDBX_ENABLE_BUNCHES_REMOVAL
132#define MDBX_ENABLE_BUNCHES_REMOVAL 1
133#elif !(MDBX_ENABLE_BUNCHES_REMOVAL == 0 || MDBX_ENABLE_BUNCHES_REMOVAL == 1)
134#error MDBX_ENABLE_BUNCHES_REMOVAL must be MDBX_ENABLE_BUNCHES_REMOVAL as 0 or 1
135#endif /* MDBX_ENABLE_BUNCHES_REMOVAL */
136
139#ifndef MDBX_DISABLE_VALIDATION
140#define MDBX_DISABLE_VALIDATION 0
141#elif !(MDBX_DISABLE_VALIDATION == 0 || MDBX_DISABLE_VALIDATION == 1)
142#error MDBX_DISABLE_VALIDATION must be defined as 0 or 1
143#endif /* MDBX_DISABLE_VALIDATION */
144
145#ifndef MDBX_PNL_PREALLOC_FOR_RADIXSORT
146#define MDBX_PNL_PREALLOC_FOR_RADIXSORT 1
147#elif !(MDBX_PNL_PREALLOC_FOR_RADIXSORT == 0 || MDBX_PNL_PREALLOC_FOR_RADIXSORT == 1)
148#error MDBX_PNL_PREALLOC_FOR_RADIXSORT must be defined as 0 or 1
149#endif /* MDBX_PNL_PREALLOC_FOR_RADIXSORT */
150
151#ifndef MDBX_DPL_PREALLOC_FOR_RADIXSORT
152#define MDBX_DPL_PREALLOC_FOR_RADIXSORT 1
153#elif !(MDBX_DPL_PREALLOC_FOR_RADIXSORT == 0 || MDBX_DPL_PREALLOC_FOR_RADIXSORT == 1)
154#error MDBX_DPL_PREALLOC_FOR_RADIXSORT must be defined as 0 or 1
155#endif /* MDBX_DPL_PREALLOC_FOR_RADIXSORT */
156
157#ifndef MDBX_DML_PREALLOC_FOR_RADIXSORT
158#define MDBX_DML_PREALLOC_FOR_RADIXSORT 1
159#elif !(MDBX_DML_PREALLOC_FOR_RADIXSORT == 0 || MDBX_DML_PREALLOC_FOR_RADIXSORT == 1)
160#error MDBX_DML_PREALLOC_FOR_RADIXSORT must be defined as 0 or 1
161#endif /* MDBX_DML_PREALLOC_FOR_RADIXSORT */
162
163#ifndef MDBX_DPL_CACHE_NPAGES
164#if MDBX_WORDBITS >= 64
165#define MDBX_DPL_CACHE_NPAGES 1
166#else
167#define MDBX_DPL_CACHE_NPAGES 0
168#endif
169#elif !(MDBX_DPL_CACHE_NPAGES == 0 || MDBX_DPL_CACHE_NPAGES == 1)
170#error MDBX_DPL_CACHE_NPAGES must be defined as 0 or 1
171#endif /* MDBX_DPL_CACHE_NPAGES */
172
185#ifndef MDBX_AVOID_MSYNC
186#if defined(_WIN32) || defined(_WIN64)
187#define MDBX_AVOID_MSYNC 1
188#else
189#define MDBX_AVOID_MSYNC 0
190#endif
191#elif !(MDBX_AVOID_MSYNC == 0 || MDBX_AVOID_MSYNC == 1)
192#error MDBX_AVOID_MSYNC must be defined as 0 or 1
193#endif /* MDBX_AVOID_MSYNC */
194
196#ifndef MDBX_ENABLE_DBI_SPARSE
197#define MDBX_ENABLE_DBI_SPARSE 1
198#elif !(MDBX_ENABLE_DBI_SPARSE == 0 || MDBX_ENABLE_DBI_SPARSE == 1)
199#error MDBX_ENABLE_DBI_SPARSE must be defined as 0 or 1
200#endif /* MDBX_ENABLE_DBI_SPARSE */
201
203#ifndef MDBX_ENABLE_DBI_LOCKFREE
204#define MDBX_ENABLE_DBI_LOCKFREE 1
205#elif !(MDBX_ENABLE_DBI_LOCKFREE == 0 || MDBX_ENABLE_DBI_LOCKFREE == 1)
206#error MDBX_ENABLE_DBI_LOCKFREE must be defined as 0 or 1
207#endif /* MDBX_ENABLE_DBI_LOCKFREE */
208
210#ifndef MDBX_WITHOUT_MSVC_CRT
211#if defined(MDBX_BUILD_CXX) && !MDBX_BUILD_CXX && (defined(_WIN32) || defined(_WIN64))
212#define MDBX_WITHOUT_MSVC_CRT 1
213#else
214#define MDBX_WITHOUT_MSVC_CRT 0
215#endif
216#elif !(MDBX_WITHOUT_MSVC_CRT == 0 || MDBX_WITHOUT_MSVC_CRT == 1)
217#error MDBX_WITHOUT_MSVC_CRT must be defined as 0 or 1
218#endif /* MDBX_WITHOUT_MSVC_CRT */
219
221#ifndef MDBX_ENVCOPY_WRITEBUF
222#define MDBX_ENVCOPY_WRITEBUF 1048576u
223#elif MDBX_ENVCOPY_WRITEBUF < 65536u || MDBX_ENVCOPY_WRITEBUF > 1073741824u || MDBX_ENVCOPY_WRITEBUF % 65536u
224#error MDBX_ENVCOPY_WRITEBUF must be defined in range 65536..1073741824 and be multiple of 65536
225#endif /* MDBX_ENVCOPY_WRITEBUF */
226
229#ifndef MDBX_FORCE_ASSERTIONS
230#define MDBX_FORCE_ASSERTIONS 0
231#elif !(MDBX_FORCE_ASSERTIONS == 0 || MDBX_FORCE_ASSERTIONS == 1)
232#error MDBX_FORCE_ASSERTIONS must be defined as 0 or 1
233#endif /* MDBX_FORCE_ASSERTIONS */
234
237#ifndef MDBX_ASSUME_MALLOC_OVERHEAD
238#ifdef __SIZEOF_POINTER__
239#define MDBX_ASSUME_MALLOC_OVERHEAD (__SIZEOF_POINTER__ * 2u)
240#else
241#define MDBX_ASSUME_MALLOC_OVERHEAD (sizeof(void *) * 2u)
242#endif
243#elif MDBX_ASSUME_MALLOC_OVERHEAD < 0 || MDBX_ASSUME_MALLOC_OVERHEAD > 64 || MDBX_ASSUME_MALLOC_OVERHEAD % 4
244#error MDBX_ASSUME_MALLOC_OVERHEAD must be defined in range 0..64 and be multiple of 4
245#endif /* MDBX_ASSUME_MALLOC_OVERHEAD */
246
249#ifndef ENABLE_MEMCHECK
250#endif /* ENABLE_MEMCHECK */
251
254#ifndef MDBX_HAVE_C11ATOMICS
255#endif /* MDBX_HAVE_C11ATOMICS */
256
263#ifndef MDBX_HAVE_BUILTIN_CPU_SUPPORTS
264#if defined(__APPLE__) || defined(BIONIC)
265/* Never use any modern features on Apple's or Google's OSes
266 * since a lot of troubles with compatibility and/or performance */
267#define MDBX_HAVE_BUILTIN_CPU_SUPPORTS 0
268#elif defined(__e2k__)
269#define MDBX_HAVE_BUILTIN_CPU_SUPPORTS 0
270#elif __has_builtin(__builtin_cpu_supports) || defined(__BUILTIN_CPU_SUPPORTS__) || \
271 (defined(__ia32__) && __GNUC_PREREQ(4, 8) && __GLIBC_PREREQ(2, 23))
272#define MDBX_HAVE_BUILTIN_CPU_SUPPORTS 1
273#else
274#define MDBX_HAVE_BUILTIN_CPU_SUPPORTS 0
275#endif
276#elif !(MDBX_HAVE_BUILTIN_CPU_SUPPORTS == 0 || MDBX_HAVE_BUILTIN_CPU_SUPPORTS == 1)
277#error MDBX_HAVE_BUILTIN_CPU_SUPPORTS must be defined as 0 or 1
278#endif /* MDBX_HAVE_BUILTIN_CPU_SUPPORTS */
279
282#ifndef MDBX_NOSUCCESS_PURE_COMMIT
283#define MDBX_NOSUCCESS_PURE_COMMIT 0
284#elif !(MDBX_NOSUCCESS_PURE_COMMIT == 0 || MDBX_NOSUCCESS_PURE_COMMIT == 1)
285#error MDBX_NOSUCCESS_PURE_COMMIT must be defined as 0 or 1
286#endif /* MDBX_NOSUCCESS_PURE_COMMIT */
287
290#ifndef MDBX_ENABLE_NON_READONLY_EXPORT
291#define MDBX_ENABLE_NON_READONLY_EXPORT 0
292#elif !(MDBX_ENABLE_NON_READONLY_EXPORT == 0 || MDBX_ENABLE_NON_READONLY_EXPORT == 1)
293#error MDBX_ENABLE_NON_READONLY_EXPORT must be defined as 0 or 1
294#endif /* MDBX_ENABLE_NON_READONLY_EXPORT */
295
298#ifndef MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS
299#define MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS 0
300#elif !(MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS == 0 || MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS == 1)
301#error MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS must be defined as 0 or 1
302#endif /* MDBX_ENABLE_FAKE_NESTED_READONLY_TRANSACTIONS */
303
312#ifndef MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY
313#define MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY 0
314#elif !(MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY == 0 || MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY == 1)
315#error MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY must be defined as 0 or 1
316#endif /* MDBX_ROUNDING_TO_ALLOCATION_GRANULARITY */
317
318//------------------------------------------------------------------------------
319
321#define MDBX_LOCKING_WIN32FILES -1
322
324#define MDBX_LOCKING_SYSV 5
325
327#define MDBX_LOCKING_POSIX1988 1988
328
330#define MDBX_LOCKING_POSIX2001 2001
331
333#define MDBX_LOCKING_POSIX2008 2008
334
336#if defined(_WIN32) || defined(_WIN64)
337#define MDBX_LOCKING MDBX_LOCKING_WIN32FILES
338#else
339#ifndef MDBX_LOCKING
340#if defined(_POSIX_THREAD_PROCESS_SHARED) && _POSIX_THREAD_PROCESS_SHARED >= 200112L && !defined(__FreeBSD__)
341
342/* Some platforms define the EOWNERDEAD error code even though they
343 * don't support Robust Mutexes. If doubt compile with -MDBX_LOCKING=2001. */
344#if defined(EOWNERDEAD) && _POSIX_THREAD_PROCESS_SHARED >= 200809L && \
345 ((defined(_POSIX_THREAD_ROBUST_PRIO_INHERIT) && _POSIX_THREAD_ROBUST_PRIO_INHERIT > 0) || \
346 (defined(_POSIX_THREAD_ROBUST_PRIO_PROTECT) && _POSIX_THREAD_ROBUST_PRIO_PROTECT > 0) || \
347 defined(PTHREAD_MUTEX_ROBUST) || defined(PTHREAD_MUTEX_ROBUST_NP)) && \
348 (!defined(__GLIBC__) || __GLIBC_PREREQ(2, 10) /* troubles with Robust mutexes before 2.10 */) && \
349 !defined(__OHOS__) /* Harmony OS doesn't support robust mutexes at the end of 2025 */
350#define MDBX_LOCKING MDBX_LOCKING_POSIX2008
351#else
352#define MDBX_LOCKING MDBX_LOCKING_POSIX2001
353#endif
354#elif defined(__sun) || defined(__SVR4) || defined(__svr4__) || defined(__HAIKU__)
355#define MDBX_LOCKING MDBX_LOCKING_POSIX1988
356#else
357#define MDBX_LOCKING MDBX_LOCKING_SYSV
358#endif
359#define MDBX_LOCKING_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_LOCKING)
360#else
361#define MDBX_LOCKING_CONFIG MDBX_STRINGIFY(MDBX_LOCKING)
362#endif /* MDBX_LOCKING */
363#endif /* !Windows */
364
366#ifndef MDBX_USE_OFDLOCKS
367#if ((defined(F_OFD_SETLK) && defined(F_OFD_SETLKW) && defined(F_OFD_GETLK)) || \
368 (defined(F_OFD_SETLK64) && defined(F_OFD_SETLKW64) && defined(F_OFD_GETLK64))) && \
369 !defined(MDBX_SAFE4QEMU) && !defined(__sun) /* OFD-lock are broken on Solaris */
370#define MDBX_USE_OFDLOCKS 1
371#else
372#define MDBX_USE_OFDLOCKS 0
373#endif
374#define MDBX_USE_OFDLOCKS_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_USE_OFDLOCKS)
375#elif !(MDBX_USE_OFDLOCKS == 0 || MDBX_USE_OFDLOCKS == 1)
376#error MDBX_USE_OFDLOCKS must be defined as 0 or 1
377#else
378#define MDBX_USE_OFDLOCKS_CONFIG MDBX_STRINGIFY(MDBX_USE_OFDLOCKS)
379#endif /* MDBX_USE_OFDLOCKS */
380
382#ifndef MDBX_USE_SENDFILE
383#if ((defined(__linux__) || defined(__gnu_linux__)) && !defined(__ANDROID_API__)) || \
384 (defined(__ANDROID_API__) && __ANDROID_API__ >= 21)
385#define MDBX_USE_SENDFILE 1
386#else
387#define MDBX_USE_SENDFILE 0
388#endif
389#elif !(MDBX_USE_SENDFILE == 0 || MDBX_USE_SENDFILE == 1)
390#error MDBX_USE_SENDFILE must be defined as 0 or 1
391#endif /* MDBX_USE_SENDFILE */
392
394#ifndef MDBX_USE_COPYFILERANGE
395#if __GLIBC_PREREQ(2, 27) && defined(_GNU_SOURCE)
396#define MDBX_USE_COPYFILERANGE 1
397#else
398#define MDBX_USE_COPYFILERANGE 0
399#endif
400#elif !(MDBX_USE_COPYFILERANGE == 0 || MDBX_USE_COPYFILERANGE == 1)
401#error MDBX_USE_COPYFILERANGE must be defined as 0 or 1
402#endif /* MDBX_USE_COPYFILERANGE */
403
405#ifndef MDBX_USE_FALLOCATE
406#if defined(__APPLE__)
407#define MDBX_USE_FALLOCATE 0 /* Too slow and unclean, but not required to prevent SIGBUS */
408#elif (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (__GLIBC_PREREQ(2, 10) && defined(_GNU_SOURCE))
409#define MDBX_USE_FALLOCATE 1
410#else
411#define MDBX_USE_FALLOCATE 0
412#endif
413#define MDBX_USE_FALLOCATE_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_USE_FALLOCATE)
414#elif !(MDBX_USE_FALLOCATE == 0 || MDBX_USE_FALLOCATE == 1)
415#error MDBX_USE_FALLOCATE must be defined as 0 or 1
416#else
417#define MDBX_USE_FALLOCATE_CONFIG MDBX_STRINGIFY(MDBX_USE_FALLOCATE)
418#endif /* MDBX_USE_FALLOCATE */
419
420#ifndef MDBX_HISTOGRAM_USING_128BIT
421#if MDBX_WORDBITS >= 64
422#define MDBX_HISTOGRAM_USING_128BIT 1
423#else
424#define MDBX_HISTOGRAM_USING_128BIT 0
425#endif
426#elif !(MDBX_HISTOGRAM_USING_128BIT == 0 || MDBX_HISTOGRAM_USING_128BIT == 1)
427#error MDBX_HISTOGRAM_USING_128BIT must be defined as 0 or 1
428#endif /* MDBX_HISTOGRAM_USING_128BIT */
429
430//------------------------------------------------------------------------------
431
432#ifndef MDBX_CPU_WRITEBACK_INCOHERENT
433#if defined(__ia32__) || defined(__e2k__) || defined(__hppa) || defined(__hppa__) || defined(DOXYGEN)
434#define MDBX_CPU_WRITEBACK_INCOHERENT 0
435#else
436#define MDBX_CPU_WRITEBACK_INCOHERENT 1
437#endif
438#elif !(MDBX_CPU_WRITEBACK_INCOHERENT == 0 || MDBX_CPU_WRITEBACK_INCOHERENT == 1)
439#error MDBX_CPU_WRITEBACK_INCOHERENT must be defined as 0 or 1
440#endif /* MDBX_CPU_WRITEBACK_INCOHERENT */
441
442#ifndef MDBX_MMAP_INCOHERENT_FILE_WRITE
443#ifdef __OpenBSD__
444#define MDBX_MMAP_INCOHERENT_FILE_WRITE 1
445#else
446#define MDBX_MMAP_INCOHERENT_FILE_WRITE 0
447#endif
448#elif !(MDBX_MMAP_INCOHERENT_FILE_WRITE == 0 || MDBX_MMAP_INCOHERENT_FILE_WRITE == 1)
449#error MDBX_MMAP_INCOHERENT_FILE_WRITE must be defined as 0 or 1
450#endif /* MDBX_MMAP_INCOHERENT_FILE_WRITE */
451
452#ifndef MDBX_MMAP_INCOHERENT_CPU_CACHE
453#if defined(__mips) || defined(__mips__) || defined(__mips64) || defined(__mips64__) || defined(_M_MRX000) || \
454 defined(_MIPS_) || defined(__MWERKS__) || defined(__sgi)
455/* MIPS has cache coherency issues. */
456#define MDBX_MMAP_INCOHERENT_CPU_CACHE 1
457#else
458/* LY: assume no relevant mmap/dcache issues. */
459#define MDBX_MMAP_INCOHERENT_CPU_CACHE 0
460#endif
461#elif !(MDBX_MMAP_INCOHERENT_CPU_CACHE == 0 || MDBX_MMAP_INCOHERENT_CPU_CACHE == 1)
462#error MDBX_MMAP_INCOHERENT_CPU_CACHE must be defined as 0 or 1
463#endif /* MDBX_MMAP_INCOHERENT_CPU_CACHE */
464
467#ifndef MDBX_MMAP_NEEDS_JOLT
468#if MDBX_MMAP_INCOHERENT_FILE_WRITE || MDBX_MMAP_INCOHERENT_CPU_CACHE || !(defined(__linux__) || defined(__gnu_linux__))
469#define MDBX_MMAP_NEEDS_JOLT 1
470#else
471#define MDBX_MMAP_NEEDS_JOLT 0
472#endif
473#define MDBX_MMAP_NEEDS_JOLT_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_MMAP_NEEDS_JOLT)
474#elif !(MDBX_MMAP_NEEDS_JOLT == 0 || MDBX_MMAP_NEEDS_JOLT == 1)
475#error MDBX_MMAP_NEEDS_JOLT must be defined as 0 or 1
476#endif /* MDBX_MMAP_NEEDS_JOLT */
477
478#ifndef MDBX_64BIT_ATOMIC
479#if MDBX_WORDBITS >= 64 || defined(DOXYGEN)
480#define MDBX_64BIT_ATOMIC 1
481#else
482#define MDBX_64BIT_ATOMIC 0
483#endif
484#define MDBX_64BIT_ATOMIC_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_64BIT_ATOMIC)
485#elif !(MDBX_64BIT_ATOMIC == 0 || MDBX_64BIT_ATOMIC == 1)
486#error MDBX_64BIT_ATOMIC must be defined as 0 or 1
487#else
488#define MDBX_64BIT_ATOMIC_CONFIG MDBX_STRINGIFY(MDBX_64BIT_ATOMIC)
489#endif /* MDBX_64BIT_ATOMIC */
490
491#ifndef MDBX_64BIT_CAS
492#if defined(__GCC_ATOMIC_LLONG_LOCK_FREE)
493#if __GCC_ATOMIC_LLONG_LOCK_FREE > 1
494#define MDBX_64BIT_CAS 1
495#else
496#define MDBX_64BIT_CAS 0
497#endif
498#elif defined(__CLANG_ATOMIC_LLONG_LOCK_FREE)
499#if __CLANG_ATOMIC_LLONG_LOCK_FREE > 1
500#define MDBX_64BIT_CAS 1
501#else
502#define MDBX_64BIT_CAS 0
503#endif
504#elif defined(ATOMIC_LLONG_LOCK_FREE)
505#if ATOMIC_LLONG_LOCK_FREE > 1
506#define MDBX_64BIT_CAS 1
507#else
508#define MDBX_64BIT_CAS 0
509#endif
510#elif defined(_MSC_VER) || defined(__APPLE__) || defined(DOXYGEN)
511#define MDBX_64BIT_CAS 1
512#elif !(MDBX_64BIT_CAS == 0 || MDBX_64BIT_CAS == 1)
513#error MDBX_64BIT_CAS must be defined as 0 or 1
514#else
515#define MDBX_64BIT_CAS MDBX_64BIT_ATOMIC
516#endif
517#define MDBX_64BIT_CAS_CONFIG "AUTO=" MDBX_STRINGIFY(MDBX_64BIT_CAS)
518#else
519#define MDBX_64BIT_CAS_CONFIG MDBX_STRINGIFY(MDBX_64BIT_CAS)
520#endif /* MDBX_64BIT_CAS */
521
522#ifndef MDBX_UNALIGNED_OK
523#if defined(__ALIGNED__) || defined(__SANITIZE_UNDEFINED__) || defined(ENABLE_UBSAN)
524#define MDBX_UNALIGNED_OK 0 /* no unaligned access allowed */
525#elif defined(__ARM_FEATURE_UNALIGNED)
526#define MDBX_UNALIGNED_OK 4 /* ok unaligned for 32-bit words */
527#elif defined(__e2k__) || defined(__elbrus__)
528#if __iset__ > 4
529#define MDBX_UNALIGNED_OK 8 /* ok unaligned for 64-bit words */
530#else
531#define MDBX_UNALIGNED_OK 4 /* ok unaligned for 32-bit words */
532#endif
533#elif defined(__ia32__)
534#define MDBX_UNALIGNED_OK 8 /* ok unaligned for 64-bit words */
535#elif __CLANG_PREREQ(5, 0) || __GNUC_PREREQ(5, 0)
536/* expecting an optimization will well done, also this
537 * hushes false-positives from UBSAN (undefined behaviour sanitizer) */
538#define MDBX_UNALIGNED_OK 0
539#else
540#define MDBX_UNALIGNED_OK 0 /* no unaligned access allowed */
541#endif
542#elif MDBX_UNALIGNED_OK == 1
543#undef MDBX_UNALIGNED_OK
544#define MDBX_UNALIGNED_OK 32 /* any unaligned access allowed */
545#endif /* MDBX_UNALIGNED_OK */
546
547#ifndef MDBX_CACHELINE_SIZE
548#if defined(SYSTEM_CACHE_ALIGNMENT_SIZE)
549#define MDBX_CACHELINE_SIZE SYSTEM_CACHE_ALIGNMENT_SIZE
550#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
551#define MDBX_CACHELINE_SIZE 128
552#else
553#define MDBX_CACHELINE_SIZE 64
554#endif
555#endif /* MDBX_CACHELINE_SIZE */
556
557/* Max length of iov-vector passed to writev() call, used for auxilary writes */
558#ifndef MDBX_AUXILARY_IOV_MAX
559#define MDBX_AUXILARY_IOV_MAX 64
560#endif
561#if defined(IOV_MAX) && IOV_MAX < MDBX_AUXILARY_IOV_MAX
562#undef MDBX_AUXILARY_IOV_MAX
563#define MDBX_AUXILARY_IOV_MAX IOV_MAX
564#endif /* MDBX_AUXILARY_IOV_MAX */
565
566/* An extra/custom information provided during library build */
567#ifndef MDBX_BUILD_METADATA
568#define MDBX_BUILD_METADATA ""
569#endif /* MDBX_BUILD_METADATA */
570
571#ifdef DOXYGEN
572/* !!! Actually this is a fake definitions for Doxygen !!! */
573
589#define MDBX_DEBUG 0...3
590
611#define MDBX_CHECKING -1...3
612
614#define MDBX_DISABLE_GNU_SOURCE 0 or 1
615
617/********************************************************************************/
618#else /* DOXYGEN */
619
620#ifndef MDBX_DEBUG
621#define MDBX_DEBUG 0
622#elif MDBX_DEBUG < -1 || MDBX_DEBUG > 3
623#error "The MDBX_DEBUG must be defined to -1, 0, 1, 2 or 3"
624#endif /* MDBX_DEBUG */
625
626#ifndef MDBX_CHECKING
627#if MDBX_FORCE_ASSERTIONS && MDBX_DEBUG < 2
628#define MDBX_CHECKING 2
629#else
630#define MDBX_CHECKING MDBX_DEBUG
631#endif
632#elif MDBX_CHECKING < -1 || MDBX_DEBUG > 3
633#error "The MDBX_CHECKING must be defined to -1, 0, 1, 2 or 3"
634#endif /* MDBX_CHECKING */
635
636#if MDBX_FORCE_ASSERTIONS && MDBX_CHECKING < 2
637#error "Please use one of MDBX_CHECKING either MDBX_FORCE_ASSERTIONS build options, but not both"
638#endif
639
640/* Since 2026-04-01 alternatives to MDBX_PNL_ASCENDING = 0 are no longer supported. */
641#define MDBX_PNL_ASCENDING 0
642
643#endif /* DOXYGEN */