diff options
author | L. E. Segovia <amy@amyspark.me> | 2023-03-04 15:00:51 -0300 |
---|---|---|
committer | L. E. Segovia <amy@amyspark.me> | 2023-03-04 15:56:38 -0300 |
commit | 8ddc2681c06948eb20909cea70c1bffa10393d47 (patch) | |
tree | c34eb2959e928eb880002aa4291ed961c98890b3 | |
parent | cbde1ad9e1fc773a71c9c4b279b5d9fd9608796f (diff) | |
download | lcms2-8ddc2681c06948eb20909cea70c1bffa10393d47.tar.gz |
Fix compatibility with MSVCRT or pre-C11 compilers
-rw-r--r-- | meson.build | 7 | ||||
-rw-r--r-- | plugins/threaded/testbed/threaded_testbed.c | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/meson.build b/meson.build index 694895e..84a164d 100644 --- a/meson.build +++ b/meson.build @@ -3,6 +3,7 @@ project( 'c', version: '2.15', meson_version: '>=0.49.0', + default_options: ['c_std=gnu11'] ) version_components = meson.project_version().split('.') @@ -33,7 +34,7 @@ endif # Check for threadsafe variants of gmtime # MinGW needs _POSIX_C_SOURCE or _POSIX_THREAD_SAFE_FUNCTIONS defined -# to make gmtime_r available +# to make gmtime_r and pthread_time.h available if host_machine.system() == 'windows' and cc.get_argument_syntax() != 'msvc' cargs += ['-D_POSIX_C_SOURCE=199503L'] endif @@ -88,6 +89,10 @@ else cargs += '-DHasTHREADS=0' endif +if cc.has_header_symbol('time.h', 'timespec_get') + cargs += '-DHAVE_TIMESPEC_GET=1' +endif + win = import('windows') deps = [m_dep, threads_dep] diff --git a/plugins/threaded/testbed/threaded_testbed.c b/plugins/threaded/testbed/threaded_testbed.c index eae94c3..22e52ee 100644 --- a/plugins/threaded/testbed/threaded_testbed.c +++ b/plugins/threaded/testbed/threaded_testbed.c @@ -50,7 +50,7 @@ static struct timespec start, finish; cmsINLINE void MeasureTimeStart(void) { -#ifdef CMS_IS_WINDOWS_ +#if defined(HAVE_TIMESPEC_GET) timespec_get(&start, TIME_UTC); #else clock_gettime(CLOCK_MONOTONIC, &start); @@ -61,7 +61,7 @@ cmsINLINE double MeasureTimeStop(void) { double elapsed; -#ifdef CMS_IS_WINDOWS_ +#if defined(HAVE_TIMESPEC_GET) timespec_get(&finish, TIME_UTC); #else clock_gettime(CLOCK_MONOTONIC, &finish); |