From a12c7fd184e8a8251b1a3e9c0f681873995ec204 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 21 Jun 2019 04:35:41 +0200 Subject: threads-h: Define 'thread_local' if and only it actually works. * m4/threads.m4 (gl_THREAD_LOCAL_DEFINITION): New macro. (gl_THREADS_H): Define _Thread_local to __thread also for ARM C, IBM C, Oracle Solaris Studio C. Compile a simple program, to see whether _Thread_local basically works. Set HAVE_THREAD_LOCAL and LIBTHREADLOCAL. (gl_THREADS_H_DEFAULTS): Initialize HAVE_THREAD_LOCAL. * lib/threads.in.h (thread_local): Undefine if it does not work. * modules/threads-h (Makefile.am): Substitute HAVE_THREAD_LOCAL. (Link): Mention LIBTHREADLOCAL. * tests/test-threads.c: Don't check that thread_local is defined. * tests/test-thread_local.c: New file. * modules/threads-h-tests (Files): Add it and macros.h. (Depends-on): Add thrd and stdint. (configure.ac): Test whether 'alarm' is declared. (Makefile.am): Arrange to build and link test-thread_local. * doc/posix-headers/threads.texi: Mention the platforms that don't support 'thread_local'. --- modules/threads-h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/threads-h') diff --git a/modules/threads-h b/modules/threads-h index 238955c6b5..c5af53e812 100644 --- a/modules/threads-h +++ b/modules/threads-h @@ -50,6 +50,7 @@ threads.h: threads.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(_NORETURN_H -e 's/@''GNULIB_MTX''@/$(GNULIB_MTX)/g' \ -e 's/@''GNULIB_THRD''@/$(GNULIB_THRD)/g' \ -e 's/@''GNULIB_TSS''@/$(GNULIB_TSS)/g' \ + -e 's|@''HAVE_THREAD_LOCAL''@|$(HAVE_THREAD_LOCAL)|g' \ -e 's|@''BROKEN_THRD_START_T''@|$(BROKEN_THRD_START_T)|g' \ -e 's|@''REPLACE_THRD_CREATE''@|$(REPLACE_THRD_CREATE)|g' \ -e 's|@''REPLACE_THRD_CURRENT''@|$(REPLACE_THRD_CURRENT)|g' \ @@ -65,6 +66,7 @@ Include: Link: +$(LIBTHREADLOCAL) if you use the thread_local macro License: LGPLv2+ -- cgit v1.2.1