From: Ralph Boehme Date: Tue, 15 Nov 2022 10:30:28 +0000 (+0100) Subject: libreplace: require TLS support if pthread support is available X-Git-Tag: talloc-2.4.0~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29a99e5e123465145f0faf66bddd94ecc26d15ff;p=thirdparty%2Fsamba.git libreplace: require TLS support if pthread support is available Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/lib/replace/replace.h b/lib/replace/replace.h index de50761d000..b15f3d14c8a 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -1082,4 +1082,16 @@ static inline bool hex_byte(const char *in, uint8_t *out) #include #endif +/* + * This handles the case of missing pthread support and ensures code can use + * __thread unconditionally, such that when built on a platform without pthread + * support, the __thread qualifier is an empty define. + */ +#ifndef HAVE___THREAD +# ifdef HAVE_PTHREAD +# error Configure failed to detect pthread library with missing TLS support +# endif +#define HAVE___THREAD +#endif + #endif /* _LIBREPLACE_REPLACE_H */ diff --git a/lib/replace/wscript b/lib/replace/wscript index 18059fab617..82c5a8a477b 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -686,6 +686,9 @@ syscall(SYS_copy_file_range,0,NULL,0,NULL,0,0); addmain=False, msg='Checking for __thread local storage') + if conf.CONFIG_SET('HAVE_PTHREAD') and not conf.CONFIG_SET('HAVE___THREAD'): + conf.fatal('Missing required TLS support in pthread library') + conf.CHECK_FUNCS_IN('crypt', 'crypt', checklibc=True) conf.CHECK_FUNCS_IN('crypt_r', 'crypt', checklibc=True) conf.CHECK_FUNCS_IN('crypt_rn', 'crypt', checklibc=True)