mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Add x86_64-linux-gnu emulator
I wanted a tiny scriptable meltdown proof way to run userspace programs and visualize how program execution impacts memory. It helps to explain how things like Actually Portable Executable works. It can show you how the GCC generated code is going about manipulating matrices and more. I didn't feel fully comfortable with Qemu and Bochs because I'm not smart enough to understand them. I wanted something like gVisor but with much stronger levels of assurances. I wanted a single binary that'll run, on all major operating systems with an embedded GPL barrier ZIP filesystem that is tiny enough to transpile to JavaScript and run in browsers too. https://justine.storage.googleapis.com/emulator625.mp4
This commit is contained in:
parent
467504308a
commit
f4f4caab0e
1052 changed files with 65667 additions and 7825 deletions
|
@ -30,10 +30,14 @@
|
|||
static textwindows noinline int sched_setaffinity$nt(int pid,
|
||||
uint64_t bitsetsize,
|
||||
const void *bitset) {
|
||||
int rc;
|
||||
uintptr_t mask;
|
||||
int64_t handle;
|
||||
typeof(SetThreadAffinityMask) *SetAffinityMask = SetThreadAffinityMask;
|
||||
uintptr_t mask = 0;
|
||||
mask = 0;
|
||||
memcpy(&mask, bitset, min(bitsetsize, sizeof(uintptr_t)));
|
||||
int64_t handle = 0;
|
||||
handle = 0;
|
||||
if (!pid) pid = GetCurrentThreadId();
|
||||
if (0 < pid && pid <= UINT32_MAX) {
|
||||
if (pid == GetCurrentProcessId()) {
|
||||
pid = GetCurrentProcess();
|
||||
|
@ -50,7 +54,7 @@ static textwindows noinline int sched_setaffinity$nt(int pid,
|
|||
}
|
||||
}
|
||||
}
|
||||
int rc = SetAffinityMask(handle ? handle : pid, mask) ? 0 : winerr();
|
||||
rc = SetAffinityMask(handle ? handle : pid, mask) ? 0 : winerr();
|
||||
if (handle) CloseHandle(handle);
|
||||
return rc;
|
||||
}
|
||||
|
@ -58,7 +62,7 @@ static textwindows noinline int sched_setaffinity$nt(int pid,
|
|||
/**
|
||||
* Asks kernel to only schedule process on particular CPUs.
|
||||
*
|
||||
* @param pid is the process or thread id
|
||||
* @param pid is the process or thread id (or 0 for caller)
|
||||
* @param bitsetsize is byte length of bitset
|
||||
* @param bitset can be manipulated using bt(), bts(), etc.
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue