Skip to content

Commit

Permalink
Fix Atomic32/AtomicWord on some platforms.
Browse files Browse the repository at this point in the history
- Removed the redefination in the atomicword_compat.h. Now Atomic32 will
alwyas be intptr_t in 32bit platforms, the bridge is no longer needed.
- Change NaCl 64bit to use intptr_t instead of int32 for Atomic32,
otherwise AtmoicWord APIs will miss the definations.

After this change, the AtmoicWord will always be either Atomic32 or
Atmoic64 depending on the platforms.
  • Loading branch information
liujisi committed Nov 8, 2017
1 parent 1144768 commit 181e284
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 131 deletions.
1 change: 0 additions & 1 deletion cmake/extract_includes.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h" in
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h" include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h" include\google\protobuf\stubs\atomicops_internals_arm_gcc.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h" include\google\protobuf\stubs\atomicops_internals_arm_qnx.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h" include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_c11_atomic.h" include\google\protobuf\stubs\atomicops_internals_generic_c11_atomic.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h" include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h" include\google\protobuf\stubs\atomicops_internals_mips_gcc.h
Expand Down
1 change: 0 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ nobase_include_HEADERS = \
google/protobuf/stubs/atomicops_internals_arm64_gcc.h \
google/protobuf/stubs/atomicops_internals_arm_gcc.h \
google/protobuf/stubs/atomicops_internals_arm_qnx.h \
google/protobuf/stubs/atomicops_internals_atomicword_compat.h \
google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h \
google/protobuf/stubs/atomicops_internals_generic_gcc.h \
google/protobuf/stubs/atomicops_internals_mips_gcc.h \
Expand Down
9 changes: 2 additions & 7 deletions src/google/protobuf/stubs/atomicops.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ namespace internal {
typedef intptr_t Atomic32;
typedef int64 Atomic64;
#else
typedef int32 Atomic32;
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
// means Atomic64 and AtomicWord should be the same type on 64-bit.
#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL)
// NaCl's intptr_t is not actually 64-bits on 64-bit!
// http://code.google.com/p/nativeclient/issues/detail?id=1162
// sparcv9's pointer type is 32bits
typedef intptr_t Atomic32;
typedef int64 Atomic64;
#else
typedef int32 Atomic32;
typedef intptr_t Atomic64;
#endif
#endif
Expand Down Expand Up @@ -229,12 +230,6 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#endif

// On some platforms we need additional declarations to make AtomicWord
// compatible with our other Atomic* types.
#if defined(GOOGLE_PROTOBUF_OS_APPLE)
#include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h>
#endif

#undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR

#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY
Expand Down
122 changes: 0 additions & 122 deletions src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h

This file was deleted.

0 comments on commit 181e284

Please sign in to comment.