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
This commit is contained in:
Konstantin Belousov 2021-11-11 10:01:54 +02:00
parent ef396441ce
commit 90fa9705d5
5 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
#define _WITH_CPU_SET_T
#include <sched.h>
int

View File

@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
#define _WITH_CPU_SET_T
#include <sched.h>
#include "libc_private.h"

View File

@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
#define _WITH_CPU_SET_T
#include <sched.h>
int

View File

@ -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"