Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick portability fixes to 23.x line #12997

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Protobuf-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Pod::Spec.new do |s|

s.header_mappings_dir = 'src'

s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.tvos.deployment_target = '9.0'
s.watchos.deployment_target = '2.0'
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.13'
s.tvos.deployment_target = '12.0'
s.watchos.deployment_target = '6.0'

s.pod_target_xcconfig = {
# Do not let src/google/protobuf/stubs/time.h override system API
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/arena.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
new internal::ThreadLocalStorage<ThreadCache>();
return *thread_cache_->Get();
}
#elif defined(PROTOBUF_USE_DLLS)
#elif defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache;
return thread_cache;
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/reflection_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace internal {

#if !defined(PROTOBUF_NO_THREADLOCAL)

#if defined(PROTOBUF_USE_DLLS)
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
ReflectionMode& ScopedReflectionMode::reflection_mode() {
static PROTOBUF_THREAD_LOCAL ReflectionMode reflection_mode =
ReflectionMode::kDefault;
Expand Down
10 changes: 6 additions & 4 deletions src/google/protobuf/reflection_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,20 @@ class PROTOBUF_EXPORT ScopedReflectionMode final {
private:
#if !defined(PROTOBUF_NO_THREADLOCAL)
const ReflectionMode previous_mode_;
#if defined(PROTOBUF_USE_DLLS)
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
// Thread local variables cannot be exposed through MSVC DLL interface but we
// can wrap them in static functions.
static ReflectionMode& reflection_mode();
#else
PROTOBUF_CONSTINIT static PROTOBUF_THREAD_LOCAL ReflectionMode
reflection_mode_;
#endif // PROTOBUF_USE_DLLS
#endif // PROTOBUF_USE_DLLS && _MSC_VER
#endif // !PROTOBUF_NO_THREADLOCAL
};

#if !defined(PROTOBUF_NO_THREADLOCAL)

#if defined(PROTOBUF_USE_DLLS)
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)

inline ScopedReflectionMode::ScopedReflectionMode(ReflectionMode mode)
: previous_mode_(reflection_mode()) {
Expand Down Expand Up @@ -140,7 +142,7 @@ inline ReflectionMode ScopedReflectionMode::current_reflection_mode() {
return reflection_mode_;
}

#endif // PROTOBUF_USE_DLLS
#endif // PROTOBUF_USE_DLLS && _MSC_VER

#else

Expand Down
6 changes: 3 additions & 3 deletions src/google/protobuf/thread_safe_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ class PROTOBUF_EXPORT ThreadSafeArena {
// iOS does not support __thread keyword so we use a custom thread local
// storage class we implemented.
static ThreadCache& thread_cache();
#elif defined(PROTOBUF_USE_DLLS)
// Thread local variables cannot be exposed through DLL interface but we can
// wrap them in static functions.
#elif defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
// Thread local variables cannot be exposed through MSVC DLL interface but we
// can wrap them in static functions.
static ThreadCache& thread_cache();
#else
PROTOBUF_CONSTINIT static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
Expand Down