git: 90fa9705d5cd - main - sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 13 Nov 2021 17:29:10 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=90fa9705d5cd29cf11c5dc7319299788dec2546a
commit 90fa9705d5cd29cf11c5dc7319299788dec2546a
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-11-11 08:01:54 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
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 <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sched.h>
-#if __BSD_VISIBLE
-#include <sys/cpuset.h>
-#endif /* __BSD_VISIBLE */
-
#if __BSD_VISIBLE
#ifdef _WITH_CPU_SET_T
+#include <sys/cpuset.h>
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 <sched.h>
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 <sched.h>
#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 <sched.h>
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 <machine/sysarch.h>
#include <x86/ifunc.h>
#include <errno.h>
+#define _WITH_CPU_SET_T
#include <sched.h>
#include "libc_private.h"