c11: Implement c11/time.h with c11/impl/time.c

Create c11/time.h instead of put timespec_get in `c11/threads.h`

Creating impl folder is used to avoid `#include <time.h>` point the c11/time.h file

Detecting if `struct timespec` present with meson
Define TIME_UTC in `c11/time.h` instead `c11/threads.h`
Define `struct timespec` in `c11/time.h` when not present.
Implement timespec_get in c11/impl/time.c instead threads.h

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15497>
This commit is contained in:
Yonggang Luo
2022-02-19 13:19:08 +08:00
committed by Marge Bot
parent fe01757ddf
commit b2ddec4e98
13 changed files with 144 additions and 53 deletions

View File

@@ -1453,6 +1453,10 @@ foreach f, prefix: functions_to_detect
endif
endforeach
if cc.has_header_symbol('time.h', 'struct timespec')
pre_args += '-DHAVE_STRUCT_TIMESPEC'
endif
if cc.has_header_symbol('errno.h', 'program_invocation_name',
args : '-D_GNU_SOURCE')
pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'