mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
Port a lot more code to AARCH64
- Introduce epoll_pwait() - Rewrite -ftrapv and ffs() libraries in C code - Use more FreeBSD code in math function library - Get significantly more tests passing on qemu-aarch64 - Fix many Musl long double functions that were broken on AARCH64
This commit is contained in:
parent
91791e9f38
commit
550b52abf6
158 changed files with 6018 additions and 3499 deletions
|
@ -36,7 +36,9 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/cp.internal.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/calls/syscall_support-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
|
@ -71,10 +73,9 @@
|
|||
#include "libc/sock/internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/epoll.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
/**
|
||||
* @fileoverview epoll
|
||||
*
|
||||
|
@ -1520,10 +1521,15 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) {
|
|||
*/
|
||||
int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
|
||||
int timeoutms) {
|
||||
int rc;
|
||||
int e, rc;
|
||||
BEGIN_CANCELLATION_POINT;
|
||||
if (!IsWindows()) {
|
||||
e = errno;
|
||||
rc = sys_epoll_wait(epfd, events, maxevents, timeoutms);
|
||||
if (rc == -1 && errno == ENOSYS) {
|
||||
errno = e;
|
||||
rc = sys_epoll_pwait(epfd, events, maxevents, timeoutms, 0, 0);
|
||||
}
|
||||
} else {
|
||||
rc = sys_epoll_wait_nt(epfd, events, maxevents, timeoutms);
|
||||
}
|
||||
|
@ -1533,4 +1539,39 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
|
|||
return rc;
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
/**
|
||||
* Receives socket events.
|
||||
*
|
||||
* @param events will receive information about what happened
|
||||
* @param maxevents is array length of events
|
||||
* @param timeoutms is milliseconds, 0 to not block, or -1 for forever
|
||||
* @param sigmask is an optional sigprocmask() to use during call
|
||||
* @return number of events stored, 0 on timeout, or -1 w/ errno
|
||||
* @cancellationpoint
|
||||
* @norestart
|
||||
*/
|
||||
int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
|
||||
int timeoutms, const sigset_t *sigmask) {
|
||||
int e, rc;
|
||||
sigset_t oldmask;
|
||||
BEGIN_CANCELLATION_POINT;
|
||||
if (!IsWindows()) {
|
||||
e = errno;
|
||||
rc = sys_epoll_pwait(epfd, events, maxevents, timeoutms, sigmask,
|
||||
sizeof(*sigmask));
|
||||
if (rc == -1 && errno == ENOSYS) {
|
||||
errno = e;
|
||||
if (sigmask) sys_sigprocmask(SIG_SETMASK, sigmask, &oldmask);
|
||||
rc = sys_epoll_wait(epfd, events, maxevents, timeoutms);
|
||||
if (sigmask) sys_sigprocmask(SIG_SETMASK, &oldmask, 0);
|
||||
}
|
||||
} else {
|
||||
if (sigmask) __sig_mask(SIG_SETMASK, sigmask, &oldmask);
|
||||
rc = sys_epoll_wait_nt(epfd, events, maxevents, timeoutms);
|
||||
if (sigmask) __sig_mask(SIG_SETMASK, &oldmask, 0);
|
||||
}
|
||||
END_CANCELLATION_POINT;
|
||||
STRACE("epoll_pwait(%d, %p, %d, %d) → %d% m", epfd, events, maxevents,
|
||||
timeoutms, DescribeSigset(0, sigmask), rc);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_SOCK_WEPOLL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
|
||||
typedef union epoll_data {
|
||||
void *ptr;
|
||||
|
@ -19,6 +20,7 @@ int epoll_create(int);
|
|||
int epoll_create1(int);
|
||||
int epoll_ctl(int, int, int, struct epoll_event *);
|
||||
int epoll_wait(int, struct epoll_event *, int, int);
|
||||
int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/nt/struct/overlapped.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
|
@ -79,6 +80,8 @@ int sys_setsockopt(int, int, int, const void *, uint32_t) _Hide;
|
|||
int32_t sys_epoll_create(int32_t) _Hide;
|
||||
int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *) _Hide;
|
||||
int32_t sys_epoll_wait(int32_t, void *, int32_t, int32_t) _Hide;
|
||||
int32_t sys_epoll_pwait(int32_t, void *, int32_t, int32_t, const sigset_t *,
|
||||
size_t);
|
||||
|
||||
int sys_socket_nt(int, int, int) _Hide;
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "net/http/ip.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#define ORIG_RAX 120
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue