From 88cc61e3e6ba7ace4db0fe3702c506fbb13bb628 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 20 Jun 2024 22:09:55 -0700 Subject: [PATCH] meson: simplify thread_local check Use a simple loop. Signed-off-by: Rosen Penev --- meson.build | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/meson.build b/meson.build index 2d1c9173..e1312fb6 100644 --- a/meson.build +++ b/meson.build @@ -294,44 +294,12 @@ endif ### thread local storage if want_tls - tls_src = ''' -#include -int main() -{ - _Thread_local int v; - return 0; -} - ''' - res = cc.compiles(tls_src, name: '_Thread_local') - if res == true - config_h.set('XML_THREAD_LOCAL', '_Thread_local') - else - tls_src = ''' -int main() -{ - __thread int v; - return 0; -} - ''' - res = cc.compiles(tls_src, name: '__thread') - if res == true - config_h.set('XML_THREAD_LOCAL', '__thread') - else - tls_src = ''' -int main() -{ - __declspec(thread) int v; - return 0; -} - ''' - res = cc.compiles(tls_src, name: '__declspec(thread)') - if res == true - config_h.set('XML_THREAD_LOCAL', '__declspec(thread)') - else - want_tls = false - endif + foreach t : ['_Thread_local', '__thread', '__declspec(thread)'] + if cc.compiles('@0@ int v;'.format(t)) + config_h.set('XML_THREAD_LOCAL', t) + break endif - endif + endforeach endif ### __attribute__((destructor))