am 7b0c23f1: Merge "Clean up <sched.h>."

* commit '7b0c23f1ac5df8654e0790b9eb3bbfcbf36c0e5f':
  Clean up <sched.h>.
This commit is contained in:
Elliott Hughes 2014-01-02 13:50:41 -08:00 committed by Android Git Automerger
commit 741d4023bb
16 changed files with 132 additions and 48 deletions

View File

@ -112,7 +112,6 @@ libc_common_src_files := \
bionic/recv.c \ bionic/recv.c \
bionic/sched_cpualloc.c \ bionic/sched_cpualloc.c \
bionic/sched_cpucount.c \ bionic/sched_cpucount.c \
bionic/sched_getcpu.c \
bionic/semaphore.c \ bionic/semaphore.c \
bionic/send.c \ bionic/send.c \
bionic/setpgrp.c \ bionic/setpgrp.c \
@ -261,6 +260,7 @@ libc_bionic_src_files := \
bionic/sbrk.cpp \ bionic/sbrk.cpp \
bionic/scandir.cpp \ bionic/scandir.cpp \
bionic/sched_getaffinity.cpp \ bionic/sched_getaffinity.cpp \
bionic/sched_getcpu.cpp \
bionic/setegid.cpp \ bionic/setegid.cpp \
bionic/__set_errno.cpp \ bionic/__set_errno.cpp \
bionic/seteuid.cpp \ bionic/seteuid.cpp \

View File

@ -179,7 +179,6 @@ int removexattr(const char*, const char*) all
int lremovexattr(const char*, const char*) all int lremovexattr(const char*, const char*) all
int __statfs64:statfs64(const char*, size_t, struct statfs*) arm,mips,x86 int __statfs64:statfs64(const char*, size_t, struct statfs*) arm,mips,x86
int statfs(const char*, struct statfs*) aarch64,x86_64 int statfs(const char*, struct statfs*) aarch64,x86_64
long unshare(unsigned long) all
int swapon(const char*, int) all int swapon(const char*, int) all
int swapoff(const char*) all int swapoff(const char*) all
@ -256,8 +255,10 @@ int sched_get_priority_max(int policy) all
int sched_get_priority_min(int policy) all int sched_get_priority_min(int policy) all
int sched_rr_get_interval(pid_t pid, struct timespec* interval) all int sched_rr_get_interval(pid_t pid, struct timespec* interval) all
int sched_setaffinity(pid_t pid, size_t setsize, const cpu_set_t* set) all int sched_setaffinity(pid_t pid, size_t setsize, const cpu_set_t* set) all
int setns(int, int) all
int unshare(int) all
int __sched_getaffinity:sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set) all int __sched_getaffinity:sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set) all
int __getcpu:getcpu(unsigned* cpu, unsigned* node, void* unused) all int __getcpu:getcpu(unsigned*, unsigned*, void*) all
# io priorities # io priorities
int ioprio_set(int which, int who, int ioprio) all int ioprio_set(int which, int who, int ioprio) all

View File

@ -147,6 +147,7 @@ syscall_src += arch-aarch64/syscalls/sendto.S
syscall_src += arch-aarch64/syscalls/setgid.S syscall_src += arch-aarch64/syscalls/setgid.S
syscall_src += arch-aarch64/syscalls/setgroups.S syscall_src += arch-aarch64/syscalls/setgroups.S
syscall_src += arch-aarch64/syscalls/setitimer.S syscall_src += arch-aarch64/syscalls/setitimer.S
syscall_src += arch-aarch64/syscalls/setns.S
syscall_src += arch-aarch64/syscalls/setpgid.S syscall_src += arch-aarch64/syscalls/setpgid.S
syscall_src += arch-aarch64/syscalls/setpriority.S syscall_src += arch-aarch64/syscalls/setpriority.S
syscall_src += arch-aarch64/syscalls/setregid.S syscall_src += arch-aarch64/syscalls/setregid.S

View File

