mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:57:35 +00:00
LibC: Mark a bunch of functions as cancellation points
This commit is contained in:
parent
899fd74f8e
commit
c85f307e62
15 changed files with 78 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <bits/pthread_cancel.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -110,6 +111,8 @@ int munlock(void const*, size_t)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/msync.html
|
||||
int msync(void* address, size_t size, int flags)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
int rc = syscall(SC_msync, address, size, flags);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bits/pthread_cancel.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/poll.h>
|
||||
|
@ -18,6 +19,8 @@ extern "C" {
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html
|
||||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timeval* timeout_tv)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
timespec* timeout_ts = nullptr;
|
||||
timespec timeout;
|
||||
if (timeout_tv) {
|
||||
|
@ -30,6 +33,8 @@ int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timev
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html
|
||||
int pselect(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timespec const* timeout, sigset_t const* sigmask)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
Vector<pollfd, FD_SETSIZE> fds;
|
||||
|
||||
if (nfds < 0 || static_cast<size_t>(nfds) >= fds.capacity())
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <bits/pthread_cancel.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -38,6 +39,8 @@ int listen(int sockfd, int backlog)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html
|
||||
int accept(int sockfd, sockaddr* addr, socklen_t* addrlen)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
return accept4(sockfd, addr, addrlen, 0);
|
||||
}
|
||||
|
||||
|
@ -51,6 +54,8 @@ int accept4(int sockfd, sockaddr* addr, socklen_t* addrlen, int flags)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html
|
||||
int connect(int sockfd, sockaddr const* addr, socklen_t addrlen)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
int rc = syscall(SC_connect, sockfd, addr, addrlen);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
@ -65,6 +70,8 @@ int shutdown(int sockfd, int how)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html
|
||||
ssize_t sendmsg(int sockfd, const struct msghdr* msg, int flags)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
int rc = syscall(SC_sendmsg, sockfd, msg, flags);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
@ -86,6 +93,8 @@ ssize_t send(int sockfd, void const* data, size_t data_length, int flags)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html
|
||||
ssize_t recvmsg(int sockfd, struct msghdr* msg, int flags)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
int rc = syscall(SC_recvmsg, sockfd, msg, flags);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
@ -93,6 +102,8 @@ ssize_t recvmsg(int sockfd, struct msghdr* msg, int flags)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html
|
||||
ssize_t recvfrom(int sockfd, void* buffer, size_t buffer_length, int flags, struct sockaddr* addr, socklen_t* addr_length)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
if (!addr_length && addr) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bits/pthread_cancel.h>
|
||||
#include <errno.h>
|
||||
#include <sys/uio.h>
|
||||
#include <syscall.h>
|
||||
|
@ -12,12 +13,16 @@ extern "C" {
|
|||
|
||||
ssize_t writev(int fd, const struct iovec* iov, int iov_count)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
int rc = syscall(SC_writev, fd, iov, iov_count);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
ssize_t readv(int fd, const struct iovec* iov, int iov_count)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
int rc = syscall(SC_readv, fd, iov, iov_count);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <bits/pthread_cancel.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#include <syscall.h>
|
||||
|
@ -21,6 +22,8 @@ pid_t wait(int* wstatus)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html
|
||||
pid_t waitpid(pid_t waitee, int* wstatus, int options)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
siginfo_t siginfo;
|
||||
idtype_t idtype;
|
||||
id_t id;
|
||||
|
@ -78,6 +81,8 @@ pid_t waitpid(pid_t waitee, int* wstatus, int options)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitid.html
|
||||
int waitid(idtype_t idtype, id_t id, siginfo_t* infop, int options)
|
||||
{
|
||||
__pthread_maybe_cancel();
|
||||
|
||||
Syscall::SC_waitid_params params { idtype, id, infop, options };
|
||||
int rc = syscall(SC_waitid, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue