summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2022-11-15 11:30:28 +0100
committerRalph Boehme <slow@samba.org>2023-01-05 11:33:37 +0000
commit29a99e5e123465145f0faf66bddd94ecc26d15ff (patch)
tree84decdfbc2349c07e4487dc6b76ca15d477cfa70 /lib/replace
parent73e7d3731d87b3c3ed907e718fcba5ed2e293e51 (diff)
downloadsamba-29a99e5e123465145f0faf66bddd94ecc26d15ff.tar.gz
libreplace: require TLS support if pthread support is available
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/replace.h12
-rw-r--r--lib/replace/wscript3
2 files changed, 15 insertions, 0 deletions
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 <sys/atomic.h>
#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)