From nobody Sat Nov 13 17:29:10 2021 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 4E531185E036; Sat, 13 Nov 2021 17:29:11 +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 4Hs2WC1klxz3PF4; Sat, 13 Nov 2021 17:29:11 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 177981753B; Sat, 13 Nov 2021 17:29:11 +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 1ADHTAnn036391; Sat, 13 Nov 2021 17:29:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ADHTAa2036390; Sat, 13 Nov 2021 17:29:10 GMT (envelope-from git) Date: Sat, 13 Nov 2021 17:29:10 GMT Message-Id: <202111131729.1ADHTAa2036390@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 90fa9705d5cd - main - sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T 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/main X-Git-Reftype: branch X-Git-Commit: 90fa9705d5cd29cf11c5dc7319299788dec2546a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=90fa9705d5cd29cf11c5dc7319299788dec2546a commit 90fa9705d5cd29cf11c5dc7319299788dec2546a Author: Konstantin Belousov AuthorDate: 2021-11-11 08:01:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-13 17:27:54 +0000 sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T Instead of only hiding cpu_set_t compat typedef itself. Too many software packages assume that sched_getaffinity() presence implies full source compatibility with glibc. We can (and should) handle missing CPU_* macros, but then there are incompatible BIT_* uses which cannot be fixed in src/. So hide everything under _WITH_CPU_SET_T, in particular, do not expose sched_getcpu(), sched_get/setaffinity(), as well as CPU_* and BIT_* macros. Consumers that want sched* functions must opt-in. Reported by: portmgr (antoine) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- include/sched.h | 7 +++---- lib/libc/gen/sched_getaffinity.c | 1 + lib/libc/gen/sched_getcpu_gen.c | 1 + lib/libc/gen/sched_setaffinity.c | 1 + lib/libc/x86/sys/sched_getcpu_x86.c | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/sched.h b/include/sched.h index 1c41cda79046..460d3bfed154 100644 --- a/include/sched.h +++ b/include/sched.h @@ -32,12 +32,9 @@ #include #include #include -#if __BSD_VISIBLE -#include -#endif /* __BSD_VISIBLE */ - #if __BSD_VISIBLE #ifdef _WITH_CPU_SET_T +#include struct _cpuset; typedef struct _cpuset cpu_set_t; #endif /* _WITH_CPU_SET_T */ @@ -45,9 +42,11 @@ typedef struct _cpuset cpu_set_t; __BEGIN_DECLS #if __BSD_VISIBLE +#ifdef _WITH_CPU_SET_T int sched_getaffinity(pid_t pid, size_t cpusetsz, cpuset_t *cpuset); int sched_setaffinity(int pid, size_t cpusetsz, const cpuset_t *cpuset); int sched_getcpu(void); +#endif /* _WITH_CPU_SET_T */ #endif /* __BSD_VISIBLE */ __END_DECLS diff --git a/lib/libc/gen/sched_getaffinity.c b/lib/libc/gen/sched_getaffinity.c index 191374a3c5e3..5557d3d93b47 100644 --- a/lib/libc/gen/sched_getaffinity.c +++ b/lib/libc/gen/sched_getaffinity.c @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#define _WITH_CPU_SET_T #include int diff --git a/lib/libc/gen/sched_getcpu_gen.c b/lib/libc/gen/sched_getcpu_gen.c index ef1bebc2915a..704075c0ae53 100644 --- a/lib/libc/gen/sched_getcpu_gen.c +++ b/lib/libc/gen/sched_getcpu_gen.c @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#define _WITH_CPU_SET_T #include #include "libc_private.h" diff --git a/lib/libc/gen/sched_setaffinity.c b/lib/libc/gen/sched_setaffinity.c index 9368b1752b74..ad775b5dbce5 100644 --- a/lib/libc/gen/sched_setaffinity.c +++ b/lib/libc/gen/sched_setaffinity.c @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#define _WITH_CPU_SET_T #include int diff --git a/lib/libc/x86/sys/sched_getcpu_x86.c b/lib/libc/x86/sys/sched_getcpu_x86.c index 13ba18ef5e36..5e3bd5311734 100644 --- a/lib/libc/x86/sys/sched_getcpu_x86.c +++ b/lib/libc/x86/sys/sched_getcpu_x86.c @@ -32,6 +32,7 @@ #include #include #include +#define _WITH_CPU_SET_T #include #include "libc_private.h"