@ -0,0 +1,21 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(setns)
stp x29, x30, [sp, #-16]!
mov x29, sp
str x8, [sp, #-16]!
mov x8, __NR_setns
svc #0
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(setns)

View File

@ -154,6 +154,7 @@ syscall_src += arch-arm/syscalls/sendto.S
syscall_src += arch-arm/syscalls/setgid.S syscall_src += arch-arm/syscalls/setgid.S
syscall_src += arch-arm/syscalls/setgroups.S syscall_src += arch-arm/syscalls/setgroups.S
syscall_src += arch-arm/syscalls/setitimer.S syscall_src += arch-arm/syscalls/setitimer.S
syscall_src += arch-arm/syscalls/setns.S
syscall_src += arch-arm/syscalls/setpgid.S syscall_src += arch-arm/syscalls/setpgid.S
syscall_src += arch-arm/syscalls/setpriority.S syscall_src += arch-arm/syscalls/setpriority.S
syscall_src += arch-arm/syscalls/setregid.S syscall_src += arch-arm/syscalls/setregid.S

View File

@ -0,0 +1,14 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(setns)
mov ip, r7
ldr r7, =__NR_setns
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(setns)

View File

@ -154,6 +154,7 @@ syscall_src += arch-mips/syscalls/sendto.S
syscall_src += arch-mips/syscalls/setgid.S syscall_src += arch-mips/syscalls/setgid.S
syscall_src += arch-mips/syscalls/setgroups.S syscall_src += arch-mips/syscalls/setgroups.S
syscall_src += arch-mips/syscalls/setitimer.S syscall_src += arch-mips/syscalls/setitimer.S
syscall_src += arch-mips/syscalls/setns.S
syscall_src += arch-mips/syscalls/setpgid.S syscall_src += arch-mips/syscalls/setpgid.S
syscall_src += arch-mips/syscalls/setpriority.S syscall_src += arch-mips/syscalls/setpriority.S
syscall_src += arch-mips/syscalls/setregid.S syscall_src += arch-mips/syscalls/setregid.S

View File

@ -0,0 +1,23 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <asm/unistd.h>
.text
.globl setns
.align 4
.ent setns
setns:
.set noreorder
.cpload $t9
li $v0, __NR_setns
syscall
bnez $a3, 1f
move $a0, $v0
j $ra
nop
1:
la $t9,__set_errno
j $t9
nop
.set reorder
.end setns

View File

@ -153,6 +153,7 @@ syscall_src += arch-x86/syscalls/sendto.S
syscall_src += arch-x86/syscalls/setgid.S syscall_src += arch-x86/syscalls/setgid.S
syscall_src += arch-x86/syscalls/setgroups.S syscall_src += arch-x86/syscalls/setgroups.S
syscall_src += arch-x86/syscalls/setitimer.S syscall_src += arch-x86/syscalls/setitimer.S
syscall_src += arch-x86/syscalls/setns.S
syscall_src += arch-x86/syscalls/setpgid.S syscall_src += arch-x86/syscalls/setpgid.S
syscall_src += arch-x86/syscalls/setpriority.S syscall_src += arch-x86/syscalls/setpriority.S
syscall_src += arch-x86/syscalls/setregid.S syscall_src += arch-x86/syscalls/setregid.S

View File

@ -0,0 +1,23 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(setns)
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
mov 16(%esp), %ecx
movl $__NR_setns, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ecx
popl %ebx
ret
END(setns)

View File

@ -148,6 +148,7 @@ syscall_src += arch-x86_64/syscalls/sendto.S
syscall_src += arch-x86_64/syscalls/setgid.S syscall_src += arch-x86_64/syscalls/setgid.S
syscall_src += arch-x86_64/syscalls/setgroups.S syscall_src += arch-x86_64/syscalls/setgroups.S
syscall_src += arch-x86_64/syscalls/setitimer.S syscall_src += arch-x86_64/syscalls/setitimer.S
syscall_src += arch-x86_64/syscalls/setns.S
syscall_src += arch-x86_64/syscalls/setpgid.S syscall_src += arch-x86_64/syscalls/setpgid.S
syscall_src += arch-x86_64/syscalls/setpriority.S syscall_src += arch-x86_64/syscalls/setpriority.S
syscall_src += arch-x86_64/syscalls/setregid.S syscall_src += arch-x86_64/syscalls/setregid.S

View File

@ -0,0 +1,16 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(setns)
movl $__NR_setns, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
negl %eax
movl %eax, %edi
call __set_errno
orq $-1, %rax
1:
ret
END(setns)

View File

@ -25,16 +25,17 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#include <sched.h> #include <sched.h>
extern int __getcpu(unsigned *cpu, unsigned *node, void* unused); extern "C" int __getcpu(unsigned*, unsigned*, void*);
int sched_getcpu(void) int sched_getcpu() {
{ unsigned cpu;
unsigned cpu; int rc = __getcpu(&cpu, NULL, NULL);
if (__getcpu(&cpu, NULL, NULL) < 0) if (rc == -1) {
return 0; return -1; // errno is already set.
}
return (int)cpu; return cpu;
} }

View File

@ -31,54 +31,32 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <sys/time.h> #include <sys/time.h>
#include <linux/sched.h>
__BEGIN_DECLS __BEGIN_DECLS
#define SCHED_NORMAL 0 /* This name is used by glibc, but not by the kernel. */
#define SCHED_OTHER 0 #define SCHED_OTHER SCHED_NORMAL
#define SCHED_FIFO 1
#define SCHED_RR 2
struct sched_param { struct sched_param {
int sched_priority; int sched_priority;
}; };
extern int sched_setscheduler(pid_t, int, const struct sched_param *); extern int sched_setscheduler(pid_t, int, const struct sched_param*);
extern int sched_getscheduler(pid_t); extern int sched_getscheduler(pid_t);
extern int sched_yield(void); extern int sched_yield(void);
extern int sched_get_priority_max(int policy); extern int sched_get_priority_max(int);
extern int sched_get_priority_min(int policy); extern int sched_get_priority_min(int);
extern int sched_setparam(pid_t, const struct sched_param *); extern int sched_setparam(pid_t, const struct sched_param*);
extern int sched_getparam(pid_t, struct sched_param *); extern int sched_getparam(pid_t, struct sched_param*);
extern int sched_rr_get_interval(pid_t pid, struct timespec *tp); extern int sched_rr_get_interval(pid_t, struct timespec*);
#define CLONE_VM 0x00000100
#define CLONE_FS 0x00000200
#define CLONE_FILES 0x00000400
#define CLONE_SIGHAND 0x00000800
#define CLONE_PTRACE 0x00002000
#define CLONE_VFORK 0x00004000
#define CLONE_PARENT 0x00008000
#define CLONE_THREAD 0x00010000
#define CLONE_NEWNS 0x00020000
#define CLONE_SYSVSEM 0x00040000
#define CLONE_SETTLS 0x00080000
#define CLONE_PARENT_SETTID 0x00100000
#define CLONE_CHILD_CLEARTID 0x00200000
#define CLONE_DETACHED 0x00400000
#define CLONE_UNTRACED 0x00800000
#define CLONE_CHILD_SETTID 0x01000000
#define CLONE_STOPPED 0x02000000
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
extern int clone(int (*fn)(void *), void *child_stack, int flags, void* arg, ...);
extern int clone(int (*)(void*), void*, int, void*, ...);
extern int unshare(int); extern int unshare(int);
#endif
/* Support for cpu thread affinity */
#ifdef _GNU_SOURCE
extern int sched_getcpu(void); extern int sched_getcpu(void);
extern int setns(int, int);
/* Our implementation supports up to 32 independent CPUs, which is also /* Our implementation supports up to 32 independent CPUs, which is also
* the maximum supported by the kernel at the moment. GLibc uses 1024 by * the maximum supported by the kernel at the moment. GLibc uses 1024 by

View File

@ -375,6 +375,7 @@
#define SYS_fcntl64 __NR_fcntl64 #define SYS_fcntl64 __NR_fcntl64
#define SYS_fdatasync __NR_fdatasync #define SYS_fdatasync __NR_fdatasync
#define SYS_fgetxattr __NR_fgetxattr #define SYS_fgetxattr __NR_fgetxattr
#define SYS_finit_module __NR_finit_module
#define SYS_flistxattr __NR_flistxattr #define SYS_flistxattr __NR_flistxattr
#define SYS_flock __NR_flock #define SYS_flock __NR_flock
#define SYS_fork __NR_fork #define SYS_fork __NR_fork
@ -439,6 +440,7 @@
#define SYS_ioprio_get __NR_ioprio_get #define SYS_ioprio_get __NR_ioprio_get
#define SYS_ioprio_set __NR_ioprio_set #define SYS_ioprio_set __NR_ioprio_set
#define SYS_ipc __NR_ipc #define SYS_ipc __NR_ipc
#define SYS_kcmp __NR_kcmp
#define SYS_kexec_load __NR_kexec_load #define SYS_kexec_load __NR_kexec_load
#define SYS_keyctl __NR_keyctl #define SYS_keyctl __NR_keyctl
#define SYS_kill __NR_kill #define SYS_kill __NR_kill

View File

@ -416,7 +416,7 @@ class State:
glibc_fp.write("#if defined(__aarch64__)\n") glibc_fp.write("#if defined(__aarch64__)\n")
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/uapi/asm-generic/unistd.h") self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/uapi/asm-generic/unistd.h")
glibc_fp.write("#elif defined(__arm__)\n") glibc_fp.write("#elif defined(__arm__)\n")
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-arm/asm/unistd.h") self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/uapi/asm-arm/asm/unistd.h")
glibc_fp.write("#elif defined(__mips__)\n") glibc_fp.write("#elif defined(__mips__)\n")
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/uapi/asm-mips/asm/unistd.h") self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/uapi/asm-mips/asm/unistd.h")
glibc_fp.write("#elif defined(__i386__)\n") glibc_fp.write("#elif defined(__i386__)\n")