From d29b9600e6b893ebea8ed34c5c9ec933727ecb5b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 30 May 2013 15:33:59 -0700 Subject: [PATCH] Windows portability fixes for prev commit --- libraries/liblmdb/lmdb.h | 16 +++++++++------- libraries/liblmdb/mdb.c | 8 +++++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index 9776366c7c..2076eb35fa 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -144,12 +144,14 @@ typedef int mdb_mode_t; typedef mode_t mdb_mode_t; #endif -#ifndef _WIN32 - /** An abstraction for a file handle. - * On POSIX systems file handles are small integers. On Windows - * they're opaque pointers. - */ -#define HANDLE int +/** An abstraction for a file handle. + * On POSIX systems file handles are small integers. On Windows + * they're opaque pointers. + */ +#ifdef _WIN32 +typedef void *mdb_filehandle_t; +#else +typedef int mdb_filehandle_t; #endif /** @defgroup mdb MDB API @@ -550,7 +552,7 @@ int mdb_env_copy(MDB_env *env, const char *path); * have already been opened for Write access. * @return A non-zero error value on failure and 0 on success. */ -int mdb_env_copyfd(MDB_env *env, HANDLE fd); +int mdb_env_copyfd(MDB_env *env, mdb_filehandle_t fd); /** @brief Return statistics about the MDB environment. * diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 4109e71c34..33b9d47668 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -199,6 +199,12 @@ mdb_sem_wait(sem_t *sem) */ #define ErrCode() errno + /** An abstraction for a file handle. + * On POSIX systems file handles are small integers. On Windows + * they're opaque pointers. + */ +#define HANDLE int + /** A value for an invalid file handle. * Mainly used to initialize file variables and signify that they are * unused. @@ -3625,7 +3631,7 @@ mdb_env_close0(MDB_env *env, int excl) } int -mdb_env_copyfd(MDB_env *env, int fd) +mdb_env_copyfd(MDB_env *env, HANDLE fd) { MDB_txn *txn = NULL; int rc; -- 2.39.5