From f22c980173cf825bb41606fa897b462b08a7e6d9 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Mon, 28 Jul 2025 10:53:32 +0000 Subject: [PATCH] meson: add 'threads' dependency for pthread_* function checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the correct detection of these functions on some platforms like Alma Linux 8. Co-authored-by: Aydın Mercan --- meson.build | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index c6859dec47..a920320a06 100644 --- a/meson.build +++ b/meson.build @@ -453,16 +453,6 @@ foreach fn, header : { 'flockfile': '#include ', 'getc_unlocked': '#include ', - # Thread control - 'pthread_attr_getstacksize': '#include ', - 'pthread_attr_setstacksize': '#include ', - 'pthread_barrier_init': '#include ', - 'pthread_set_name_np': '#include ', - 'pthread_setname_np': '#include ', - 'pthread_spin_init': '#include ', - 'pthread_yield': '#include ', - 'pthread_yield_np': '#include ', - # Processor control 'cpuset_getaffinity': '#include ', 'sched_getaffinity': '#include ', @@ -524,9 +514,31 @@ endif ### null_dep = dependency('', required: false) -thread_dep = dependency('threads') m_dep = cc.find_library('m', required: false) +## Threads +thread_dep = dependency('threads') + +foreach fn : [ + 'pthread_attr_getstacksize', + 'pthread_attr_setstacksize', + 'pthread_barrier_init', + 'pthread_set_name_np', + 'pthread_setname_np', + 'pthread_spin_init', + 'pthread_yield', + 'pthread_yield_np', +] + if cc.has_function( + fn, + prefix: '#include ', + args: sys_defines, + dependencies: thread_dep, + ) + config.set('HAVE_@0@'.format(fn.to_upper()), 1) + endif +endforeach + ## OpenSSL openssl_dep = [ dependency('libcrypto', version: '>=1.1.1'),