diff options
author | Yabin Cui <yabinc@google.com> | 2014-12-01 17:41:04 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2014-12-08 21:52:43 -0800 |
commit | 634816055f51c536d24dea30dfe930b7fe2fa603 (patch) | |
tree | 5d3739b116df16774776010538254c10007c0a76 /libc | |
parent | f64c43ba6c9244c50e904961dc432f04b1dfcfd9 (diff) | |
download | android_bionic-634816055f51c536d24dea30dfe930b7fe2fa603.tar.gz android_bionic-634816055f51c536d24dea30dfe930b7fe2fa603.tar.bz2 android_bionic-634816055f51c536d24dea30dfe930b7fe2fa603.zip |
support _POSIX_REALTIME_SIGNALS
Bug: 18489947
Change-Id: I2e834d68bc10ca5fc7ebde047b517a3074179475
Diffstat (limited to 'libc')
-rw-r--r-- | libc/Android.mk | 3 | ||||
-rw-r--r-- | libc/SYSCALLS.TXT | 1 | ||||
-rw-r--r-- | libc/arch-arm/syscalls/__rt_sigqueueinfo.S | 14 | ||||
-rw-r--r-- | libc/arch-arm64/syscalls/__rt_sigqueueinfo.S | 15 | ||||
-rw-r--r-- | libc/arch-mips/syscalls/__rt_sigqueueinfo.S | 19 | ||||
-rw-r--r-- | libc/arch-mips64/syscalls/__rt_sigqueueinfo.S | 26 | ||||
-rw-r--r-- | libc/arch-x86/syscalls/__rt_sigqueueinfo.S | 31 | ||||
-rw-r--r-- | libc/arch-x86_64/syscalls/__rt_sigqueueinfo.S | 16 | ||||
-rw-r--r-- | libc/bionic/sigqueue.cpp | 46 | ||||
-rw-r--r-- | libc/bionic/sigtimedwait.cpp | 38 | ||||
-rw-r--r-- | libc/bionic/sigwaitinfo.cpp | 33 | ||||
-rw-r--r-- | libc/include/machine/posix_limits.h | 2 | ||||
-rw-r--r-- | libc/include/signal.h | 5 |
13 files changed, 248 insertions, 1 deletions
diff --git a/libc/Android.mk b/libc/Android.mk index ef1fb9be6..90c2e9260 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -201,8 +201,11 @@ libc_bionic_src_files := \ bionic/signalfd.cpp \ bionic/sigpending.cpp \ bionic/sigprocmask.cpp \ + bionic/sigqueue.cpp \ bionic/sigsuspend.cpp \ + bionic/sigtimedwait.cpp \ bionic/sigwait.cpp \ + bionic/sigwaitinfo.cpp \ bionic/socket.cpp \ bionic/stat.cpp \ bionic/statvfs.cpp \ diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index 39ff37de0..35558c994 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -223,6 +223,7 @@ int __rt_sigpending:rt_sigpending(sigset_t*, size_t) all int __rt_sigprocmask:rt_sigprocmask(int, const sigset_t*, sigset_t*, size_t) all int __rt_sigsuspend:rt_sigsuspend(const sigset_t*, size_t) all int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t*, struct siginfo_t*, struct timespec_t*, size_t) all +int __rt_sigqueueinfo:rt_sigqueueinfo(pid_t, int, siginfo_t*) all int __signalfd4:signalfd4(int, const sigset_t*, size_t, int) all # sockets diff --git a/libc/arch-arm/syscalls/__rt_sigqueueinfo.S b/libc/arch-arm/syscalls/__rt_sigqueueinfo.S new file mode 100644 index 000000000..c823ceee1 --- /dev/null +++ b/libc/arch-arm/syscalls/__rt_sigqueueinfo.S @@ -0,0 +1,14 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(__rt_sigqueueinfo) + mov ip, r7 + ldr r7, =__NR_rt_sigqueueinfo + swi #0 + mov r7, ip + cmn r0, #(MAX_ERRNO + 1) + bxls lr + neg r0, r0 + b __set_errno_internal +END(__rt_sigqueueinfo) diff --git a/libc/arch-arm64/syscalls/__rt_sigqueueinfo.S b/libc/arch-arm64/syscalls/__rt_sigqueueinfo.S new file mode 100644 index 000000000..2b23e1822 --- /dev/null +++ b/libc/arch-arm64/syscalls/__rt_sigqueueinfo.S @@ -0,0 +1,15 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(__rt_sigqueueinfo) + mov x8, __NR_rt_sigqueueinfo + svc #0 + + cmn x0, #(MAX_ERRNO + 1) + cneg x0, x0, hi + b.hi __set_errno_internal + + ret +END(__rt_sigqueueinfo) +.hidden __rt_sigqueueinfo diff --git a/libc/arch-mips/syscalls/__rt_sigqueueinfo.S b/libc/arch-mips/syscalls/__rt_sigqueueinfo.S new file mode 100644 index 000000000..a978bc467 --- /dev/null +++ b/libc/arch-mips/syscalls/__rt_sigqueueinfo.S @@ -0,0 +1,19 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(__rt_sigqueueinfo) + .set noreorder + .cpload t9 + li v0, __NR_rt_sigqueueinfo + syscall + bnez a3, 1f + move a0, v0 + j ra + nop +1: + la t9,__set_errno_internal + j t9 + nop + .set reorder +END(__rt_sigqueueinfo) diff --git a/libc/arch-mips64/syscalls/__rt_sigqueueinfo.S b/libc/arch-mips64/syscalls/__rt_sigqueueinfo.S new file mode 100644 index 000000000..e97aebad3 --- /dev/null +++ b/libc/arch-mips64/syscalls/__rt_sigqueueinfo.S @@ -0,0 +1,26 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(__rt_sigqueueinfo) + .set push + .set noreorder + li v0, __NR_rt_sigqueueinfo + syscall + bnez a3, 1f + move a0, v0 + j ra + nop +1: + move t0, ra + bal 2f + nop +2: + .cpsetup ra, t1, 2b + LA t9,__set_errno_internal + .cpreturn + j t9 + move ra, t0 + .set pop +END(__rt_sigqueueinfo) +.hidden __rt_sigqueueinfo diff --git a/libc/arch-x86/syscalls/__rt_sigqueueinfo.S b/libc/arch-x86/syscalls/__rt_sigqueueinfo.S new file mode 100644 index 000000000..415210067 --- /dev/null +++ b/libc/arch-x86/syscalls/__rt_sigqueueinfo.S @@ -0,0 +1,31 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(__rt_sigqueueinfo) + pushl %ebx + .cfi_def_cfa_offset 8 + .cfi_rel_offset ebx, 0 + pushl %ecx + .cfi_adjust_cfa_offset 4 + .cfi_rel_offset ecx, 0 + pushl %edx + .cfi_adjust_cfa_offset 4 + .cfi_rel_offset edx, 0 + mov 16(%esp), %ebx + mov 20(%esp), %ecx + mov 24(%esp), %edx + movl $__NR_rt_sigqueueinfo, %eax + int $0x80 + cmpl $-MAX_ERRNO, %eax + jb 1f + negl %eax + pushl %eax + call __set_errno_internal + addl $4, %esp +1: + popl %edx + popl %ecx + popl %ebx + ret +END(__rt_sigqueueinfo) diff --git a/libc/arch-x86_64/syscalls/__rt_sigqueueinfo.S b/libc/arch-x86_64/syscalls/__rt_sigqueueinfo.S new file mode 100644 index 000000000..52b686346 --- /dev/null +++ b/libc/arch-x86_64/syscalls/__rt_sigqueueinfo.S @@ -0,0 +1,16 @@ +/* Generated by gensyscalls.py. Do not edit. */ + +#include <private/bionic_asm.h> + +ENTRY(__rt_sigqueueinfo) + movl $__NR_rt_sigqueueinfo, %eax + syscall + cmpq $-MAX_ERRNO, %rax + jb 1f + negl %eax + movl %eax, %edi + call __set_errno_internal +1: + ret +END(__rt_sigqueueinfo) +.hidden __rt_sigqueueinfo diff --git a/libc/bionic/sigqueue.cpp b/libc/bionic/sigqueue.cpp new file mode 100644 index 000000000..39c879873 --- /dev/null +++ b/libc/bionic/sigqueue.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <signal.h> +#include <string.h> +#include <sys/types.h> +#include <unistd.h> + +extern "C" int __rt_sigqueueinfo(pid_t, int, siginfo_t*); + +int sigqueue(pid_t pid, int signo, const sigval value) { + siginfo_t info; + memset(&info, 0, sizeof(siginfo_t)); + info.si_signo = signo; + info.si_code = SI_QUEUE; + info.si_pid = getpid(); + info.si_uid = getuid(); + info.si_value = value; + + return __rt_sigqueueinfo(pid, signo, &info); +} diff --git a/libc/bionic/sigtimedwait.cpp b/libc/bionic/sigtimedwait.cpp new file mode 100644 index 000000000..c29f806e9 --- /dev/null +++ b/libc/bionic/sigtimedwait.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <signal.h> + +#include "private/kernel_sigset_t.h" + +extern "C" int __rt_sigtimedwait(const sigset_t*, siginfo_t*, const timespec*, size_t); + +int sigtimedwait(const sigset_t* set, siginfo_t* info, const timespec* timeout) { + kernel_sigset_t sigset(set); + return __rt_sigtimedwait(sigset.get(), info, timeout, sizeof(sigset)); +} diff --git a/libc/bionic/sigwaitinfo.cpp b/libc/bionic/sigwaitinfo.cpp new file mode 100644 index 000000000..43e2395e6 --- /dev/null +++ b/libc/bionic/sigwaitinfo.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <signal.h> + +int sigwaitinfo(const sigset_t* set, siginfo_t* info) { + return sigtimedwait(set, info, NULL); +} diff --git a/libc/include/machine/posix_limits.h b/libc/include/machine/posix_limits.h index e5a299bc6..073d0df35 100644 --- a/libc/include/machine/posix_limits.h +++ b/libc/include/machine/posix_limits.h @@ -69,7 +69,7 @@ #define _POSIX_PRIORITIZED_IO -1 /* not implemented */ #define _POSIX_RAW_SOCKETS 200809L #define _POSIX_READER_WRITER_LOCKS 200809L -#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */ +#define _POSIX_REALTIME_SIGNALS 200809L #define _POSIX_REGEXP 1 #define _POSIX_RE_DUP_MAX 255 #define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */ diff --git a/libc/include/signal.h b/libc/include/signal.h index 6d89ef7d0..867f49748 100644 --- a/libc/include/signal.h +++ b/libc/include/signal.h @@ -32,6 +32,7 @@ #include <asm/sigcontext.h> #include <errno.h> #include <limits.h> +#include <linux/time.h> #include <machine/pthread_types.h> #include <string.h> #include <sys/cdefs.h> @@ -133,6 +134,10 @@ extern void psignal(int, const char*); extern int pthread_kill(pthread_t, int); extern int pthread_sigmask(int, const sigset_t*, sigset_t*); +extern int sigqueue(pid_t, int, const union sigval); +extern int sigtimedwait(const sigset_t*, siginfo_t*, const struct timespec*); +extern int sigwaitinfo(const sigset_t*, siginfo_t*); + __END_DECLS #endif /* _SIGNAL_H_ */ |