File libcpuset-fix-missing-syscall.diff of Package libcpuset
From: Bernhard Walle <bwalle@suse.de>
Subject: [PATCH] Fix build when system calls are missing
This patch fixes the build on systems like s390 that have no __NR_get_mempolicy
or __NR_set_mempolicy system call. It also fixes the build if
__NR_sched_setaffinity is not available, although I don't know such a platform.
It catches the error at runtime by returning -1 and setting errno to
ENOSYS ("Function not implemented").
Signed-off-by: Bernhard Walle <bwalle@suse.de>
---
libcpuset.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
--- a/libcpuset.c
+++ b/libcpuset.c
@@ -2892,18 +2892,33 @@ done:
static int sched_setaffinity(pid_t pid, unsigned len, unsigned long *mask)
{
+#ifdef __NR_sched_setaffinity
return syscall(__NR_sched_setaffinity, pid, len, mask);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif /* __NR_sched_setaffinity */
}
static int get_mempolicy(int *policy, unsigned long *nmask,
unsigned long maxnode, void *addr, int flags)
{
+#ifdef __NR_get_mempolicy
return syscall(__NR_get_mempolicy, policy, nmask, maxnode, addr, flags);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif /* __NR_get_mempolicy */
}
static int set_mempolicy(int mode, unsigned long *nmask, unsigned long maxnode)
{
+#ifdef __NR_set_mempolicy
return syscall(__NR_set_mempolicy, mode, nmask, maxnode);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif /* __NR_set_mempolicy */
}
struct cpuset_placement {