Skip to content

Commit

Permalink
Emscripten support patch
Browse files Browse the repository at this point in the history
  • Loading branch information
invokr committed Apr 22, 2015
1 parent 4d8336a commit a221786
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/google/protobuf/stubs/atomicops.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#error "Atomic operations are not supported on your platform"

// ThreadSanitizer, http://clang.llvm.org/docs/ThreadSanitizer.html.
#if defined(THREAD_SANITIZER)
#if defined(EMSCRIPTEN)
#include <google/protobuf/stubs/atomicops_internals_emscripten.h>
#elif defined(THREAD_SANITIZER)
#include <google/protobuf/stubs/atomicops_internals_tsan.h>
// MSVC.
#elif defined(_MSC_VER)
Expand Down
22 changes: 22 additions & 0 deletions src/google/protobuf/stubs/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define snprintf _snprintf // see comment in strutil.cc
#elif defined(HAVE_PTHREAD)
#include <pthread.h>
#elif defined(EMSCRIPTEN)
#else
#error "No suitable threading library available."
#endif
Expand Down Expand Up @@ -282,6 +283,27 @@ void Mutex::AssertHeld() {
#endif
}

#elif defined(EMSCRIPTEN)

struct Mutex::Internal {
};

Mutex::Mutex()
: mInternal(new Internal) {
}

Mutex::~Mutex() {
}

void Mutex::Lock() {
}

void Mutex::Unlock() {
}

void Mutex::AssertHeld() {
}

#elif defined(HAVE_PTHREAD)

struct Mutex::Internal {
Expand Down
3 changes: 3 additions & 0 deletions src/google/protobuf/stubs/platform_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
#elif defined(__aarch64__)
#define GOOGLE_PROTOBUF_ARCH_AARCH64 1
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
#elif defined(EMSCRIPTEN)
#define GOOGLE_PROTOBUF_ARCH_IA32 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__MIPSEL__)
#if defined(__LP64__)
#define GOOGLE_PROTOBUF_ARCH_MIPS64 1
Expand Down

0 comments on commit a221786

Please sign in to comment.