libroot: Merge sigtimedwait.cpp into sigwaitinfo.cpp.

No functional change intended.
This commit is contained in:
Augustin Cavalier 2024-11-09 14:14:52 -05:00
parent 18b7c68ed6
commit 0b04cf2f5b
3 changed files with 43 additions and 51 deletions

View File

@ -32,7 +32,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
sigset.cpp
sigset_accessors.cpp
sigsuspend.cpp
sigtimedwait.cpp
sigwait.cpp
sigwaitinfo.cpp
strsignal.cpp

View File

@ -1,50 +0,0 @@
/*
* Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include <signal.h>
#include <errno.h>
#include <pthread.h>
#include <syscall_utils.h>
#include <errno_private.h>
#include <time_private.h>
#include <syscalls.h>
int
sigtimedwait(const sigset_t* set, siginfo_t* info,
const struct timespec* timeout)
{
// make info non-NULL to simplify things
siginfo_t stackInfo;
if (info == NULL)
info = &stackInfo;
// translate the timeout
uint32 flags;
bigtime_t timeoutMicros;
if (timeout != NULL) {
if (!timespec_to_bigtime(*timeout, timeoutMicros))
RETURN_AND_SET_ERRNO(EINVAL);
timeoutMicros += system_time();
flags = B_ABSOLUTE_TIMEOUT;
} else {
flags = 0;
timeoutMicros = 0;
}
status_t error = _kern_sigwait(set, info, flags, timeoutMicros);
pthread_testcancel();
if (error != B_OK)
RETURN_AND_SET_ERRNO(error);
return info->si_signo;
}

View File

@ -6,9 +6,52 @@
#include <signal.h>
#include <errno.h>
#include <pthread.h>
#include <syscall_utils.h>
#include <errno_private.h>
#include <time_private.h>
#include <syscalls.h>
int
sigwaitinfo(const sigset_t* set, siginfo_t* info)
{
return sigtimedwait(set, info, NULL);
}
int
sigtimedwait(const sigset_t* set, siginfo_t* info,
const struct timespec* timeout)
{
// make info non-NULL to simplify things
siginfo_t stackInfo;
if (info == NULL)
info = &stackInfo;
// translate the timeout
uint32 flags;
bigtime_t timeoutMicros = 0;
if (timeout != NULL) {
if (!timespec_to_bigtime(*timeout, timeoutMicros))
RETURN_AND_SET_ERRNO(EINVAL);
timeoutMicros += system_time();
flags = B_ABSOLUTE_TIMEOUT;
} else {
flags = 0;
timeoutMicros = 0;
}
status_t error = _kern_sigwait(set, info, flags, timeoutMicros);
pthread_testcancel();
if (error != B_OK)
RETURN_AND_SET_ERRNO(error);
return info->si_signo;
}