From: LinuxLegend Date: Wed, 30 Mar 2022 16:56:38 +0000 (-0600) Subject: Added tinycthread change for checking if C11 supports for Threads.h exists X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=02c3e6daad886ea516b227bbc689cfe84c99645b;p=jp%2Fvkhelpers.git Added tinycthread change for checking if C11 supports for Threads.h exists --- diff --git a/meson.build b/meson.build index 4ce3a84..9bae7ec 100644 --- a/meson.build +++ b/meson.build @@ -156,7 +156,6 @@ vkh_dependencies = [vulkan_dep, threads_dep] pkg_conf = import('pkgconfig') - vkh_src = [ 'src/vkh_app.c', 'src/vkh_buffer.c', @@ -169,7 +168,7 @@ vkh_src = [ 'src/VmaUsage.cpp' ] -if (host_machine.system() == 'windows') +if (has_c11_threads_support == false) vkh_src += 'src/deps/tinycthread.c' endif @@ -180,8 +179,8 @@ vkh_include = [ ] vkh_shared_library = shared_library('vkh', - c_args: [vkh_compile_options, '-DVKH_SHARED_BUILD'], - cpp_args: [vkh_compile_options, '-DVKH_SHARED_BUILD'], + c_args: [vkh_compile_options, has_c11_threads_support_defines, '-DVKH_SHARED_BUILD'], + cpp_args: [vkh_compile_options, has_c11_threads_support_defines, '-DVKH_SHARED_BUILD'], build_by_default: true, install: true, soversion: lib_so_version, @@ -191,8 +190,8 @@ vkh_shared_library = shared_library('vkh', ) vkh_static_library = static_library('vkh', - c_args: [vkh_compile_options, '-DVKH_STATIC_BUILD'], - cpp_args: [vkh_compile_options, '-DVKH_STATIC_BUILD'], + c_args: [vkh_compile_options, has_c11_threads_support_defines, '-DVKH_STATIC_BUILD'], + cpp_args: [vkh_compile_options, has_c11_threads_support_defines, '-DVKH_STATIC_BUILD'], build_by_default: true, install: true, sources: vkh_src, diff --git a/src/deps/tinycthread.c b/src/deps/tinycthread.c index f9cea2e..6a45784 100644 --- a/src/deps/tinycthread.c +++ b/src/deps/tinycthread.c @@ -21,6 +21,7 @@ freely, subject to the following restrictions: distribution. */ +#if defined(STDC_VERSION) && (STDC_VERSION >= 201102L) && !defined(STDC_NO_THREADS) /* 2013-01-06 Camilla Löwy * * Added casts from time_t to DWORD to avoid warnings on VC++. @@ -591,4 +592,4 @@ int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts) return 0; } #endif // _TTHREAD_EMULATE_CLOCK_GETTIME_ - +#endif // END OF STDC_NO_THREADS \ No newline at end of file diff --git a/src/deps/tinycthread.h b/src/deps/tinycthread.h index 42958c3..71b3e72 100644 --- a/src/deps/tinycthread.h +++ b/src/deps/tinycthread.h @@ -23,7 +23,7 @@ freely, subject to the following restrictions: #ifndef _TINYCTHREAD_H_ #define _TINYCTHREAD_H_ - +#if defined(STDC_VERSION) && (STDC_VERSION >= 201102L) && !defined(STDC_NO_THREADS) /** * @file * @mainpage TinyCThread API Reference @@ -438,6 +438,7 @@ void *tss_get(tss_t key); */ int tss_set(tss_t key, void *val); - -#endif /* _TINYTHREAD_H_ */ - +#else +#include +#endif +#endif /* _TINYTHREAD_H_ */ \ No newline at end of file