Page MenuHomeFreeBSD

D39377.id119797.diff
No OneTemporary

D39377.id119797.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
@@ -97,6 +97,7 @@
isinf.c \
isnan.c \
jrand48.c \
+ kqueue1.c \
lcong48.c \
libc_dlopen.c \
lockf.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
@@ -436,6 +436,7 @@
};
FBSD_1.7 {
+ kqueue1;
posix_spawn_file_actions_addchdir_np;
posix_spawn_file_actions_addclosefrom_np;
posix_spawn_file_actions_addfchdir_np;
diff --git a/lib/libc/gen/kqueue1.c b/lib/libc/gen/kqueue1.c
new file mode 100644
--- /dev/null
+++ b/lib/libc/gen/kqueue1.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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/param.h>
+#include <sys/event.h>
+#include <errno.h>
+#include <fcntl.h>
+
+/*
+ * Provide some NetBSD compatibility. They support a set of O_*
+ * flags, we only carry O_CLOEXEC, and accept but ignore O_NONBLOCK.
+ */
+int
+kqueue1(int openflags)
+{
+ u_int flags;
+
+ if ((openflags & ~(O_CLOEXEC | O_NONBLOCK)) != 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ flags = 0;
+ if ((openflags & O_CLOEXEC) != 0)
+ flags |= KQUEUE_CLOEXEC;
+ return (kqueuex(flags));
+}
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -430,7 +430,7 @@
jail.2 jail_set.2
MLINKS+=kldunload.2 kldunloadf.2
MLINKS+=kqueue.2 kevent.2 \
- kqueue.2 kqueue1.2 \
+ kqueue.2 kqueuex.2 \
kqueue.2 EV_SET.3
MLINKS+=link.2 linkat.2
MLINKS+=madvise.2 posix_madvise.2
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -419,7 +419,7 @@
FBSD_1.7 {
_Fork;
fspacectl;
- kqueue1;
+ kqueuex;
swapoff;
};
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -38,7 +38,7 @@
.Ft int
.Fn kqueue "void"
.Ft int
-.Fn kqueue1 "u_int flags"
+.Fn kqueuex "u_int flags"
.Ft int
.Fo kevent
.Fa "int kq"
@@ -92,7 +92,7 @@
which will allow sharing of the kqueue between two processes.
.Pp
The
-.Fn kqueue1
+.Fn kqueuex
system call also creates a new kernel event queue, and additionally takes
the
.Fa flags
@@ -105,7 +105,7 @@
The
.Ql fd = kqueue()
call is equivalent to
-.Ql fd = kqueue1(0) .
+.Ql fd = kqueuex(0) .
.Pp
The
.Fn kevent
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1058,7 +1058,7 @@
}
int
-sys_kqueue1(struct thread *td, struct kqueue1_args *uap)
+sys_kqueuex(struct thread *td, struct kqueuex_args *uap)
{
int flags;
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -3307,7 +3307,7 @@
);
}
583 AUE_KQUEUE STD|CAPENABLED {
- int kqueue1(
+ int kqueuex(
u_int flags
);
}
diff --git a/sys/sys/event.h b/sys/sys/event.h
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -218,7 +218,7 @@
#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */
#define NOTE_ABSTIME 0x00000010 /* timeout is absolute */
-/* Flags for kqueue1(2) */
+/* Flags for kqueuex(2) */
#define KQUEUE_CLOEXEC 0x00000001 /* close on exec */
struct knote;
@@ -361,7 +361,8 @@
__BEGIN_DECLS
int kqueue(void);
-int kqueue1(unsigned flags);
+int kqueuex(unsigned flags);
+int kqueue1(int flags);
int kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout);

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 21, 7:25 PM (53 m, 58 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16760238
Default Alt Text
D39377.id119797.diff (4 KB)

Event Timeline