From a43fcad8c65c2f4998a27d5596677dd81a42bd0f Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 23 Jul 2016 12:43:16 +0200 Subject: [PATCH] MDB_VL32: Match mdb_size_t type with format modifier. When using format modifier "ll" or "I64", use the matching type unsigned rather than uint64_t. --- libraries/liblmdb/lmdb.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index c21115d808..0b3d839ef1 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -167,6 +167,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -185,19 +186,24 @@ typedef mode_t mdb_mode_t; # define MDB_FMT_Z "z" /**< printf/scanf format modifier for size_t */ #endif -#ifdef MDB_VL32 -typedef uint64_t mdb_size_t; -#define MDB_SIZE_MAX UINT64_MAX -#ifdef _WIN32 -# define MDB_FMT_Y "I64" -#else -# define MDB_FMT_Y "ll" -#endif -#define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */ -#else +#if !defined(MDB_VL32) || SIZE_MAX > 0xffffffffU typedef size_t mdb_size_t; # define MDB_SIZE_MAX SIZE_MAX /**< max #mdb_size_t */ # define MDB_FMT_Y MDB_FMT_Z /**< Obsolescent, see #MDB_PRIz()/#MDB_SCNz() */ +/* TODO: For VL32, use uint64_t (trivial) and therefore PRI64 (big patch) */ +#elif defined(_WIN32) +typedef unsigned __int64 mdb_size_t; +# define MDB_SIZE_MAX _UI64_MAX +# define MDB_FMT_Y "I64" +#elif defined(ULLONG_MAX) +typedef unsigned long long mdb_size_t; +# define MDB_SIZE_MAX ULLONG_MAX +# define MDB_FMT_Y "ll" +#else +# error "Found no acceptable integer type for mdb_size_t" +#endif +#ifdef MDB_VL32 +# define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */ #endif /** #mdb_size_t printf formats, \b t = one of [diouxX] without quotes */ -- 2.39.5