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:
11
meson.build
11
meson.build
@@ -1598,8 +1598,15 @@ elif with_shader_cache
|
|||||||
error('Shader Cache requires compression')
|
error('Shader Cache requires compression')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
dep_thread = dependency('threads')
|
if host_machine.system() == 'windows'
|
||||||
if dep_thread.found() and 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'
|
pre_args += '-DHAVE_PTHREAD'
|
||||||
if host_machine.system() != 'netbsd' and cc.has_function(
|
if host_machine.system() != 'netbsd' and cc.has_function(
|
||||||
'pthread_setaffinity_np',
|
'pthread_setaffinity_np',
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#ifndef HAVE_TIMESPEC_GET
|
#ifndef HAVE_TIMESPEC_GET
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(HAVE_PTHREAD)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(HAVE_PTHREAD)
|
||||||
# include <io.h> /* close */
|
# include <io.h> /* close */
|
||||||
# include <process.h> /* _exit */
|
# include <process.h> /* _exit */
|
||||||
#elif defined(HAVE_PTHREAD)
|
#elif defined(HAVE_PTHREAD)
|
||||||
@@ -97,7 +97,7 @@ extern "C" {
|
|||||||
typedef void (*tss_dtor_t)(void *);
|
typedef void (*tss_dtor_t)(void *);
|
||||||
typedef int (*thrd_start_t)(void *);
|
typedef int (*thrd_start_t)(void *);
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(HAVE_PTHREAD)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
void *Ptr;
|
void *Ptr;
|
||||||
|
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
#if DETECT_OS_LINUX && !defined(ANDROID)
|
#if DETECT_OS_LINUX && !defined(ANDROID)
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
#elif defined(_WIN32) && !defined(HAVE_PTHREAD)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ util_get_current_cpu(void)
|
|||||||
#if DETECT_OS_LINUX && !defined(ANDROID)
|
#if DETECT_OS_LINUX && !defined(ANDROID)
|
||||||
return sched_getcpu();
|
return sched_getcpu();
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
#elif defined(_WIN32) && !defined(HAVE_PTHREAD)
|
||||||
return GetCurrentProcessorNumber();
|
return GetCurrentProcessorNumber();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -188,7 +188,7 @@ util_set_thread_affinity(thrd_t thread,
|
|||||||
}
|
}
|
||||||
return pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset) == 0;
|
return pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset) == 0;
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__)
|
#elif defined(_WIN32) && !defined(HAVE_PTHREAD)
|
||||||
DWORD_PTR m = mask[0];
|
DWORD_PTR m = mask[0];
|
||||||
|
|
||||||
if (sizeof(m) > 4 && num_mask_bits > 32)
|
if (sizeof(m) > 4 && num_mask_bits > 32)
|
||||||
|
Reference in New Issue
Block a user