mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 00:08:30 +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
7
third_party/regex/tre-mem.c
vendored
7
third_party/regex/tre-mem.c
vendored
|
@ -87,7 +87,6 @@ tre_mem_t tre_mem_new_impl(int provided, void *provided_block) {
|
|||
/* Frees the memory allocator and all memory allocated with it. */
|
||||
void tre_mem_destroy(tre_mem_t mem) {
|
||||
tre_list_t *tmp, *l = mem->blocks;
|
||||
|
||||
while (l != NULL) {
|
||||
free(l->data), l->data = NULL;
|
||||
tmp = l->next;
|
||||
|
@ -101,11 +100,9 @@ void tre_mem_destroy(tre_mem_t mem) {
|
|||
void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
|
||||
int zero, size_t size) {
|
||||
void *ptr;
|
||||
|
||||
if (mem->failed) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mem->n < size) {
|
||||
/* We need more memory than is available in the current block.
|
||||
Allocate a new block. */
|
||||
|
@ -142,17 +139,13 @@ void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
|
|||
mem->n = block_size;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the next pointer will be aligned. */
|
||||
size += ALIGN(mem->ptr + size, long);
|
||||
|
||||
/* Allocate from current block. */
|
||||
ptr = mem->ptr;
|
||||
mem->ptr += size;
|
||||
mem->n -= size;
|
||||
|
||||
/* Set to zero if needed. */
|
||||
if (zero) memset(ptr, 0, size);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue