mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-06 00:46:23 +00:00
Introduce CPUID detection for Blink
This commit is contained in:
parent
4922bc4890
commit
3da887c58f
12 changed files with 19 additions and 14 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
4
third_party/nsync/futex.c
vendored
4
third_party/nsync/futex.c
vendored
|
@ -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;
|
||||
|
|
|
@ -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 "";
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue