From 275cd48511daabe4591caa49c3ad0df34a6889ff Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 27 Sep 2010 17:33:08 +0200 Subject: libc: Add missing pipe2() declaration and implementation. Change-Id: Iacb914bd6ac5adc60c5671e6fef680ede21f9b0c --- libc/SYSCALLS.TXT | 5 +++-- libc/arch-arm/syscalls.mk | 1 + libc/arch-arm/syscalls/pipe2.S | 19 +++++++++++++++++++ libc/arch-sh/syscalls.mk | 1 + libc/arch-sh/syscalls/pipe2.S | 32 ++++++++++++++++++++++++++++++++ libc/arch-x86/syscalls.mk | 1 + libc/arch-x86/syscalls/pipe2.S | 26 ++++++++++++++++++++++++++ libc/include/sys/linux-syscalls.h | 7 +++++-- libc/include/sys/linux-unistd.h | 1 + libc/include/unistd.h | 3 +++ 10 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 libc/arch-arm/syscalls/pipe2.S create mode 100644 libc/arch-sh/syscalls/pipe2.S create mode 100644 libc/arch-x86/syscalls/pipe2.S diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index f66ff4067..4bcccb5b1 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -112,6 +112,7 @@ int flock(int, int) 143 int fchmod(int, mode_t) 94 int dup(int) 41 int pipe(int *) 42,42,-1 +int pipe2(int *, int) 359,331 int dup2(int, int) 63 int select:_newselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *) 142 int ftruncate(int, off_t) 93 @@ -229,8 +230,8 @@ int sched_get_priority_min(int policy) 160 int sched_rr_get_interval(pid_t pid, struct timespec *interval) 161 # io priorities -int ioprio_set(int which, int who, int ioprio) 314,289 -int ioprio_get(int which, int who) 315,290 +int ioprio_set(int which, int who, int ioprio) 314,289,288 +int ioprio_get(int which, int who) 315,290,289 # other int uname(struct utsname *) 122 diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index c46616666..2d944cabd 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -66,6 +66,7 @@ syscall_src += arch-arm/syscalls/flock.S syscall_src += arch-arm/syscalls/fchmod.S syscall_src += arch-arm/syscalls/dup.S syscall_src += arch-arm/syscalls/pipe.S +syscall_src += arch-arm/syscalls/pipe2.S syscall_src += arch-arm/syscalls/dup2.S syscall_src += arch-arm/syscalls/select.S syscall_src += arch-arm/syscalls/ftruncate.S diff --git a/libc/arch-arm/syscalls/pipe2.S b/libc/arch-arm/syscalls/pipe2.S new file mode 100644 index 000000000..df7709405 --- /dev/null +++ b/libc/arch-arm/syscalls/pipe2.S @@ -0,0 +1,19 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type pipe2, #function + .globl pipe2 + .align 4 + .fnstart + +pipe2: + .save {r4, r7} + stmfd sp!, {r4, r7} + ldr r7, =__NR_pipe2 + swi #0 + ldmfd sp!, {r4, r7} + movs r0, r0 + bxpl lr + b __set_syscall_errno + .fnend diff --git a/libc/arch-sh/syscalls.mk b/libc/arch-sh/syscalls.mk index ddae8d395..b690bbfc6 100644 --- a/libc/arch-sh/syscalls.mk +++ b/libc/arch-sh/syscalls.mk @@ -69,6 +69,7 @@ syscall_src += arch-sh/syscalls/__fcntl.S syscall_src += arch-sh/syscalls/flock.S syscall_src += arch-sh/syscalls/fchmod.S syscall_src += arch-sh/syscalls/dup.S +syscall_src += arch-sh/syscalls/pipe2.S syscall_src += arch-sh/syscalls/dup2.S syscall_src += arch-sh/syscalls/select.S syscall_src += arch-sh/syscalls/ftruncate.S diff --git a/libc/arch-sh/syscalls/pipe2.S b/libc/arch-sh/syscalls/pipe2.S new file mode 100644 index 000000000..f6d9964ec --- /dev/null +++ b/libc/arch-sh/syscalls/pipe2.S @@ -0,0 +1,32 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type pipe2, @function + .globl pipe2 + .align 4 + +pipe2: + + /* invoke trap */ + mov.l 0f, r3 /* trap num */ + trapa #(2 + 0x10) + + /* check return value */ + cmp/pz r0 + bt __NR_pipe2_end + + /* keep error number */ + sts.l pr, @-r15 + mov.l 1f, r1 + jsr @r1 + mov r0, r4 + lds.l @r15+, pr + +__NR_pipe2_end: + rts + nop + + .align 2 +0: .long __NR_pipe2 +1: .long __set_syscall_errno diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index 6ac371646..27153f908 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -69,6 +69,7 @@ syscall_src += arch-x86/syscalls/flock.S syscall_src += arch-x86/syscalls/fchmod.S syscall_src += arch-x86/syscalls/dup.S syscall_src += arch-x86/syscalls/pipe.S +syscall_src += arch-x86/syscalls/pipe2.S syscall_src += arch-x86/syscalls/dup2.S syscall_src += arch-x86/syscalls/select.S syscall_src += arch-x86/syscalls/ftruncate.S diff --git a/libc/arch-x86/syscalls/pipe2.S b/libc/arch-x86/syscalls/pipe2.S new file mode 100644 index 000000000..c3354a77f --- /dev/null +++ b/libc/arch-x86/syscalls/pipe2.S @@ -0,0 +1,26 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type pipe2, @function + .globl pipe2 + .align 4 + +pipe2: + pushl %ebx + pushl %ecx + mov 12(%esp), %ebx + mov 16(%esp), %ecx + movl $__NR_pipe2, %eax + int $0x80 + cmpl $-129, %eax + jb 1f + negl %eax + pushl %eax + call __set_errno + addl $4, %esp + orl $-1, %eax +1: + popl %ecx + popl %ebx + ret diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h index 9e2aa2f37..6a7fc401e 100644 --- a/libc/include/sys/linux-syscalls.h +++ b/libc/include/sys/linux-syscalls.h @@ -138,6 +138,7 @@ #define __NR_openat (__NR_SYSCALL_BASE + 322) #define __NR_madvise (__NR_SYSCALL_BASE + 220) #define __NR_mincore (__NR_SYSCALL_BASE + 219) +#define __NR_pipe2 (__NR_SYSCALL_BASE + 359) #define __NR_getdents64 (__NR_SYSCALL_BASE + 217) #define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267) #define __NR_fstatat64 (__NR_SYSCALL_BASE + 327) @@ -194,6 +195,7 @@ #define __NR_openat (__NR_SYSCALL_BASE + 295) #define __NR_madvise (__NR_SYSCALL_BASE + 219) #define __NR_mincore (__NR_SYSCALL_BASE + 218) +#define __NR_pipe2 (__NR_SYSCALL_BASE + 331) #define __NR_getdents64 (__NR_SYSCALL_BASE + 220) #define __NR_fstatfs64 (__NR_SYSCALL_BASE + 269) #define __NR_fstatat64 (__NR_SYSCALL_BASE + 300) @@ -235,6 +237,7 @@ #define __NR_openat (__NR_SYSCALL_BASE + 295) #define __NR_madvise (__NR_SYSCALL_BASE + 219) #define __NR_mincore (__NR_SYSCALL_BASE + 218) +#define __NR_pipe2 (__NR_SYSCALL_BASE + 331) #define __NR_getdents64 (__NR_SYSCALL_BASE + 220) #define __NR_fstatfs64 (__NR_SYSCALL_BASE + 269) #define __NR_fstatat64 (__NR_SYSCALL_BASE + 300) @@ -270,8 +273,8 @@ #define __NR_socketcall (__NR_SYSCALL_BASE + 102) #define __NR_socketcall (__NR_SYSCALL_BASE + 102) #define __NR___socketcall (__NR_SYSCALL_BASE + 102) -#define __NR_ioprio_set (__NR_SYSCALL_BASE + 289) -#define __NR_ioprio_get (__NR_SYSCALL_BASE + 290) +#define __NR_ioprio_set (__NR_SYSCALL_BASE + 288) +#define __NR_ioprio_get (__NR_SYSCALL_BASE + 289) #define __NR_epoll_create (__NR_SYSCALL_BASE + 254) #define __NR_epoll_ctl (__NR_SYSCALL_BASE + 255) #define __NR_epoll_wait (__NR_SYSCALL_BASE + 256) diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h index 6bd9ac7e9..7494efefb 100644 --- a/libc/include/sys/linux-unistd.h +++ b/libc/include/sys/linux-unistd.h @@ -79,6 +79,7 @@ int flock (int, int); int fchmod (int, mode_t); int dup (int); int pipe (int *); +int pipe2 (int *, int); int dup2 (int, int); int select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *); int ftruncate (int, off_t); diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 75541980d..cd09e3d24 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -118,6 +118,9 @@ extern int chdir(const char *); extern int fchdir(int); extern int rmdir(const char *); extern int pipe(int *); +#ifdef _GNU_SOURCE /* GLibc compatibility */ +extern int pipe2(int *, int); +#endif extern int chroot(const char *); extern int symlink(const char *, const char *); extern int readlink(const char *, char *, size_t); -- cgit v1.2.3