c11: Getting the macro guard of HAVE_PTHREAD in c11/threads.h to be consistence with util/u_uthread.h

The macro guard of #if defined(_WIN32) && !defined(__CYGWIN__) is comes from yohhoy's implementation
and that's not consistence with util/u_uthread.h, this caused it's hard to understand.
Now we change the behavior that's always rely on how meson detecting HAVE_PTHREAD.

So we always disable detecting of threads on Win32 as it's always included in the kernel32 library to
avoid detecting pthreads in mingw.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18425>
This commit is contained in:
Yonggang Luo
2022-09-15 22:53:03 +08:00
committed by Marge Bot
parent 54beddb5d2
commit 399dc71a30
4 changed files with 15 additions and 8 deletions

View File

@@ -1598,8 +1598,15 @@ elif with_shader_cache
error('Shader Cache requires compression')
endif
dep_thread = dependency('threads')
if dep_thread.found() and host_machine.system() != 'windows'
if host_machine.system() == 'windows'
# For MSVC and MinGW we aren't using pthreads, and dependency('threads') will add linkage
# to pthread for MinGW, so leave the dependency null_dep for Windows. For Windows linking to
# kernel32 is enough for c11/threads.h and it's already linked by meson by default
dep_thread = null_dep
else
dep_thread = dependency('threads')
endif
if dep_thread.found()
pre_args += '-DHAVE_PTHREAD'
if host_machine.system() != 'netbsd' and cc.has_function(
'pthread_setaffinity_np',