Fix sigsuspend to use rt_sigsuspend on all platforms.

Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
This commit is contained in:
Elliott Hughes 2013-10-15 18:01:56 -07:00
parent c100a10069
commit 1f5af926fa
15 changed files with 69 additions and 82 deletions

View File

@ -184,7 +184,6 @@ libc_common_src_files += \
bionic/fstatfs.c \
bionic/__get_tls.cpp \
bionic/lseek64.c \
bionic/sigsuspend.c \
bionic/statfs.c \
endif
@ -248,6 +247,7 @@ libc_bionic_src_files := \
bionic/setlocale.cpp \
bionic/signalfd.cpp \
bionic/sigprocmask.cpp \
bionic/sigsuspend.cpp \
bionic/sigwait.cpp \
bionic/statvfs.cpp \
bionic/strerror.cpp \

View File

@ -233,14 +233,12 @@ int timerfd_gettime(int, struct itimerspec*) all
# signals
int sigaction(int, const struct sigaction*, struct sigaction*) arm,x86,mips
int __sigsuspend:sigsuspend(int unused1, int unused2, unsigned mask) arm,x86
int __sigsuspend:sigsuspend(const sigset_t* mask) mips
int __rt_sigsuspend:rt_sigsuspend(const sigset_t *unewset, size_t sigset_size) x86_64
int __rt_sigaction:rt_sigaction(int sig, const struct sigaction* act, struct sigaction* oact, size_t sigsetsize) all
int __rt_sigprocmask:rt_sigprocmask(int how, const sigset_t* set, sigset_t* oset, size_t sigsetsize) all
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t* set, struct siginfo_t* info, struct timespec_t* timeout, size_t sigset_size) all
int sigpending(sigset_t*) arm,x86,mips
int signalfd4(int fd, const sigset_t* mask, size_t sizemask, int flags) all
int __rt_sigaction:rt_sigaction(int, const struct sigaction*, struct sigaction*, 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 signalfd4(int, const sigset_t*, size_t, int) all
# sockets
int socket(int, int, int) arm,mips,x86_64

View File

@ -152,11 +152,11 @@ syscall_src += arch-arm/syscalls/timerfd_create.S
syscall_src += arch-arm/syscalls/timerfd_settime.S
syscall_src += arch-arm/syscalls/timerfd_gettime.S
syscall_src += arch-arm/syscalls/sigaction.S
syscall_src += arch-arm/syscalls/__sigsuspend.S
syscall_src += arch-arm/syscalls/sigpending.S
syscall_src += arch-arm/syscalls/__rt_sigaction.S
syscall_src += arch-arm/syscalls/__rt_sigprocmask.S
syscall_src += arch-arm/syscalls/__rt_sigsuspend.S
syscall_src += arch-arm/syscalls/__rt_sigtimedwait.S
syscall_src += arch-arm/syscalls/sigpending.S
syscall_src += arch-arm/syscalls/signalfd4.S
syscall_src += arch-arm/syscalls/socket.S
syscall_src += arch-arm/syscalls/socketpair.S

View File

@ -3,13 +3,13 @@
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(__sigsuspend)
ENTRY(__rt_sigsuspend)
mov ip, r7
ldr r7, =__NR_sigsuspend
ldr r7, =__NR_rt_sigsuspend
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(__sigsuspend)
END(__rt_sigsuspend)

View File

@ -155,11 +155,11 @@ syscall_src += arch-mips/syscalls/timerfd_create.S
syscall_src += arch-mips/syscalls/timerfd_settime.S
syscall_src += arch-mips/syscalls/timerfd_gettime.S
syscall_src += arch-mips/syscalls/sigaction.S
syscall_src += arch-mips/syscalls/__sigsuspend.S
syscall_src += arch-mips/syscalls/sigpending.S
syscall_src += arch-mips/syscalls/__rt_sigaction.S
syscall_src += arch-mips/syscalls/__rt_sigprocmask.S
syscall_src += arch-mips/syscalls/__rt_sigsuspend.S
syscall_src += arch-mips/syscalls/__rt_sigtimedwait.S
syscall_src += arch-mips/syscalls/sigpending.S
syscall_src += arch-mips/syscalls/signalfd4.S
syscall_src += arch-mips/syscalls/socket.S
syscall_src += arch-mips/syscalls/socketpair.S

View File

@ -1,14 +1,14 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
.globl __sigsuspend
.globl __rt_sigsuspend
.align 4
.ent __sigsuspend
.ent __rt_sigsuspend
__sigsuspend:
__rt_sigsuspend:
.set noreorder
.cpload $t9
li $v0, __NR_sigsuspend
li $v0, __NR_rt_sigsuspend
syscall
bnez $a3, 1f
move $a0, $v0
@ -19,4 +19,4 @@ __sigsuspend:
j $t9
nop
.set reorder
.end __sigsuspend
.end __rt_sigsuspend

View File

@ -156,11 +156,11 @@ syscall_src += arch-x86/syscalls/timerfd_create.S
syscall_src += arch-x86/syscalls/timerfd_settime.S
syscall_src += arch-x86/syscalls/timerfd_gettime.S
syscall_src += arch-x86/syscalls/sigaction.S
syscall_src += arch-x86/syscalls/__sigsuspend.S
syscall_src += arch-x86/syscalls/sigpending.S
syscall_src += arch-x86/syscalls/__rt_sigaction.S
syscall_src += arch-x86/syscalls/__rt_sigprocmask.S
syscall_src += arch-x86/syscalls/__rt_sigsuspend.S
syscall_src += arch-x86/syscalls/__rt_sigtimedwait.S
syscall_src += arch-x86/syscalls/sigpending.S
syscall_src += arch-x86/syscalls/signalfd4.S
syscall_src += arch-x86/syscalls/socket.S
syscall_src += arch-x86/syscalls/bind.S

View File

@ -3,14 +3,12 @@
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(__sigsuspend)
ENTRY(__rt_sigsuspend)
pushl %ebx
pushl %ecx
pushl %edx
mov 16(%esp), %ebx
mov 20(%esp), %ecx
mov 24(%esp), %edx
movl $__NR_sigsuspend, %eax
mov 12(%esp), %ebx
mov 16(%esp), %ecx
movl $__NR_rt_sigsuspend, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@ -20,8 +18,7 @@ ENTRY(__sigsuspend)
addl $4, %esp
orl $-1, %eax
1:
popl %edx
popl %ecx
popl %ebx
ret
END(__sigsuspend)
END(__rt_sigsuspend)

View File

@ -149,9 +149,9 @@ syscall_src += arch-x86_64/syscalls/utimensat.S
syscall_src += arch-x86_64/syscalls/timerfd_create.S
syscall_src += arch-x86_64/syscalls/timerfd_settime.S
syscall_src += arch-x86_64/syscalls/timerfd_gettime.S
syscall_src += arch-x86_64/syscalls/__rt_sigsuspend.S
syscall_src += arch-x86_64/syscalls/__rt_sigaction.S
syscall_src += arch-x86_64/syscalls/__rt_sigprocmask.S
syscall_src += arch-x86_64/syscalls/__rt_sigsuspend.S
syscall_src += arch-x86_64/syscalls/__rt_sigtimedwait.S
syscall_src += arch-x86_64/syscalls/signalfd4.S
syscall_src += arch-x86_64/syscalls/socket.S

View File

@ -9,7 +9,6 @@ _LIBC_ARCH_COMMON_SRC_FILES := \
arch-x86_64/bionic/__set_tls.c \
arch-x86_64/bionic/sigaction.c \
arch-x86_64/bionic/sigsetjmp.S \
arch-x86_64/bionic/sigsuspend.c \
arch-x86_64/bionic/syscall.S \
_LIBC_ARCH_STATIC_SRC_FILES := \

View File

@ -28,7 +28,7 @@
#include <sys/signalfd.h>
#include <private/kernel_sigset_t.h>
#include "private/kernel_sigset_t.h"
extern "C" int signalfd4(int fd, kernel_sigset_t* mask, size_t sizemask, int flags);

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2008 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>
#ifdef __mips__
extern int __sigsuspend(const sigset_t *);
#else
extern int __sigsuspend(int, int, unsigned int);
#endif
int sigsuspend(const sigset_t *_mask)
{
#ifdef __mips__
return __sigsuspend(_mask);
#else
unsigned int mask = (unsigned int)*_mask;
return __sigsuspend(0, 0, mask);
#endif
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,8 +28,11 @@
#include <signal.h>
extern int __rt_sigsuspend(const sigset_t*, size_t);
#include "private/kernel_sigset_t.h"
int sigsuspend(const sigset_t* set) {
return __rt_sigsuspend(set, sizeof(sigset_t));
extern "C" int __rt_sigsuspend(const kernel_sigset_t*, size_t);
int sigsuspend(const sigset_t* bionic_set) {
kernel_sigset_t set(bionic_set);
return __rt_sigsuspend(&set, sizeof(set));
}

View File

@ -31,7 +31,7 @@
#include <string.h>
#include <time.h>
#include <private/kernel_sigset_t.h>
#include "private/kernel_sigset_t.h"
extern "C" int __rt_sigtimedwait(const sigset_t* uthese, siginfo_t* uinfo, const struct timespec* uts, size_t sigsetsize);

View File

@ -153,3 +153,36 @@ TEST(signal, sigwait) {
ASSERT_EQ(0, errno);
ASSERT_EQ(SIGALRM, received_signal);
}
static int gSigSuspendTestHelperCallCount = 0;
static void SigSuspendTestHelper(int) {
++gSigSuspendTestHelperCallCount;
}
TEST(signal, sigsuspend) {
ScopedSignalHandler ssh(SIGALRM, SigSuspendTestHelper);
// Block SIGALRM.
sigset_t just_SIGALRM;
sigemptyset(&just_SIGALRM);
sigaddset(&just_SIGALRM, SIGALRM);
sigset_t original_set;
ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &just_SIGALRM, &original_set));
// Raise SIGALRM and check our signal handler wasn't called.
raise(SIGALRM);
ASSERT_EQ(0, gSigSuspendTestHelperCallCount);
// Use sigsuspend to block everything except SIGALRM...
sigset_t not_SIGALRM;
sigfillset(&not_SIGALRM);
sigdelset(&not_SIGALRM, SIGALRM);
ASSERT_EQ(-1, sigsuspend(&not_SIGALRM));
ASSERT_EQ(EINTR, errno);
// ...and check that we now receive our pending SIGALRM.
ASSERT_EQ(1, gSigSuspendTestHelperCallCount);
// Restore the original set.
assert(0 == sigprocmask(SIG_SETMASK, &original_set, NULL));
}