From nobody Sun Apr 16 11:10:31 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PznXm20NXz458NQ; Sun, 16 Apr 2023 11:10:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PznXm14Tkz422p; Sun, 16 Apr 2023 11:10:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681643432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zpES5DwGzSIxKzexRkDd/CgjisXLBjJhfDzxYOdPExg=; b=hkePprhbPk1n0JTe+i/3LyzxdemyjtQpwVwcG4Ap9yXKpw41kl9xcfoTcacl273JIANb3d GGumvP4EM0Rarc0k15k+OR2VyGQt1ewFYC7KI14nJkeUOqISvHyr6XlP0fg2gj97CqGU0V jqTqryG5XBXaTXzRgCRLbmRyElUcp2uIgGsZG/CwyEdrzb8wyOsRCQn9eFlUAjwbad/f1z G+FiG0clJRHSvPeZtgBxEHEnma9MfRtOcEKe2RkdIfu8z3adTtan3bLf6ivzSoQq3B1rEy c8xmPaTPtAlZHZLF+HOEGmk4qSwiHckSe9KQxHdeWftIQtS5Fodg+ATux6Opyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681643432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zpES5DwGzSIxKzexRkDd/CgjisXLBjJhfDzxYOdPExg=; b=clTkK3S9+1BZw4ThUvWdmqfYydGofGJscsb8WuQF4xeVhhSA1Q0yj+yUc2UeJaKuLeQIKm tZmK9BxDU/rtNRxFafNROM2MdCXMkmTQTn2nEbNAKSRVFmGqJRuyieamseIs5N1my9rUvc 7ZLCsMSOOf+2UJE94Qrg3jBpQOTtpQ2b48CbZIQMdC+HJ2K4NEkFDfmZxwBe0szbpt+w/4 QndOVH1gouFPYzqS/DXbphk0XJ59AEnAvIR6h1RoF91Ium4cP87VmPHIIqxc5Up+FCdnSX YYiDBJRDgN0+o3AOkSGhmCU7NMNHlLqXTAfhC3M+6o5NrgtJj3173qqUcpN8bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681643432; a=rsa-sha256; cv=none; b=KKqwInSd5G6k2WtsNXTMjCQx9ytQO85OBONtuOrm6AshUwUmX3kVaDEy98ylUYXqlz54Wf wRL/ZHevg7sfuTm1Qa21ES03hkg6kaxrCf50/9URhZ5zy6R2KZmoaN/gnSBP/IGI1BrTS4 vbnZTjDADC9stBiSZ/M/hSNNM0WcT5ZObFKc1d4lj5g/TASclux5BQODIg5pZauMMpcXzG N5+n4zvMQmDLJ/5PBS66w1r+5rIkQeBwR7YOFZmJPIQL0hhroBlrCrG8Wf5dUlrVYR8wGR zR86Ql80NQGhs2my+vmnLFK3Isy3Yt0zNBH52HEsXMABBEFFFKVyEKHkRx8HAA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PznXm070LzlYZ; Sun, 16 Apr 2023 11:10:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33GBAVRu048055; Sun, 16 Apr 2023 11:10:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33GBAVAr048054; Sun, 16 Apr 2023 11:10:31 GMT (envelope-from git) Date: Sun, 16 Apr 2023 11:10:31 GMT Message-Id: <202304161110.33GBAVAr048054@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b50b224df47f - stable/13 - Change kqueue1() to be compatible with NetBSD List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b50b224df47f9bf5a9b194e95908d5aa760ae791 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b50b224df47f9bf5a9b194e95908d5aa760ae791 commit b50b224df47f9bf5a9b194e95908d5aa760ae791 Author: Konstantin Belousov AuthorDate: 2023-03-31 22:31:41 +0000 Commit: Konstantin Belousov CommitDate: 2023-04-16 10:59:44 +0000 Change kqueue1() to be compatible with NetBSD (cherry picked from commit 54579376c05e7a039cde5f424c641fa29348835f) --- lib/libc/gen/Makefile.inc | 1 + lib/libc/gen/Symbol.map | 1 + lib/libc/gen/kqueue1.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ lib/libc/sys/kqueue.2 | 8 ++++++++ sys/sys/event.h | 1 + 5 files changed, 63 insertions(+) diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 22573d8ec36c..ae8a6bec08de 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -97,6 +97,7 @@ SRCS+= __getosreldate.c \ 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 index 0a20a41d0e20..84432432f4e6 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -436,6 +436,7 @@ FBSD_1.6 { }; 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 index 000000000000..b27a8f63019e --- /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 + * 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 +#include +#include +#include + +/* + * 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/kqueue.2 b/lib/libc/sys/kqueue.2 index 2996b0f02109..2d2b990102c2 100644 --- a/lib/libc/sys/kqueue.2 +++ b/lib/libc/sys/kqueue.2 @@ -107,6 +107,14 @@ The call is equivalent to .Ql fd = kqueuex(0) . .Pp +For compatibility with +.Nx , +the +.Fn kqueue1 +function is provided, which accepts the +.Dv O_CLOEXEC +flag with the expected semantic. +.Pp The .Fn kevent system call diff --git a/sys/sys/event.h b/sys/sys/event.h index f204ab8fe0b5..1141a22b8109 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -361,6 +361,7 @@ struct timespec; __BEGIN_DECLS int kqueue(void); 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);