From d049bce84405a26996979de1e9333c7d0fc7378a Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 15 Oct 2021 13:10:38 -0700 Subject: [PATCH] Remove references to HAVE_PTHREAD (#9100) This is based on @haberman's changes in #8257. Now that we're using std::mutex we no longer need to check whether pthreads are available, so this commit removes references to HAVE_PTHREAD. I left the autotools build alone, though, since we are likely to drop support for it soon anyway. --- BUILD | 2 -- Protobuf-C++.podspec | 3 --- cmake/CMakeLists.txt | 3 --- cmake/protobuf-module.cmake.in | 14 -------------- protobuf-lite.pc.in | 4 ++-- protobuf.pc.in | 4 ++-- src/google/protobuf/stubs/common.cc | 4 ---- 7 files changed, 4 insertions(+), 30 deletions(-) diff --git a/BUILD b/BUILD index 389882b06..1690d4219 100644 --- a/BUILD +++ b/BUILD @@ -26,7 +26,6 @@ ZLIB_DEPS = ["@zlib//:zlib"] ################################################################################ MSVC_COPTS = [ - "/DHAVE_PTHREAD", "/wd4018", # -Wno-sign-compare "/wd4065", # switch statement contains 'default' but no 'case' labels "/wd4146", # unary minus operator applied to unsigned type, result still unsigned @@ -46,7 +45,6 @@ MSVC_COPTS = [ COPTS = select({ ":msvc": MSVC_COPTS, "//conditions:default": [ - "-DHAVE_PTHREAD", "-DHAVE_ZLIB", "-Wmissing-field-initializers", "-Woverloaded-virtual", diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index f285e58af..9b8fae51a 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -35,9 +35,6 @@ Pod::Spec.new do |s| # Do not let src/google/protobuf/stubs/time.h override system API 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', - - # Configure tool is not being used for Xcode. When building, assume pthread is supported. - 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "HAVE_PTHREAD=1"', } end diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 94dc810cc..51e8478f6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -127,9 +127,6 @@ if (protobuf_DISABLE_RTTI) endif() find_package(Threads REQUIRED) -if (CMAKE_USE_PTHREADS_INIT) - add_definitions(-DHAVE_PTHREAD) -endif (CMAKE_USE_PTHREADS_INIT) set(_protobuf_FIND_ZLIB) if (protobuf_WITH_ZLIB) diff --git a/cmake/protobuf-module.cmake.in b/cmake/protobuf-module.cmake.in index 810256e54..09b9d29c2 100644 --- a/cmake/protobuf-module.cmake.in +++ b/cmake/protobuf-module.cmake.in @@ -110,16 +110,6 @@ function(_protobuf_find_libraries name filename) endif() endfunction() -# Internal function: find threads library -function(_protobuf_find_threads) - set(CMAKE_THREAD_PREFER_PTHREAD TRUE) - find_package(Threads) - if(Threads_FOUND) - list(APPEND PROTOBUF_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) - set(PROTOBUF_LIBRARIES "${PROTOBUF_LIBRARIES}" PARENT_SCOPE) - endif() -endfunction() - # # Main. # @@ -139,10 +129,6 @@ _protobuf_find_libraries(Protobuf_LITE protobuf-lite) # The Protobuf Protoc Library _protobuf_find_libraries(Protobuf_PROTOC protoc) -if(UNIX) - _protobuf_find_threads() -endif() - # Set the include directory get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) diff --git a/protobuf-lite.pc.in b/protobuf-lite.pc.in index 68a2bb455..f92e4ad9d 100644 --- a/protobuf-lite.pc.in +++ b/protobuf-lite.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: Protocol Buffers Description: Google's Data Interchange Format Version: @VERSION@ -Libs: -L${libdir} -lprotobuf-lite @PTHREAD_LIBS@ -Cflags: -I${includedir} @PTHREAD_CFLAGS@ +Libs: -L${libdir} -lprotobuf-lite +Cflags: -I${includedir} Conflicts: protobuf diff --git a/protobuf.pc.in b/protobuf.pc.in index 055a9d056..e9bef5d0f 100644 --- a/protobuf.pc.in +++ b/protobuf.pc.in @@ -6,8 +6,8 @@ includedir=@includedir@ Name: Protocol Buffers Description: Google's Data Interchange Format Version: @VERSION@ -Libs: -L${libdir} -lprotobuf @PTHREAD_LIBS@ +Libs: -L${libdir} -lprotobuf Libs.private: @LIBS@ -Cflags: -I${includedir} @PTHREAD_CFLAGS@ +Cflags: -I${includedir} Conflicts: protobuf-lite diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 9067818a5..82d46531f 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -44,10 +44,6 @@ #endif #include #define snprintf _snprintf // see comment in strutil.cc -#elif defined(HAVE_PTHREAD) -#include -#else -#error "No suitable threading library available." #endif #if defined(__ANDROID__) #include