Port leveldb to MinGW32

Several changes to make the native windows leveldb code compile
with mingw32 and run on 32-bit Windows:
* Remove -std=c++0x dependency (modified code to use NULL instead of
  nullptr)
* Link with -lshlwapi
* Only #define snprintf/etc if compiling with Visual Studio
* Do not link against DbgHelp.lib (wrote a CreateDir instead of using
  DbgHelp's MakeSureDirectoryPathExists
* Define WINVER=0x0500 so MinGW32 can use the 64-bit-filesystem Windows
  api calls
* Define __USE_MINGW_ANSI_STDIO=1 to use MinGW's printf (which supports
  %ll)

I also cleaned up makefile.mingw, assuming that dependencies would be in
the standard /usr/local/{include,lib} by default but allowing overriding
with make DEPSDIR=... etc
This commit is contained in:
Gavin Andresen
2012-12-21 14:41:48 -05:00
parent 8aef119f43
commit b1024662ea
7 changed files with 71 additions and 40 deletions

View File

@@ -37,7 +37,7 @@ namespace leveldb {
namespace port {
Mutex::Mutex() :
cs_(nullptr) {
cs_(NULL) {
assert(!cs_);
cs_ = static_cast<void *>(new CRITICAL_SECTION());
::InitializeCriticalSection(static_cast<CRITICAL_SECTION *>(cs_));
@@ -48,7 +48,7 @@ Mutex::~Mutex() {
assert(cs_);
::DeleteCriticalSection(static_cast<CRITICAL_SECTION *>(cs_));
delete static_cast<CRITICAL_SECTION *>(cs_);
cs_ = nullptr;
cs_ = NULL;
assert(!cs_);
}
@@ -128,7 +128,7 @@ void InitOnce(OnceType* once, void (*initializer)()) {
}
void* AtomicPointer::Acquire_Load() const {
void * p = nullptr;
void * p = NULL;
InterlockedExchangePointer(&p, rep_);
return p;
}

View File

@@ -31,9 +31,11 @@
#ifndef STORAGE_LEVELDB_PORT_PORT_WIN_H_
#define STORAGE_LEVELDB_PORT_PORT_WIN_H_
#ifdef _MSC_VER
#define snprintf _snprintf
#define close _close
#define fread_unlocked _fread_nolock
#endif
#include <string>
#include <stdint.h>
@@ -120,7 +122,7 @@ class AtomicPointer {
private:
void * rep_;
public:
AtomicPointer() : rep_(nullptr) { }
AtomicPointer() : rep_(NULL) { }
explicit AtomicPointer(void* v);
void* Acquire_Load() const;