From 3dcb3c95ea4e9561a8da9c9256ce1148aa571b63 Mon Sep 17 00:00:00 2001 From: zrj Date: Wed, 2 May 2018 16:18:32 +0300 Subject: [PATCH] gcc80: Add alternative variant of pthread presence checking. Port the 5f76495ba37ea12fb60cf57228cc78b83d889fb from gcc50. --- contrib/gcc-8.0/libgcc/gthr-posix.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/contrib/gcc-8.0/libgcc/gthr-posix.h b/contrib/gcc-8.0/libgcc/gthr-posix.h index e2f952f6c1..cdc8b2a9cb 100644 --- a/contrib/gcc-8.0/libgcc/gthr-posix.h +++ b/contrib/gcc-8.0/libgcc/gthr-posix.h @@ -209,6 +209,30 @@ __gthread_active_p (void) return __gthread_active_latest_value != 0; } +#elif defined(__DragonFly__) && defined(_AVOID_WEAKREF) + +/* + * On DragonFly libpthread always brings libc so __isthreaded is available. + * __isthreaded is a special variable that is set by libpthread lib. + * Mainly for libgcc_pic.a usage case, ld.gold is not ready to handle such + * static relocatable lib in pthread+cxx shared lib linkages. + * Everything else should use weakref on pthread_cancel below. + */ + +#if defined(__cplusplus) +extern "C" { +#endif +extern int __isthreaded; /* from libc */ +#if defined(__cplusplus) +} +#endif + +static inline int +__gthread_active_p (void) +{ + return (__isthreaded != 0); +} + #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must -- 2.41.0