[Pkg-javascript-commits] [node-leveldown] 293/492: move win atomic pointer code out of leveldb src

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit 4d2b8843fb112abe3170d05697c94cbaee411704
Author: Rod Vagg <rod at vagg.org>
Date:   Sat Mar 30 17:09:35 2013 +1100

    move win atomic pointer code out of leveldb src
---
 deps/leveldb/leveldb-1.9.0/port/port.h       |  2 +-
 deps/leveldb/port-libuv/atomic_pointer_win.h | 42 ++++++++++++++++++++++++++++
 deps/leveldb/port-libuv/port_uv.h            |  3 ++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/deps/leveldb/leveldb-1.9.0/port/port.h b/deps/leveldb/leveldb-1.9.0/port/port.h
index 3c8fd8c..e009fb6 100644
--- a/deps/leveldb/leveldb-1.9.0/port/port.h
+++ b/deps/leveldb/leveldb-1.9.0/port/port.h
@@ -11,7 +11,7 @@
 // porting to a new platform, see "port_example.h" for documentation
 // of what the new port_<platform>.h file must provide.
 #if defined(LEVELDB_PLATFORM_UV)
-#  include "libuv_port/port_uv.h"
+#  include "port_uv.h"
 #elif defined(LEVELDB_PLATFORM_POSIX)
 #  include "port/port_posix.h"
 #elif defined(LEVELDB_PLATFORM_CHROMIUM)
diff --git a/deps/leveldb/port-libuv/atomic_pointer_win.h b/deps/leveldb/port-libuv/atomic_pointer_win.h
new file mode 100644
index 0000000..e9b4c87
--- /dev/null
+++ b/deps/leveldb/port-libuv/atomic_pointer_win.h
@@ -0,0 +1,42 @@
+#include <stdint.h>
+#include <windows.h>
+
+// credit: https://groups.google.com/forum/#!msg/leveldb/VuECZMnsob4/F6pGPGaK-XwJ
+
+class AtomicPointer {
+  private:
+    void* rep_;
+
+  public:
+    AtomicPointer () {}
+    explicit AtomicPointer(void* v) {
+      InterlockedExchangePointer(&rep_, v);
+    }
+
+    // Read and return the stored pointer with the guarantee that no
+    // later memory access (read or write) by this thread can be
+    // reordered ahead of this read.
+    inline void* Acquire_Load() const {
+        void* r;
+        InterlockedExchangePointer(&r, rep_ );
+        return r;
+    }
+
+    // Set v as the stored pointer with the guarantee that no earlier
+    // memory access (read or write) by this thread can be reordered
+    // after this store.
+    inline void Release_Store(void* v) {
+        InterlockedExchangePointer(&rep_, v);
+    }
+
+    // Read the stored pointer with no ordering guarantees.
+    inline void* NoBarrier_Load() const {
+        void* r = reinterpret_cast<void*>(rep_);
+        return r;
+    }
+
+    // Set va as the stored pointer with no ordering guarantees.
+    inline void NoBarrier_Store(void* v) {
+        rep_ = reinterpret_cast<void*>(v);
+    }
+};
\ No newline at end of file
diff --git a/deps/leveldb/port-libuv/port_uv.h b/deps/leveldb/port-libuv/port_uv.h
index f63c4d5..8173f9c 100644
--- a/deps/leveldb/port-libuv/port_uv.h
+++ b/deps/leveldb/port-libuv/port_uv.h
@@ -43,6 +43,9 @@
 #include <stdint.h>
 #include <string>
 #include "port/atomic_pointer.h"
+#if defined(_MSC_VER)
+  #include "atomic_pointer_win.h"
+#endif
 
 #ifndef PLATFORM_IS_LITTLE_ENDIAN
 #define PLATFORM_IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list