diff --git a/libc/calls/pledge.c b/libc/calls/pledge.c index c15ace04f..ace419995 100644 --- a/libc/calls/pledge.c +++ b/libc/calls/pledge.c @@ -239,7 +239,7 @@ int pledge(const char *promises, const char *execpromises) { int e, rc; unsigned long ipromises, iexecpromises; - if (IsGenuineCosmo()) { + if (IsGenuineCosmo() || IsGenuineBlink()) { rc = 0; // blink doesn't support seccomp } else if (!ParsePromises(promises, &ipromises) && !ParsePromises(execpromises, &iexecpromises)) { diff --git a/libc/calls/unveil.c b/libc/calls/unveil.c index 3674d6ee9..346e5ea78 100644 --- a/libc/calls/unveil.c +++ b/libc/calls/unveil.c @@ -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()) { + if (IsGenuineCosmo() || IsGenuineBlink()) { rc = 0; // blink doesn't support landlock } else if (IsLinux()) { rc = sys_unveil_linux(path, permissions); diff --git a/libc/intrin/isdebuggerpresent.c b/libc/intrin/isdebuggerpresent.c index 579ae4577..22285cbfc 100644 --- a/libc/intrin/isdebuggerpresent.c +++ b/libc/intrin/isdebuggerpresent.c @@ -43,6 +43,7 @@ int IsDebuggerPresent(bool force) { 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(); if (__isworker) return false; diff --git a/libc/log/attachdebugger.c b/libc/log/attachdebugger.c index 454dd53c1..dd7fecc66 100644 --- a/libc/log/attachdebugger.c +++ b/libc/log/attachdebugger.c @@ -57,7 +57,8 @@ relegated int(AttachDebugger)(intptr_t continuetoaddr) { char pidstr[11], breakcmd[40]; const char *se, *elf, *gdb, *rewind, *layout; __restore_tty(); - if (IsGenuineCosmo() || !(gdb = GetGdbPath()) || !isatty(0) || !isatty(1) || + if (IsGenuineCosmo() || IsGenuineBlink() || !(gdb = GetGdbPath()) || + !isatty(0) || !isatty(1) || (ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC)) == -1) { return -1; } diff --git a/libc/nexgen32e/vendor.internal.h b/libc/nexgen32e/vendor.internal.h index 7f74f9495..8e3a7b9ba 100644 --- a/libc/nexgen32e/vendor.internal.h +++ b/libc/nexgen32e/vendor.internal.h @@ -18,5 +18,10 @@ 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_ */ diff --git a/libc/thread/sem_getvalue.c b/libc/thread/sem_getvalue.c index 654e0e117..db638f248 100644 --- a/libc/thread/sem_getvalue.c +++ b/libc/thread/sem_getvalue.c @@ -22,7 +22,7 @@ #include "libc/thread/semaphore.h" /** - * Destroys unnamed semaphore. + * Returns semaphore value. * * @param sem was created by sem_init() * @param sval receives output value diff --git a/test/libc/stdio/dtoa_test.c b/test/libc/stdio/dtoa_test.c index 59590f2cf..677cbcec1 100644 --- a/test/libc/stdio/dtoa_test.c +++ b/test/libc/stdio/dtoa_test.c @@ -137,7 +137,9 @@ static const struct { }; TEST(printf, longdouble) { - if (IsGenuineCosmo()) return; // TODO(jart): long double precision in blink + if (IsGenuineCosmo() || IsGenuineBlink()) { + return; // TODO(jart): long double precision in blink + } int i; for (i = 0; i < ARRAYLEN(Vx); ++i) { ++g_testlib_ran; diff --git a/test/libc/thread/pthread_create_test.c b/test/libc/thread/pthread_create_test.c index 70f25f09f..4cc9e2ee2 100644 --- a/test/libc/thread/pthread_create_test.c +++ b/test/libc/thread/pthread_create_test.c @@ -99,7 +99,6 @@ static void *CheckSchedule(void *arg) { TEST(pthread_create, scheduling) { pthread_t id; pthread_attr_t attr; - if (IsGenuineCosmo()) return; // TODO(jart): blink struct sched_param pri = {sched_get_priority_min(SCHED_OTHER)}; ASSERT_EQ(0, pthread_attr_init(&attr)); ASSERT_EQ(0, pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED)); diff --git a/third_party/nsync/futex.c b/third_party/nsync/futex.c index deb3a63e0..7efd89058 100644 --- a/third_party/nsync/futex.c +++ b/third_party/nsync/futex.c @@ -66,10 +66,6 @@ __attribute__((__constructor__)) static void nsync_futex_init_ (void) { FUTEX_WAIT_ = FUTEX_WAIT; - if (IsGenuineCosmo ()) { - return; - } - if (IsWindows ()) { futex_is_supported = true; return; diff --git a/tool/build/lib/syscall.c b/tool/build/lib/syscall.c index b253468cf..2fd75102a 100644 --- a/tool/build/lib/syscall.c +++ b/tool/build/lib/syscall.c @@ -150,7 +150,7 @@ static int GetAfd(struct Machine *m, int fd) { } static const char *GetSimulated(void) { - if (IsGenuineCosmo()) { + if (IsGenuineCosmo() || IsGenuineBlink()) { return " SIMULATED"; } else { return ""; diff --git a/tool/build/lib/throw.c b/tool/build/lib/throw.c index 1ce6187dd..9922e2e6a 100644 --- a/tool/build/lib/throw.c +++ b/tool/build/lib/throw.c @@ -18,8 +18,8 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/log/check.h" #include "libc/log/log.h" -#include "libc/nexgen32e/vendor.internal.h" #include "libc/mem/gc.internal.h" +#include "libc/nexgen32e/vendor.internal.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "tool/build/lib/address.h" @@ -47,7 +47,8 @@ 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() ? " SIMULATED" : "", va, m->ip, + "SEGMENTATION FAULT", + IsGenuineCosmo() || 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), diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 906c53ede..a1bca3a13 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -7258,7 +7258,7 @@ static void GetOpts(int argc, char *argv[]) { int opt; bool storeasset = false; // only generate ecp cert under blinkenlights (rsa is slow) - norsagen = IsGenuineCosmo(); + norsagen = IsGenuineCosmo() || IsGenuineBlink(); while ((opt = getopt(argc, argv, GETOPTS)) != -1) { switch (opt) { CASE('S', ++sandboxed);