mirror of
https://github.com/isar/libmdbx.git
synced 2025-08-23 09:04:26 +08:00
mdbx: add workaround for old MSVC and/or old Windows SDK.
Resolves https://github.com/erthink/libmdbx/issues/265. Change-Id: I295b5d9d5ecd670ccf258791bf87379a3ca17f21
This commit is contained in:
@@ -674,19 +674,19 @@ typedef struct MDBX_lockinfo {
|
||||
/* Marker to distinguish uniqueness of DB/CLK. */
|
||||
MDBX_atomic_uint64_t mti_bait_uniqueness;
|
||||
|
||||
alignas(MDBX_CACHELINE_SIZE) /* cacheline ---------------------------------*/
|
||||
MDBX_ALIGNAS(MDBX_CACHELINE_SIZE) /* cacheline ----------------------------*/
|
||||
|
||||
#if MDBX_ENABLE_PGOP_STAT
|
||||
/* Statistics of costly ops of all (running, completed and aborted)
|
||||
* transactions */
|
||||
MDBX_pgop_stat_t mti_pgop_stat;
|
||||
/* Statistics of costly ops of all (running, completed and aborted)
|
||||
* transactions */
|
||||
MDBX_pgop_stat_t mti_pgop_stat;
|
||||
#endif /* MDBX_ENABLE_PGOP_STAT*/
|
||||
|
||||
alignas(MDBX_CACHELINE_SIZE) /* cacheline ---------------------------------*/
|
||||
MDBX_ALIGNAS(MDBX_CACHELINE_SIZE) /* cacheline ----------------------------*/
|
||||
|
||||
/* Write transaction lock. */
|
||||
#if MDBX_LOCKING > 0
|
||||
mdbx_ipclock_t mti_wlock;
|
||||
mdbx_ipclock_t mti_wlock;
|
||||
#endif /* MDBX_LOCKING > 0 */
|
||||
|
||||
atomic_txnid_t mti_oldest_reader;
|
||||
@@ -708,11 +708,11 @@ typedef struct MDBX_lockinfo {
|
||||
/* Shared anchor for tracking readahead edge and enabled/disabled status. */
|
||||
pgno_t mti_readahead_anchor;
|
||||
|
||||
alignas(MDBX_CACHELINE_SIZE) /* cacheline ---------------------------------*/
|
||||
MDBX_ALIGNAS(MDBX_CACHELINE_SIZE) /* cacheline ----------------------------*/
|
||||
|
||||
/* Readeaders registration lock. */
|
||||
#if MDBX_LOCKING > 0
|
||||
mdbx_ipclock_t mti_rlock;
|
||||
mdbx_ipclock_t mti_rlock;
|
||||
#endif /* MDBX_LOCKING > 0 */
|
||||
|
||||
/* The number of slots that have been used in the reader table.
|
||||
@@ -723,8 +723,8 @@ typedef struct MDBX_lockinfo {
|
||||
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
||||
(!defined(__cplusplus) && defined(_MSC_VER))
|
||||
alignas(MDBX_CACHELINE_SIZE) /* cacheline ---------------------------------*/
|
||||
MDBX_reader mti_readers[] /* dynamic size */;
|
||||
MDBX_ALIGNAS(MDBX_CACHELINE_SIZE) /* cacheline ----------------------------*/
|
||||
MDBX_reader mti_readers[] /* dynamic size */;
|
||||
#endif /* C99 */
|
||||
} MDBX_lockinfo;
|
||||
|
||||
|
21
src/osal.h
21
src/osal.h
@@ -56,18 +56,21 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
/* C11 stdalign.h */
|
||||
/* C11' alignas() */
|
||||
#if __has_include(<stdalign.h>)
|
||||
#include <stdalign.h>
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
#define alignas(N) _Alignas(N)
|
||||
#elif defined(_MSC_VER)
|
||||
#define alignas(N) __declspec(align(N))
|
||||
#elif __has_attribute(__aligned__) || defined(__GNUC__)
|
||||
#define alignas(N) __attribute__((__aligned__(N)))
|
||||
#else
|
||||
#error "FIXME: Required _alignas() or equivalent."
|
||||
#endif
|
||||
#if defined(alignas) || defined(__cplusplus)
|
||||
#define MDBX_ALIGNAS(N) alignas(N)
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
#define MDBX_ALIGNAS(N) _Alignas(N)
|
||||
#elif defined(_MSC_VER)
|
||||
#define MDBX_ALIGNAS(N) __declspec(align(N))
|
||||
#elif __has_attribute(__aligned__) || defined(__GNUC__)
|
||||
#define MDBX_ALIGNAS(N) __attribute__((__aligned__(N)))
|
||||
#else
|
||||
#error "FIXME: Required alignas() or equivalent."
|
||||
#endif /* MDBX_ALIGNAS */
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Systems includes */
|
||||
|
Reference in New Issue
Block a user