On 12/11/20 17:34 +0000, Jonathan Wakely wrote: >On 11/11/20 19:08 +0100, Jakub Jelinek via Libstdc++ wrote: >>On Wed, Nov 11, 2020 at 05:24:42PM +0000, Jonathan Wakely wrote: >>>--- a/libgcc/gthr-posix.h >>>+++ b/libgcc/gthr-posix.h >>>@@ -684,7 +684,14 @@ __gthread_equal (__gthread_t __t1, __gthread_t __t2) >>> static inline __gthread_t >>> __gthread_self (void) >>> { >>>+#if __GLIBC_PREREQ(2, 27) >> >>What if it is a non-glibc system where __GLIBC_PREREQ macro isn't defined? >>I think you'd get then >>error: missing binary operator before token "(" >>So I think you want >>#if defined __GLIBC__ && defined __GLIBC_PREREQ >>#if __GLIBC_PREREQ(2, 27) >> return pthread_self (); >>#else >> return __gthrw_(pthread_self) (); >>#else >> return __gthrw_(pthread_self) (); >>#endif >>or similar. > > >Here's a fixed version of the patch. > >I've moved the glibc-specific code in this_thread::get_id() into a new >macro defined in config/os/gnu-linux/os_defines.h (where we already >know we are dealing with glibc). That means we don't do the >__GLIBC_PREREQ check directly in , it's hidden away in a >target-specific header. > >Tested powerpc64le-linux (glibc 2.17 and 2.32), sparc-solaris2.11 and >powerpc-aix. I've committed this version which only fixes this_thread::get_id() in libstdc++, and doesn't change __gthread_self in gthr-posix.h Due to a recent change to replace other uses of __gthread_self with calls to this_thread::get_id(), fixing it there fixes all uses in libstdc++. Tested x86_64-linux, powerpc-aix, sparc-solaris2.11, committed to trunk.