mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 00:32: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
|
@ -24,11 +24,12 @@
|
|||
#include "libc/intrin/fsgsbase.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/segmentation.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/nt/version.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
void SetUpOnce(void) {
|
||||
__tls_enabled = false;
|
||||
|
@ -126,3 +127,5 @@ TEST(fsgsbase, gs) {
|
|||
TriggerSignal();
|
||||
ASSERT_EQ(0xdeadbeef, gs((int64_t *)0));
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -52,6 +52,8 @@ TEST(sbrk, underflowsEnd_returnsEinval) {
|
|||
ASSERT_SYS(EINVAL, MAP_FAILED, sbrk(-GUARDSIZE));
|
||||
}
|
||||
|
||||
#ifndef __aarch64__
|
||||
// not sure if qemu-aarch64 supports this
|
||||
TEST(sbrk, giantDelta_returnsEnomem) {
|
||||
if (IsXnu()) return; // mmap polyfills this but brk doesn't right now
|
||||
if (IsWsl1()) return; // WSL1 setrlimit() is busted
|
||||
|
@ -61,6 +63,7 @@ TEST(sbrk, giantDelta_returnsEnomem) {
|
|||
ASSERT_SYS(ENOMEM, MAP_FAILED, sbrk(1024 * 1024 * 4));
|
||||
EXITS(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(sbrk, overlapsExistingMapping_failsWithEexist) {
|
||||
char *p = (char *)ROUNDUP((intptr_t)_end, FRAMESIZE);
|
||||
|
|
|
@ -95,25 +95,25 @@ atomic_int sysbarrier;
|
|||
int CloneTestSys(void *arg, int tid) {
|
||||
int i, id = (intptr_t)arg;
|
||||
CheckStackIsAligned();
|
||||
while (!sysbarrier) asm("pause");
|
||||
while (!sysbarrier) donothing;
|
||||
for (i = 0; i < 20; ++i) {
|
||||
switch (id % 3) {
|
||||
case 0:
|
||||
errno = 123;
|
||||
open(0, 0);
|
||||
asm("pause");
|
||||
donothing;
|
||||
ASSERT_EQ(EFAULT, errno);
|
||||
break;
|
||||
case 1:
|
||||
errno = 123;
|
||||
dup(-1);
|
||||
asm("pause");
|
||||
donothing;
|
||||
ASSERT_EQ(EBADF, errno);
|
||||
break;
|
||||
case 2:
|
||||
errno = 123;
|
||||
dup3(0, 0, 0);
|
||||
asm("pause");
|
||||
donothing;
|
||||
ASSERT_EQ(EINVAL, errno);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/pushpop.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -95,6 +96,5 @@ TEST(grow, testOverflow_returnsFalseAndDoesNotFree) {
|
|||
EXPECT_EQ(1, p[0]);
|
||||
EXPECT_EQ(2, p[1]);
|
||||
EXPECT_EQ(3, p[2]);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ TEST(mmap, testMapFixed_destroysEverythingInItsPath) {
|
|||
EXPECT_NE(-1, munmap((void *)kFixedmapStart, FRAMESIZE * 3));
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
TEST(mmap, customStackMemory_isAuthorized) {
|
||||
char *stack;
|
||||
uintptr_t w, r;
|
||||
|
@ -160,6 +161,7 @@ TEST(mmap, customStackMemory_isAuthorized) {
|
|||
ASSERT_EQ(123, r);
|
||||
EXPECT_SYS(0, 0, munmap(stack, STACKSIZE));
|
||||
}
|
||||
#endif /* __x86_64__ */
|
||||
|
||||
TEST(mmap, fileOffset) {
|
||||
int fd;
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/testlib/subprocess.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
TEST(omg, test) {
|
||||
SPAWN(fork);
|
||||
EXITS(0);
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
sigjmp_buf jb;
|
||||
volatile int sigs;
|
||||
|
@ -54,3 +55,5 @@ TEST(sigsetjmp, test) {
|
|||
ASSERT_EQ(1000, jumps);
|
||||
ASSERT_EQ(1000, sigs);
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
#define A TLS_ALIGNMENT
|
||||
|
||||
|
@ -43,6 +43,8 @@ TEST(tls, test) {
|
|||
ASSERT_EQ(A, _Alignof(a));
|
||||
ASSERT_EQ(0, sizeof(struct CosmoTib) % A);
|
||||
ASSERT_EQ(0, (intptr_t)__get_tls() & (A - 1));
|
||||
EXPECT_EQ(2, z);
|
||||
EXPECT_EQ(40, y[0]);
|
||||
EXPECT_EQ(42, x + y[0] + z);
|
||||
y[0] = 666;
|
||||
ASSERT_EQ(0, (intptr_t)&a & (A - 1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue