mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Update tests and CPU detection for Blink
This commit is contained in:
parent
be3e109309
commit
006c44ff5d
24 changed files with 206 additions and 56 deletions
|
@ -239,7 +239,7 @@
|
|||
int pledge(const char *promises, const char *execpromises) {
|
||||
int e, rc;
|
||||
unsigned long ipromises, iexecpromises;
|
||||
if (IsGenuineCosmo() || IsGenuineBlink()) {
|
||||
if (IsGenuineBlink()) {
|
||||
rc = 0; // blink doesn't support seccomp
|
||||
} else if (!ParsePromises(promises, &ipromises) &&
|
||||
!ParsePromises(execpromises, &iexecpromises)) {
|
||||
|
|
|
@ -354,7 +354,7 @@ int sys_unveil_linux(const char *path, const char *permissions) {
|
|||
int unveil(const char *path, const char *permissions) {
|
||||
int e, rc;
|
||||
e = errno;
|
||||
if (IsGenuineCosmo() || IsGenuineBlink()) {
|
||||
if (IsGenuineBlink()) {
|
||||
rc = 0; // blink doesn't support landlock
|
||||
} else if (IsLinux()) {
|
||||
rc = sys_unveil_linux(path, permissions);
|
||||
|
|
34
libc/intrin/getcpuidbrand.c
Normal file
34
libc/intrin/getcpuidbrand.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- 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 2023 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/runtime/runtime.h"
|
||||
|
||||
void GetCpuidBrand(char s[13], uint32_t leaf) {
|
||||
int ax, cx;
|
||||
asm("push\t%%rbx\r\n"
|
||||
"cpuid\r\n"
|
||||
"mov\t%%ebx,0+%2\r\n"
|
||||
"mov\t%%ecx,4+%2\r\n"
|
||||
"mov\t%%edx,8+%2\r\n"
|
||||
"movb\t$0,12+%2\r\n"
|
||||
"pop\t%%rbx"
|
||||
: "=a"(ax), "=c"(cx), "=o"(*(char(*)[13])s)
|
||||
: "0"(leaf), "1"(0)
|
||||
: "rdx");
|
||||
s[12] = 0;
|
||||
}
|
29
libc/intrin/getcpuidemulator.c
Normal file
29
libc/intrin/getcpuidemulator.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- 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 2023 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/runtime/runtime.h"
|
||||
|
||||
const char *GetCpuidEmulator(void) {
|
||||
static bool once;
|
||||
static char s[13];
|
||||
if (!once) {
|
||||
GetCpuidBrand(s, 0x40000000);
|
||||
once = true;
|
||||
}
|
||||
return s;
|
||||
}
|
29
libc/intrin/getcpuidos.c
Normal file
29
libc/intrin/getcpuidos.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- 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 2023 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/runtime/runtime.h"
|
||||
|
||||
const char *GetCpuidOs(void) {
|
||||
static bool once;
|
||||
static char s[13];
|
||||
if (!once) {
|
||||
GetCpuidBrand(s, 0x40031337);
|
||||
once = true;
|
||||
}
|
||||
return s;
|
||||
}
|
24
libc/intrin/iscygwin.c
Normal file
24
libc/intrin/iscygwin.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- 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 2023 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/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
bool IsCygwin(void) {
|
||||
return IsGenuineBlink() && !strcmp(GetCpuidOs(), "Cygwin");
|
||||
}
|
|
@ -21,7 +21,6 @@
|
|||
#include "libc/intrin/promises.internal.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/nt/struct/teb.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
@ -42,7 +41,6 @@ int IsDebuggerPresent(bool force) {
|
|||
ssize_t got;
|
||||
int e, fd, res;
|
||||
char *p, buf[1024];
|
||||
if (!force && IsGenuineCosmo()) return 0;
|
||||
if (!force && IsGenuineBlink()) return 0;
|
||||
if (!force && __getenv(environ, "HEISENDEBUG")) return 0;
|
||||
if (IsWindows()) return IsBeingDebugged();
|
||||
|
|
25
libc/intrin/isgenuineblink.c
Normal file
25
libc/intrin/isgenuineblink.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-*- 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 2023 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/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
bool IsGenuineBlink(void) {
|
||||
return X86_HAVE(HYPERVISOR) && !strcmp(GetCpuidEmulator(), "GenuineBlink");
|
||||
}
|
|
@ -57,8 +57,7 @@ relegated int(AttachDebugger)(intptr_t continuetoaddr) {
|
|||
char pidstr[11], breakcmd[40];
|
||||
const char *se, *elf, *gdb, *rewind, *layout;
|
||||
__restore_tty();
|
||||
if (IsGenuineCosmo() || IsGenuineBlink() || !(gdb = GetGdbPath()) ||
|
||||
!isatty(0) || !isatty(1) ||
|
||||
if (IsGenuineBlink() || !(gdb = GetGdbPath()) || !isatty(0) || !isatty(1) ||
|
||||
(ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -13,15 +13,5 @@
|
|||
kCpuids[KCPUIDS_0H][KCPUIDS_EDX] == 0x49656e69 /* ineI */ && \
|
||||
kCpuids[KCPUIDS_0H][KCPUIDS_ECX] == 0x6c65746e /* ntel */)
|
||||
|
||||
#define IsGenuineCosmo() \
|
||||
(kCpuids[KCPUIDS_0H][KCPUIDS_EBX] == 0x756e6547 /* Genu */ && \
|
||||
kCpuids[KCPUIDS_0H][KCPUIDS_EDX] == 0x43656e69 /* ineC */ && \
|
||||
kCpuids[KCPUIDS_0H][KCPUIDS_ECX] == 0x6f6d736f /* osmo */)
|
||||
|
||||
#define IsGenuineBlink() \
|
||||
(kCpuids[KCPUIDS_0H][KCPUIDS_EBX] == 0x756e6547 /* Genu */ && \
|
||||
kCpuids[KCPUIDS_0H][KCPUIDS_EDX] == 0x42656e69 /* ineB */ && \
|
||||
kCpuids[KCPUIDS_0H][KCPUIDS_ECX] == 0x6b6e696c /* link */)
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_VENDOR_H_ */
|
||||
|
|
|
@ -37,11 +37,14 @@ unsigned long getauxval(unsigned long);
|
|||
void *_mapanon(size_t) attributeallocsize((1)) mallocesque;
|
||||
void *_mapshared(size_t) attributeallocsize((1)) mallocesque;
|
||||
void *_mapstack(void) returnsaligned((FRAMESIZE)) mallocesque;
|
||||
int setjmp(jmp_buf) libcesque returnstwice paramsnonnull();
|
||||
int setjmp(jmp_buf)
|
||||
libcesque returnstwice paramsnonnull();
|
||||
void longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
|
||||
axdx_t setlongerjmp(jmp_buf) libcesque returnstwice paramsnonnull();
|
||||
axdx_t setlongerjmp(jmp_buf)
|
||||
libcesque returnstwice paramsnonnull();
|
||||
void longerjmp(jmp_buf, intptr_t) libcesque wontreturn paramsnonnull();
|
||||
int _setjmp(jmp_buf) libcesque returnstwice paramsnonnull();
|
||||
int _setjmp(jmp_buf)
|
||||
libcesque returnstwice paramsnonnull();
|
||||
int sigsetjmp(sigjmp_buf, int) libcesque returnstwice paramsnonnull();
|
||||
void siglongjmp(sigjmp_buf, int) libcesque wontreturn paramsnonnull();
|
||||
void _longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
|
||||
|
@ -107,6 +110,11 @@ void __warn_if_powersave(void);
|
|||
const char *__describe_os(void);
|
||||
bool IsDynamicExecutable(const char *);
|
||||
void _restorewintty(void);
|
||||
const char *GetCpuidOs(void);
|
||||
const char *GetCpuidEmulator(void);
|
||||
void GetCpuidBrand(char[13], uint32_t);
|
||||
bool IsGenuineBlink(void);
|
||||
bool IsCygwin(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -133,11 +133,6 @@ static void FixIrregularFds(void) {
|
|||
pfds[i].fd = i + 3;
|
||||
pfds[i].events = POLLIN;
|
||||
}
|
||||
if (IsGenuineCosmo()) {
|
||||
// TODO(jart): Fix Blinkenlights poll() / close()
|
||||
free(pfds);
|
||||
return;
|
||||
}
|
||||
if (poll(pfds, maxfds, 0) != -1) {
|
||||
for (i = 0; i < maxfds; ++i) {
|
||||
if (pfds[i].revents & POLLNVAL) continue;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -86,16 +87,20 @@ TEST(ftruncate, test) {
|
|||
ASSERT_SYS(0, 5, lseek(3, 0, SEEK_CUR)); // doesn't change position
|
||||
ASSERT_SYS(0, 5, write(3, "world", 5));
|
||||
ASSERT_SYS(0, 0, fstat(3, &st));
|
||||
ASSERT_EQ(8192, st.st_size); // 8192 is logical size
|
||||
if (IsWindows() || IsNetbsd() || IsOpenbsd()) { //
|
||||
ASSERT_EQ(8192 / 512, st.st_blocks); // 8192 is physical size
|
||||
} else if (IsFreebsd()) { //
|
||||
ASSERT_EQ(512 / 512, st.st_blocks); // 512 is physical size
|
||||
} else if (IsLinux() || IsXnu()) { //
|
||||
ASSERT_EQ(4096 / 512, st.st_blocks); // 4096 is physical size
|
||||
} else {
|
||||
notpossible;
|
||||
ASSERT_EQ(8192, st.st_size);
|
||||
#if 0
|
||||
if (!IsGenuineBlink()) {
|
||||
if (IsWindows() || IsNetbsd() || IsOpenbsd()) { //
|
||||
ASSERT_EQ(8192 / 512, st.st_blocks); // 8192 is physical size
|
||||
} else if (IsFreebsd()) { //
|
||||
ASSERT_EQ(512 / 512, st.st_blocks); // 512 is physical size
|
||||
} else if (IsLinux() || IsXnu()) { //
|
||||
ASSERT_EQ(4096 / 512, st.st_blocks); // 4096 is physical size
|
||||
} else {
|
||||
notpossible;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ASSERT_SYS(0, 512, pread(3, got, 512, 0));
|
||||
ASSERT_EQ(0, memcmp(want, got, 512));
|
||||
ASSERT_SYS(0, 0, ftruncate(3, 0)); // shrink file to be empty
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
@ -48,6 +49,7 @@ TEST(pipe, ebadf) {
|
|||
|
||||
TEST(pipe, emfile) {
|
||||
if (IsWindows()) return; // TODO
|
||||
if (IsCygwin()) return;
|
||||
ASSERT_NE(-1, (pid = fork()));
|
||||
if (!pid) {
|
||||
ASSERT_EQ(0, setrlimit(RLIMIT_NOFILE, &rlim));
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -184,6 +185,7 @@ TEST(sigaction, ignoringSignalDiscardsSignal) {
|
|||
|
||||
TEST(sigaction, autoZombieSlayer) {
|
||||
if (IsWindows()) return;
|
||||
if (IsCygwin()) return;
|
||||
int pid;
|
||||
struct sigaction sa;
|
||||
// make sure we're starting in expected state
|
||||
|
@ -194,8 +196,8 @@ TEST(sigaction, autoZombieSlayer) {
|
|||
if (!pid) _Exit(0);
|
||||
ASSERT_SYS(0, pid, wait(0));
|
||||
// enable automatic zombie slayer
|
||||
sa.sa_handler = SIG_DFL; // POSIX.1 says no SIG_IGN
|
||||
sa.sa_flags = SA_NOCLDWAIT; // seems to be optional
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sa.sa_flags = 0;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
ASSERT_SYS(0, 0, sigaction(SIGCHLD, &sa, &sa));
|
||||
// verify it works
|
||||
|
|
|
@ -82,18 +82,18 @@ TEST(writev, test) {
|
|||
|
||||
TEST(writev, big_fullCompletion) {
|
||||
int fd;
|
||||
char *ba = gc(malloc(2 * 1024 * 1024));
|
||||
char *bb = gc(malloc(2 * 1024 * 1024));
|
||||
char *bc = gc(malloc(2 * 1024 * 1024));
|
||||
char *ba = gc(malloc(1024 * 1024));
|
||||
char *bb = gc(malloc(1024 * 1024));
|
||||
char *bc = gc(malloc(1024 * 1024));
|
||||
struct iovec iov[] = {
|
||||
{"", 0}, //
|
||||
{ba, 2 * 1024 * 1024}, //
|
||||
{NULL, 0}, //
|
||||
{bb, 2 * 1024 * 1024}, //
|
||||
{bc, 2 * 1024 * 1024}, //
|
||||
{"", 0}, //
|
||||
{ba, 1024 * 1024}, //
|
||||
{NULL, 0}, //
|
||||
{bb, 1024 * 1024}, //
|
||||
{bc, 1024 * 1024}, //
|
||||
};
|
||||
ASSERT_NE(-1, (fd = open("file", O_RDWR | O_CREAT | O_TRUNC, 0644)));
|
||||
EXPECT_EQ(6 * 1024 * 1024, writev(fd, iov, ARRAYLEN(iov)));
|
||||
EXPECT_EQ(3 * 1024 * 1024, writev(fd, iov, ARRAYLEN(iov)));
|
||||
EXPECT_NE(-1, close(fd));
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,8 @@ TEST(writev, empty_stillPerformsIoOperation) {
|
|||
struct iovec iov[] = {{"", 0}, {NULL, 0}};
|
||||
ASSERT_NE(-1, touch("file", 0644));
|
||||
ASSERT_NE(-1, (fd = open("file", O_RDONLY)));
|
||||
EXPECT_EQ(-1, writev(fd, iov, ARRAYLEN(iov)));
|
||||
errno = 0;
|
||||
EXPECT_SYS(EBADF, -1, writev(fd, iov, ARRAYLEN(iov)));
|
||||
EXPECT_EQ(-1, writev(fd, NULL, 0));
|
||||
EXPECT_NE(-1, close(fd));
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/nt/version.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -124,6 +125,7 @@ TEST(unix, stream) {
|
|||
|
||||
TEST(unix, serverGoesDown_deletedSockFile) { // field of landmine
|
||||
if (IsWindows()) return;
|
||||
if (IsCygwin()) return;
|
||||
int ws, rc;
|
||||
char buf[8] = {0};
|
||||
uint32_t len = sizeof(struct sockaddr_un);
|
||||
|
@ -135,7 +137,10 @@ TEST(unix, serverGoesDown_deletedSockFile) { // field of landmine
|
|||
ASSERT_SYS(0, 5, write(4, "hello", 5));
|
||||
ASSERT_SYS(0, 5, read(3, buf, 8));
|
||||
ASSERT_SYS(0, 0, close(3));
|
||||
ASSERT_SYS(IsBsd() ? ECONNRESET : ECONNREFUSED, -1, write(4, "hello", 5));
|
||||
ASSERT_EQ(-1, write(4, "hello", 5));
|
||||
ASSERT_TRUE(errno == ECONNREFUSED || // Linux
|
||||
errno == ECONNRESET); // BSDs
|
||||
errno = 0;
|
||||
ASSERT_SYS(0, 0, unlink(addr.sun_path));
|
||||
ASSERT_SYS(0, 3, socket(AF_UNIX, SOCK_DGRAM, 0));
|
||||
ASSERT_SYS(0, 0, bind(3, (void *)&addr, len));
|
||||
|
@ -156,6 +161,7 @@ TEST(unix, serverGoesDown_deletedSockFile) { // field of landmine
|
|||
|
||||
TEST(unix, serverGoesDown_usingSendTo_unlink) { // much easier
|
||||
if (IsWindows()) return;
|
||||
if (IsCygwin()) return;
|
||||
int ws, rc;
|
||||
char buf[8] = {0};
|
||||
uint32_t len = sizeof(struct sockaddr_un);
|
||||
|
|
|
@ -137,7 +137,7 @@ static const struct {
|
|||
};
|
||||
|
||||
TEST(printf, longdouble) {
|
||||
if (IsGenuineCosmo() || IsGenuineBlink()) {
|
||||
if (IsGenuineBlink()) {
|
||||
return; // TODO(jart): long double precision in blink
|
||||
}
|
||||
int i;
|
||||
|
|
|
@ -42,7 +42,7 @@ int DbOpen(const char *path, sqlite3 **db) {
|
|||
int i, rc;
|
||||
rc = sqlite3_open(path, db);
|
||||
if (rc != SQLITE_OK) return rc;
|
||||
for (i = 0; i < 12; ++i) {
|
||||
for (i = 0; i < 16; ++i) {
|
||||
rc = sqlite3_exec(*db, "PRAGMA journal_mode=WAL", 0, 0, 0);
|
||||
if (rc == SQLITE_OK) break;
|
||||
if (rc != SQLITE_BUSY) return rc;
|
||||
|
@ -53,7 +53,7 @@ int DbOpen(const char *path, sqlite3 **db) {
|
|||
|
||||
int DbStep(sqlite3_stmt *stmt) {
|
||||
int i, rc;
|
||||
for (i = 0; i < 12; ++i) {
|
||||
for (i = 0; i < 16; ++i) {
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc == SQLITE_ROW) break;
|
||||
if (rc == SQLITE_DONE) break;
|
||||
|
@ -65,7 +65,7 @@ int DbStep(sqlite3_stmt *stmt) {
|
|||
|
||||
int DbExec(sqlite3 *db, const char *sql) {
|
||||
int i, rc;
|
||||
for (i = 0; i < 12; ++i) {
|
||||
for (i = 0; i < 16; ++i) {
|
||||
rc = sqlite3_exec(db, sql, 0, 0, 0);
|
||||
if (rc == SQLITE_OK) break;
|
||||
if (rc != SQLITE_BUSY) return rc;
|
||||
|
|
|
@ -150,7 +150,7 @@ static int GetAfd(struct Machine *m, int fd) {
|
|||
}
|
||||
|
||||
static const char *GetSimulated(void) {
|
||||
if (IsGenuineCosmo() || IsGenuineBlink()) {
|
||||
if (IsGenuineBlink()) {
|
||||
return " SIMULATED";
|
||||
} else {
|
||||
return "";
|
||||
|
|
|
@ -47,8 +47,7 @@ void ThrowSegmentationFault(struct Machine *m, int64_t va) {
|
|||
WARNF("%s%s ADDR %012lx IP %012lx AX %lx CX %lx DX %lx BX %lx SP %lx "
|
||||
"BP %lx SI %lx DI %lx R8 %lx R9 %lx R10 %lx R11 %lx R12 %lx R13 %lx "
|
||||
"R14 %lx R15 %lx",
|
||||
"SEGMENTATION FAULT",
|
||||
IsGenuineCosmo() || IsGenuineBlink() ? " SIMULATED" : "", va, m->ip,
|
||||
"SEGMENTATION FAULT", IsGenuineBlink() ? " SIMULATED" : "", va, m->ip,
|
||||
Read64(m->ax), Read64(m->cx), Read64(m->dx), Read64(m->bx),
|
||||
Read64(m->sp), Read64(m->bp), Read64(m->si), Read64(m->di),
|
||||
Read64(m->r8), Read64(m->r9), Read64(m->r10), Read64(m->r11),
|
||||
|
|
|
@ -205,6 +205,8 @@
|
|||
"__weak__"
|
||||
"__vector_size__"
|
||||
"__ms_abi__"
|
||||
"__sysv_abi__"
|
||||
"systemfive"
|
||||
"__mode__"
|
||||
"__seg_fs"
|
||||
"__seg_gs"))
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
"__code_model_medium__"))
|
||||
|
||||
(cpp92
|
||||
'("__BYTE_ORDER__"
|
||||
'("__SEG_FS"
|
||||
"__SEG_GS"
|
||||
"__BYTE_ORDER__"
|
||||
"__ORDER_LITTLE_ENDIAN__"
|
||||
"__ORDER_BIG_ENDIAN__"
|
||||
"__ORDER_PDP_ENDIAN__"
|
||||
|
|
|
@ -637,7 +637,7 @@ static void DropOutput(void) {
|
|||
}
|
||||
|
||||
static bool ShouldAvoidGzip(void) {
|
||||
return IsGenuineCosmo() || (IsGenuineBlink() && !X86_HAVE(JIT));
|
||||
return (IsGenuineBlink() && !X86_HAVE(JIT));
|
||||
}
|
||||
|
||||
static char *MergePaths(const char *p, size_t n, const char *q, size_t m,
|
||||
|
@ -7266,7 +7266,7 @@ static void GetOpts(int argc, char *argv[]) {
|
|||
int opt;
|
||||
bool storeasset = false;
|
||||
// only generate ecp cert under blinkenlights (rsa is slow)
|
||||
norsagen = IsGenuineCosmo() || IsGenuineBlink();
|
||||
norsagen = IsGenuineBlink();
|
||||
while ((opt = getopt(argc, argv, GETOPTS)) != -1) {
|
||||
switch (opt) {
|
||||
CASE('S', ++sandboxed);
|
||||
|
|
Loading…
Reference in a new issue