Factor out MDB_SIZE_MAX, MDB_FMT_Y, MDB_FMT_Z

ntdll
Hallvard Furuseth 8 years ago
parent 84610e65da
commit 32764bcb52
  1. 19
      libraries/liblmdb/lmdb.h
  2. 13
      libraries/liblmdb/mdb.c
  3. 15
      libraries/liblmdb/mdb_dump.c
  4. 16
      libraries/liblmdb/mdb_load.c
  5. 16
      libraries/liblmdb/mdb_stat.c
  6. 9
      libraries/liblmdb/midl.h

@ -179,13 +179,32 @@ typedef int mdb_mode_t;
typedef mode_t mdb_mode_t; typedef mode_t mdb_mode_t;
#endif #endif
#ifdef _WIN32
# define MDB_FMT_Z "I"
#else
# define MDB_FMT_Z "z" /**< printf/scanf format modifier for size_t */
#endif
#ifdef MDB_VL32 #ifdef MDB_VL32
typedef uint64_t mdb_size_t; 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 */ #define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */
#else #else
typedef size_t mdb_size_t; 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() */
#endif #endif
/** #mdb_size_t printf formats, \b t = one of [diouxX] without quotes */
#define MDB_PRIz(t) MDB_FMT_Y #t
/** #mdb_size_t scanf formats, \b t = one of [dioux] without quotes */
#define MDB_SCNz(t) MDB_FMT_Y #t
/** An abstraction for a file handle. /** An abstraction for a file handle.
* On POSIX systems file handles are small integers. On Windows * On POSIX systems file handles are small integers. On Windows
* they're opaque pointers. * they're opaque pointers.

@ -355,12 +355,10 @@ typedef HANDLE mdb_mutex_t, mdb_mutexref_t;
#else #else
#define MDB_PROCESS_QUERY_LIMITED_INFORMATION 0x1000 #define MDB_PROCESS_QUERY_LIMITED_INFORMATION 0x1000
#endif #endif
#define Z "I"
#else #else
#define THREAD_RET void * #define THREAD_RET void *
#define THREAD_CREATE(thr,start,arg) pthread_create(&thr,NULL,start,arg) #define THREAD_CREATE(thr,start,arg) pthread_create(&thr,NULL,start,arg)
#define THREAD_FINISH(thr) pthread_join(thr,NULL) #define THREAD_FINISH(thr) pthread_join(thr,NULL)
#define Z "z" /**< printf format modifier for size_t */
/** For MDB_LOCK_FORMAT: True if readers take a pid lock in the lockfile */ /** For MDB_LOCK_FORMAT: True if readers take a pid lock in the lockfile */
#define MDB_PIDLOCK 1 #define MDB_PIDLOCK 1
@ -458,15 +456,8 @@ typedef pthread_mutex_t mdb_mutex_t[1], *mdb_mutexref_t;
#define GET_PAGESIZE(x) ((x) = sysconf(_SC_PAGE_SIZE)) #define GET_PAGESIZE(x) ((x) = sysconf(_SC_PAGE_SIZE))
#endif #endif
#ifdef MDB_VL32 #define Z MDB_FMT_Z /**< printf/scanf format modifier for size_t */
#ifdef _WIN32 #define Y MDB_FMT_Y /**< printf/scanf format modifier for #mdb_size_t */
#define Y "I64"
#else
#define Y "ll"
#endif
#else
#define Y Z
#endif
#if defined(_WIN32) || defined(MDB_USE_POSIX_SEM) #if defined(_WIN32) || defined(MDB_USE_POSIX_SEM)
#define MNAME_LEN 32 #define MNAME_LEN 32

@ -20,20 +20,7 @@
#include <signal.h> #include <signal.h>
#include "lmdb.h" #include "lmdb.h"
#ifdef _WIN32 #define Y MDB_FMT_Y
#define Z "I"
#else
#define Z "z"
#endif
#ifdef MDB_VL32
#ifdef _WIN32
#define Y "I64"
#else
#define Y "ll"
#endif
#else
#define Y Z
#endif
#define PRINT 1 #define PRINT 1
static int mode; static int mode;

@ -38,20 +38,8 @@ static MDB_envinfo info;
static MDB_val kbuf, dbuf; static MDB_val kbuf, dbuf;
#ifdef _WIN32 #define Z MDB_FMT_Z
#define Z "I" #define Y MDB_FMT_Y
#else
#define Z "z"
#endif
#ifdef MDB_VL32
#ifdef _WIN32
#define Y "I64"
#else
#define Y "ll"
#endif
#else
#define Y Z
#endif
#define STRLENOF(s) (sizeof(s)-1) #define STRLENOF(s) (sizeof(s)-1)

@ -17,20 +17,8 @@
#include <unistd.h> #include <unistd.h>
#include "lmdb.h" #include "lmdb.h"
#ifdef _WIN32 #define Z MDB_FMT_Z
#define Z "I" #define Y MDB_FMT_Y
#else
#define Z "z"
#endif
#ifdef MDB_VL32
#ifdef _WIN32
#define Y "I64"
#else
#define Y "ll"
#endif
#else
#define Y Z
#endif
static void prstat(MDB_stat *ms) static void prstat(MDB_stat *ms)
{ {

@ -26,8 +26,7 @@
#ifndef _MDB_MIDL_H_ #ifndef _MDB_MIDL_H_
#define _MDB_MIDL_H_ #define _MDB_MIDL_H_
#include <stddef.h> #include "lmdb.h"
#include <inttypes.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -43,11 +42,7 @@ extern "C" {
/** A generic unsigned ID number. These were entryIDs in back-bdb. /** A generic unsigned ID number. These were entryIDs in back-bdb.
* Preferably it should have the same size as a pointer. * Preferably it should have the same size as a pointer.
*/ */
#ifdef MDB_VL32 typedef mdb_size_t MDB_ID;
typedef uint64_t MDB_ID;
#else
typedef size_t MDB_ID;
#endif
/** An IDL is an ID List, a sorted array of IDs. The first /** An IDL is an ID List, a sorted array of IDs. The first
* element of the array is a counter for how many actual * element of the array is a counter for how many actual

Loading…
Cancel
Save