Page MenuHomeFreeBSD

D38460.id117616.diff
No OneTemporary

D38460.id117616.diff

diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -154,6 +154,7 @@
telldir.c \
termios.c \
time.c \
+ timerfd.c \
times.c \
timespec_get.c \
timezone.c \
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -443,6 +443,9 @@
sched_getaffinity;
sched_setaffinity;
sched_getcpu;
+ timerfd_create;
+ timerfd_gettime;
+ timerfd_settime;
versionsort;
__cpuset_alloc;
__cpuset_free;
diff --git a/lib/libc/gen/timerfd.c b/lib/libc/gen/timerfd.c
new file mode 100644
--- /dev/null
+++ b/lib/libc/gen/timerfd.c
@@ -0,0 +1,59 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Jake Freeland <jfree@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/ioctl.h>
+#include <sys/specialfd.h>
+#include <sys/timerfd.h>
+#include "libc_private.h"
+
+int
+timerfd_create(int clockid, int flags)
+{
+ struct specialfd_timerfd args;
+
+ args.clockid = clockid;
+ args.flags = flags;
+ return (__sys___specialfd(SPECIALFD_TIMERFD, &args, sizeof(args)));
+}
+
+int
+timerfd_gettime(int fd, struct itimerspec *curr_value)
+{
+ return (ioctl(fd, TFD_GETTIME, curr_value));
+}
+
+int
+timerfd_settime(int fd, int flags, const struct itimerspec *new_value,
+ struct itimerspec *old_value)
+{
+ struct timerfd_settime_args args;
+
+ args.flags = flags;
+ args.new_value = new_value;
+ args.old_value = old_value;
+ return (ioctl(fd, TFD_SETTIME, &args));
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 2, 6:20 PM (10 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29142160
Default Alt Text
D38460.id117616.diff (2 KB)

Event Timeline