Skip to content

Instantly share code, notes, and snippets.

@splhack
Created January 10, 2014 02:43
Show Gist options
  • Save splhack/8346123 to your computer and use it in GitHub Desktop.
Save splhack/8346123 to your computer and use it in GitHub Desktop.
diff --git a/protobuf-2.5.0/src/google/protobuf/stubs/once.cc b/protobuf-2.5.0/src/google/protobuf/stubs/once.cc
index 1e24b85..e9056ac 100644
--- a/protobuf-2.5.0/src/google/protobuf/stubs/once.cc
+++ b/protobuf-2.5.0/src/google/protobuf/stubs/once.cc
@@ -63,7 +63,7 @@ void SchedYield() {
} // namespace
void GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure) {
- internal::AtomicWord state = internal::Acquire_Load(once);
+ internal::AtomicWord state = internal::Acquire_Load((volatile internal::Atomic32 *)once);
// Fast path. The provided closure was already executed.
if (state == ONCE_STATE_DONE) {
return;
@@ -76,19 +76,19 @@ void GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure) {
// First, try to change the state from UNINITIALIZED to EXECUTING_CLOSURE
// atomically.
state = internal::Acquire_CompareAndSwap(
- once, ONCE_STATE_UNINITIALIZED, ONCE_STATE_EXECUTING_CLOSURE);
+ (volatile internal::Atomic32 *)once, ONCE_STATE_UNINITIALIZED, ONCE_STATE_EXECUTING_CLOSURE);
if (state == ONCE_STATE_UNINITIALIZED) {
// We are the first thread to call this function, so we have to call the
// closure.
closure->Run();
- internal::Release_Store(once, ONCE_STATE_DONE);
+ internal::Release_Store((volatile internal::Atomic32 *)once, ONCE_STATE_DONE);
} else {
// Another thread has already started executing the closure. We need to
// wait until it completes the initialization.
while (state == ONCE_STATE_EXECUTING_CLOSURE) {
// Note that futex() could be used here on Linux as an improvement.
SchedYield();
- state = internal::Acquire_Load(once);
+ state = internal::Acquire_Load((volatile internal::Atomic32 *)once);
}
}
}
diff --git a/protobuf-2.5.0/src/google/protobuf/stubs/once.h b/protobuf-2.5.0/src/google/protobuf/stubs/once.h
index 7fbc117..7ae4406 100644
--- a/protobuf-2.5.0/src/google/protobuf/stubs/once.h
+++ b/protobuf-2.5.0/src/google/protobuf/stubs/once.h
@@ -122,7 +122,7 @@ LIBPROTOBUF_EXPORT
void GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure);
inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) {
- if (internal::Acquire_Load(once) != ONCE_STATE_DONE) {
+ if (internal::Acquire_Load((const internal::Atomic32*)once) != ONCE_STATE_DONE) {
internal::FunctionClosure0 func(init_func, false);
GoogleOnceInitImpl(once, &func);
}
@@ -131,7 +131,7 @@ inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) {
template <typename Arg>
inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg*),
Arg* arg) {
- if (internal::Acquire_Load(once) != ONCE_STATE_DONE) {
+ if (internal::Acquire_Load((const internal::Atomic32*)once) != ONCE_STATE_DONE) {
internal::FunctionClosure1<Arg*> func(init_func, false, arg);
GoogleOnceInitImpl(once, &func);
}
diff --git a/protobuf-2.5.0/src/google/protobuf/wire_format_lite.h b/protobuf-2.5.0/src/google/protobuf/wire_format_lite.h
index cb4fc91..2253bd9 100644
--- a/protobuf-2.5.0/src/google/protobuf/wire_format_lite.h
+++ b/protobuf-2.5.0/src/google/protobuf/wire_format_lite.h
@@ -92,6 +92,8 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
WIRETYPE_FIXED32 = 5,
};
+#undef TYPE_BOOL
+
// Lite alternative to FieldDescriptor::Type. Must be kept in sync.
enum FieldType {
TYPE_DOUBLE = 1,
@jingweiChar
Copy link

Solved my problem when try build a ndk version pb2.5. Thanks bro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment