Skip to content

Commit

Permalink
Remove references to HAVE_PTHREAD (#9100)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acozzette authored Oct 15, 2021
1 parent c01cd6e commit d049bce
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 30 deletions.
2 changes: 0 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,7 +45,6 @@ MSVC_COPTS = [
COPTS = select({
":msvc": MSVC_COPTS,
"//conditions:default": [
"-DHAVE_PTHREAD",
"-DHAVE_ZLIB",
"-Wmissing-field-initializers",
"-Woverloaded-virtual",
Expand Down
3 changes: 0 additions & 3 deletions Protobuf-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 0 additions & 14 deletions cmake/protobuf-module.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions protobuf-lite.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions protobuf.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions src/google/protobuf/stubs/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
#endif
#include <windows.h>
#define snprintf _snprintf // see comment in strutil.cc
#elif defined(HAVE_PTHREAD)
#include <pthread.h>
#else
#error "No suitable threading library available."
#endif
#if defined(__ANDROID__)
#include <android/log.h>
Expand Down

0 comments on commit d049bce

Please sign in to comment.