amputate HAVE_FORK checking

Pretty much everything has fork, except windows. Which is much simpler
to test at compile time, then duplicating and complicating the test at
configure time.
This commit is contained in:
Aliaksey Kandratsenka 2024-01-25 16:10:30 -05:00
parent 8cc2d93055
commit 79b6ad2ab5
5 changed files with 20 additions and 31 deletions

View File

@ -199,7 +199,6 @@ set(CMAKE_EXTRA_INCLUDE_FILES)
check_function_exists("sbrk" HAVE_SBRK) # for tcmalloc to get memory
check_function_exists("__sbrk" HAVE___SBRK) # for tcmalloc to get memory
check_function_exists("geteuid" HAVE_GETEUID) # for turning off services when run as root
check_function_exists("fork" HAVE_FORK) # for the pthread_atfork setup
check_include_file("features.h" HAVE_FEATURES_H) # for vdso_support.h, Where __GLIBC__ is defined
check_include_file("malloc.h" HAVE_MALLOC_H) # some systems define stuff there, others not
check_include_file("glob.h" HAVE_GLOB_H) # for heap-profile-table (cleaning up profiles)

View File

@ -74,9 +74,6 @@
/* Define to 1 if you have the <features.h> header file. */
#cmakedefine HAVE_FEATURES_H
/* Define to 1 if you have the `fork' function. */
#cmakedefine HAVE_FORK
/* Define to 1 if you have the `geteuid' function. */
#cmakedefine HAVE_GETEUID

View File

@ -46,26 +46,6 @@
namespace tcmalloc {
#if defined(HAVE_FORK) && defined(HAVE_PTHREAD)
// These following two functions are registered via pthread_atfork to make
// sure the central_cache locks remain in a consisten state in the forked
// version of the thread.
void CentralCacheLockAll() NO_THREAD_SAFETY_ANALYSIS
{
Static::pageheap_lock()->Lock();
for (int i = 0; i < Static::num_size_classes(); ++i)
Static::central_cache()[i].Lock();
}
void CentralCacheUnlockAll() NO_THREAD_SAFETY_ANALYSIS
{
for (int i = 0; i < Static::num_size_classes(); ++i)
Static::central_cache()[i].Unlock();
Static::pageheap_lock()->Unlock();
}
#endif
bool Static::inited_;
SizeMap Static::sizemap_;
CentralFreeListPadded Static::central_cache_[kClassSizesMax];
@ -108,9 +88,27 @@ void Static::InitStaticVars() {
DLL_Init(&sampled_objects_);
}
// These following two functions are registered via pthread_atfork to
// make sure the central_cache locks remain in a consisten state in
// the forked version of the thread. Also our OSX integration uses it
// for mi_force_lock.
void CentralCacheLockAll() NO_THREAD_SAFETY_ANALYSIS
{
Static::pageheap_lock()->Lock();
for (int i = 0; i < Static::num_size_classes(); ++i)
Static::central_cache()[i].Lock();
}
void CentralCacheUnlockAll() NO_THREAD_SAFETY_ANALYSIS
{
for (int i = 0; i < Static::num_size_classes(); ++i)
Static::central_cache()[i].Unlock();
Static::pageheap_lock()->Unlock();
}
void Static::InitLateMaybeRecursive() {
#if defined(HAVE_FORK) && defined(HAVE_PTHREAD) \
&& !defined(__APPLE__) && !defined(TCMALLOC_NO_ATFORK) \
#if !defined(__APPLE__) && !defined(_WIN32) && !defined(TCMALLOC_NO_ATFORK) \
&& !defined(PTHREADS_CRASHES_IF_RUN_TOO_EARLY)
// OSX has it's own way of handling atfork in malloc (see
// libc_override_osx.h).

View File

@ -93,9 +93,6 @@
/* Define to 1 if you have the <features.h> header file. */
/* #undef HAVE_FEATURES_H */
/* Define to 1 if you have the `fork' function. */
/* #undef HAVE_FORK */
/* Define to 1 if you have the `geteuid' function. */
/* #undef HAVE_GETEUID */

View File

@ -54,8 +54,6 @@
# define _WIN32_WINNT 0x0501
#endif
#undef HAVE_FORK
#include "windows/port.h"
#endif /* __MINGW32__ */