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.
This commit is contained in:
Adam Cozzette 2021-10-15 13:10:38 -07:00 committed by GitHub
parent c01cd6ec79
commit d049bce844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 4 additions and 30 deletions

2
BUILD
View File

@ -26,7 +26,6 @@ ZLIB_DEPS = ["@zlib//:zlib"]
################################################################################ ################################################################################
MSVC_COPTS = [ MSVC_COPTS = [
"/DHAVE_PTHREAD",
"/wd4018", # -Wno-sign-compare "/wd4018", # -Wno-sign-compare
"/wd4065", # switch statement contains 'default' but no 'case' labels "/wd4065", # switch statement contains 'default' but no 'case' labels
"/wd4146", # unary minus operator applied to unsigned type, result still unsigned "/wd4146", # unary minus operator applied to unsigned type, result still unsigned
@ -46,7 +45,6 @@ MSVC_COPTS = [
COPTS = select({ COPTS = select({
":msvc": MSVC_COPTS, ":msvc": MSVC_COPTS,
"//conditions:default": [ "//conditions:default": [
"-DHAVE_PTHREAD",
"-DHAVE_ZLIB", "-DHAVE_ZLIB",
"-Wmissing-field-initializers", "-Wmissing-field-initializers",
"-Woverloaded-virtual", "-Woverloaded-virtual",

View File

@ -35,9 +35,6 @@ Pod::Spec.new do |s|
# Do not let src/google/protobuf/stubs/time.h override system API # Do not let src/google/protobuf/stubs/time.h override system API
'USE_HEADERMAP' => 'NO', 'USE_HEADERMAP' => 'NO',
'ALWAYS_SEARCH_USER_PATHS' => '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 end

View File

@ -127,9 +127,6 @@ if (protobuf_DISABLE_RTTI)
endif() endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (CMAKE_USE_PTHREADS_INIT)
add_definitions(-DHAVE_PTHREAD)
endif (CMAKE_USE_PTHREADS_INIT)
set(_protobuf_FIND_ZLIB) set(_protobuf_FIND_ZLIB)
if (protobuf_WITH_ZLIB) if (protobuf_WITH_ZLIB)

View File

@ -110,16 +110,6 @@ function(_protobuf_find_libraries name filename)
endif() endif()
endfunction() 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. # Main.
# #
@ -139,10 +129,6 @@ _protobuf_find_libraries(Protobuf_LITE protobuf-lite)
# The Protobuf Protoc Library # The Protobuf Protoc Library
_protobuf_find_libraries(Protobuf_PROTOC protoc) _protobuf_find_libraries(Protobuf_PROTOC protoc)
if(UNIX)
_protobuf_find_threads()
endif()
# Set the include directory # Set the include directory
get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES) INTERFACE_INCLUDE_DIRECTORIES)

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: Protocol Buffers Name: Protocol Buffers
Description: Google's Data Interchange Format Description: Google's Data Interchange Format
Version: @VERSION@ Version: @VERSION@
Libs: -L${libdir} -lprotobuf-lite @PTHREAD_LIBS@ Libs: -L${libdir} -lprotobuf-lite
Cflags: -I${includedir} @PTHREAD_CFLAGS@ Cflags: -I${includedir}
Conflicts: protobuf Conflicts: protobuf

View File

@ -6,8 +6,8 @@ includedir=@includedir@
Name: Protocol Buffers Name: Protocol Buffers
Description: Google's Data Interchange Format Description: Google's Data Interchange Format
Version: @VERSION@ Version: @VERSION@
Libs: -L${libdir} -lprotobuf @PTHREAD_LIBS@ Libs: -L${libdir} -lprotobuf
Libs.private: @LIBS@ Libs.private: @LIBS@
Cflags: -I${includedir} @PTHREAD_CFLAGS@ Cflags: -I${includedir}
Conflicts: protobuf-lite Conflicts: protobuf-lite

View File

@ -44,10 +44,6 @@
#endif #endif
#include <windows.h> #include <windows.h>
#define snprintf _snprintf // see comment in strutil.cc #define snprintf _snprintf // see comment in strutil.cc
#elif defined(HAVE_PTHREAD)
#include <pthread.h>
#else
#error "No suitable threading library available."
#endif #endif
#if defined(__ANDROID__) #if defined(__ANDROID__)
#include <android/log.h> #include <android/log.h>