From 881d590d23730fff6bf8f37e10d998226180cd65 Mon Sep 17 00:00:00 2001 From: Tavian Barnes <tavianator@tavianator.com> Date: Thu, 10 Oct 2024 10:20:11 -0400 Subject: xtime: Add a wrapper for timer_create()/setitimer() setitimer() is obsolescent in POSIX 2008 and removed from POSIX 2024. However, at least macOS doesn't implement the new timer_create() API, so we still need the setitimer() fallback. --- build/has/timer-create.c | 9 +++++++++ build/header.mk | 1 + 2 files changed, 10 insertions(+) create mode 100644 build/has/timer-create.c (limited to 'build') diff --git a/build/has/timer-create.c b/build/has/timer-create.c new file mode 100644 index 0000000..d5354c3 --- /dev/null +++ b/build/has/timer-create.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <time.h> + +int main(void) { + timer_t timer; + return timer_create(CLOCK_REALTIME, NULL, &timer); +} diff --git a/build/header.mk b/build/header.mk index abec00f..88a8986 100644 --- a/build/header.mk +++ b/build/header.mk @@ -52,6 +52,7 @@ HEADERS := \ gen/has/strtofflags.h \ gen/has/tcgetwinsize.h \ gen/has/timegm.h \ + gen/has/timer-create.h \ gen/has/tm-gmtoff.h \ gen/has/uselocale.h -- cgit v1.2.3