Clean up <sched.h>.
This patch switches to using the uapi constants. It also adds the missing
setns system call, fixes sched_getcpu's error behavior, and fixes the
gensyscalls script now ARM is uapi-only too.
Change-Id: I8e16b1693d6d32cd9b8499e46b5d8b0a50bc4f1d
diff --git a/libc/bionic/sched_getcpu.c b/libc/bionic/sched_getcpu.cpp
similarity index 87%
rename from libc/bionic/sched_getcpu.c
rename to libc/bionic/sched_getcpu.cpp
index 954df37..1f92e54 100644
--- a/libc/bionic/sched_getcpu.c
+++ b/libc/bionic/sched_getcpu.cpp
@@ -25,16 +25,17 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#define _GNU_SOURCE 1
#include <sched.h>
-extern int __getcpu(unsigned *cpu, unsigned *node, void* unused);
+extern "C" int __getcpu(unsigned*, unsigned*, void*);
-int sched_getcpu(void)
-{
- unsigned cpu;
- if (__getcpu(&cpu, NULL, NULL) < 0)
- return 0;
-
- return (int)cpu;
+int sched_getcpu() {
+ unsigned cpu;
+ int rc = __getcpu(&cpu, NULL, NULL);
+ if (rc == -1) {
+ return -1; // errno is already set.
+ }
+ return cpu;
}