lmdb: cleanup Windows support.

Change-Id: I7bc7f3e997eeea4c5678a97e2faf10525ba7eee6
This commit is contained in:
Leo Yuriev 2015-05-04 02:24:36 +03:00
parent f97cc739cb
commit 59d6560fc3
2 changed files with 293 additions and 908 deletions

25
lmdb.h
View File

@ -51,7 +51,6 @@
* Fix: Check for stale readers periodically, using the * Fix: Check for stale readers periodically, using the
* #mdb_reader_check function or the \ref mdb_stat_1 "mdb_stat" tool. * #mdb_reader_check function or the \ref mdb_stat_1 "mdb_stat" tool.
* Stale writers will be cleared automatically on most systems: * Stale writers will be cleared automatically on most systems:
* - Windows - automatic
* - BSD, systems using SysV semaphores - automatic * - BSD, systems using SysV semaphores - automatic
* - Linux, systems using POSIX mutexes with Robust option - automatic * - Linux, systems using POSIX mutexes with Robust option - automatic
* Otherwise just make all programs using the database close it; * Otherwise just make all programs using the database close it;
@ -162,22 +161,10 @@
extern "C" { extern "C" {
#endif #endif
/** Unix permissions for creating files, or dummy definition for Windows */
#ifdef _MSC_VER
typedef int mdb_mode_t;
#else
typedef mode_t mdb_mode_t;
#endif
/** 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.
* they're opaque pointers.
*/ */
#ifdef _WIN32
typedef void *mdb_filehandle_t;
#else
typedef int mdb_filehandle_t; typedef int mdb_filehandle_t;
#endif
/** @defgroup mdb LMDB API /** @defgroup mdb LMDB API
* @{ * @{
@ -290,7 +277,7 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
#define MDB_NOTLS 0x200000 #define MDB_NOTLS 0x200000
/** don't do any locking, caller must manage their own locks */ /** don't do any locking, caller must manage their own locks */
#define MDB_NOLOCK 0x400000 #define MDB_NOLOCK 0x400000
/** don't do readahead (no effect on Windows) */ /** don't do readahead */
#define MDB_NORDAHEAD 0x800000 #define MDB_NORDAHEAD 0x800000
/** don't initialize malloc'd memory before writing to datafile */ /** don't initialize malloc'd memory before writing to datafile */
#define MDB_NOMEMINIT 0x1000000 #define MDB_NOMEMINIT 0x1000000
@ -414,8 +401,6 @@ typedef enum MDB_cursor_op {
#define MDB_DBS_FULL (-30791) #define MDB_DBS_FULL (-30791)
/** Environment maxreaders reached */ /** Environment maxreaders reached */
#define MDB_READERS_FULL (-30790) #define MDB_READERS_FULL (-30790)
/** Too many TLS keys in use - Windows only */
#define MDB_TLS_FULL (-30789)
/** Txn has too many dirty pages */ /** Txn has too many dirty pages */
#define MDB_TXN_FULL (-30788) #define MDB_TXN_FULL (-30788)
/** Cursor stack too deep - internal error */ /** Cursor stack too deep - internal error */
@ -579,7 +564,6 @@ int mdb_env_create(MDB_env **env);
* read requests by default. This option turns it off if the OS * read requests by default. This option turns it off if the OS
* supports it. Turning it off may help random read performance * supports it. Turning it off may help random read performance
* when the DB is larger than RAM and system RAM is full. * when the DB is larger than RAM and system RAM is full.
* The option is not implemented on Windows.
* <li>#MDB_NOMEMINIT * <li>#MDB_NOMEMINIT
* Don't initialize malloc'd memory before writing to unused spaces * Don't initialize malloc'd memory before writing to unused spaces
* in the data file. By default, memory for pages written to the data * in the data file. By default, memory for pages written to the data
@ -606,8 +590,7 @@ int mdb_env_create(MDB_env **env);
* LIFO policy for reclaiming FreeDB records. This significantly reduce * LIFO policy for reclaiming FreeDB records. This significantly reduce
* write IPOS in case MDB_NOSYNC with periodically checkpoints. * write IPOS in case MDB_NOSYNC with periodically checkpoints.
* </ul> * </ul>
* @param[in] mode The UNIX permissions to set on created files. This parameter * @param[in] mode The UNIX permissions to set on created files.
* is ignored on Windows.
* @return A non-zero error value on failure and 0 on success. Some possible * @return A non-zero error value on failure and 0 on success. Some possible
* errors are: * errors are:
* <ul> * <ul>
@ -619,7 +602,7 @@ int mdb_env_create(MDB_env **env);
* <li>EAGAIN - the environment was locked by another process. * <li>EAGAIN - the environment was locked by another process.
* </ul> * </ul>
*/ */
int mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode); int mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode);
/** @brief Copy an LMDB environment to the specified path. /** @brief Copy an LMDB environment to the specified path.
* *

1176
mdb.c

File diff suppressed because it is too large Load Diff