Explorar el Código

- only compile them if the respective syscalls are available

Bernhard Reutner-Fischer hace 16 años
padre
commit
9f2b28a508

+ 8 - 3
libc/sysdeps/linux/common/sched_getaffinity.c

@@ -26,8 +26,7 @@
 #include <string.h>
 #include <sys/param.h>
 
-/* Experimentally off - libc_hidden_proto(memset) */
-
+#if defined __NR_sched_getaffinity
 #define __NR___syscall_sched_getaffinity __NR_sched_getaffinity
 static __inline__ _syscall3(int, __syscall_sched_getaffinity, __kernel_pid_t, pid,
 			size_t, cpusetsize, cpu_set_t *, cpuset);
@@ -45,5 +44,11 @@ int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
 	}
 	return res;
 }
-
+#elif defined __UCLIBC_HAS_STUBS__
+int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
+{
+    __set_errno(ENOSYS);
+    return -1;
+}
+#endif
 #endif

+ 15 - 0
libc/sysdeps/linux/common/sched_setaffinity.c

@@ -30,6 +30,7 @@
 #include <sys/param.h>
 #include <alloca.h>
 
+#if defined __NR_sched_setaffinity
 libc_hidden_proto(getpid)
 
 #define __NR___syscall_sched_setaffinity __NR_sched_setaffinity
@@ -73,5 +74,19 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
 
 	return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset);
 }
+#else
+#define ___HAVE_NO_sched_setaffinity
 #endif
+#else
+#define ___HAVE_NO_sched_setaffinity
 #endif
+
+#if defined ___HAVE_NO_sched_setaffinity && defined __UCLIBC_HAS_STUBS__
+int sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
+{
+    __set_errno(ENOSYS);
+    return -1;
+}
+#endif
+
+#endif /* __USE_GNU */