aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/specialfd.h
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-12-23 14:14:04 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-12-27 10:57:26 +0000
commit7a202823aa54ba18c485bdbcf355269bcfee1ab9 (patch)
treea6a53d2d79199defb8e4b96dae58c166f08788cf /sys/sys/specialfd.h
parent7cb901bf227f1591f208a9df5ddc948c6124e0a8 (diff)
downloadsrc-7a202823aa54ba18c485bdbcf355269bcfee1ab9.tar.gz
src-7a202823aa54ba18c485bdbcf355269bcfee1ab9.zip
Expose eventfd in the native API/ABI using a new __specialfd syscall
eventfd is a Linux system call that produces special file descriptors for event notification. When porting Linux software, it is currently usually emulated by epoll-shim on top of kqueues. Unfortunately, kqueues are not passable between processes. And, as noted by the author of epoll-shim, even if they were, the library state would also have to be passed somehow. This came up when debugging strange HW video decode failures in Firefox. A native implementation would avoid these problems and help with porting Linux software. Since we now already have an eventfd implementation in the kernel (for the Linuxulator), it's pretty easy to expose it natively, which is what this patch does. Submitted by: greg@unrelenting.technology Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26668
Diffstat (limited to 'sys/sys/specialfd.h')
-rw-r--r--sys/sys/specialfd.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/sys/specialfd.h b/sys/sys/specialfd.h
new file mode 100644
index 000000000000..c388bdcb7b6f
--- /dev/null
+++ b/sys/sys/specialfd.h
@@ -0,0 +1,42 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2020 Greg V
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_SPECIALFD_H_
+#define _SYS_SPECIALFD_H_
+
+enum specialfd_type {
+ SPECIALFD_EVENTFD = 1,
+};
+
+struct specialfd_eventfd {
+ unsigned int initval;
+ int flags;
+};
+
+#endif /* !_SYS_SPECIALFD_H_ */