mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-01 03:53:33 +00:00
f4f4caab0e
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
48 lines
3.1 KiB
C++
48 lines
3.1 KiB
C++
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
|
│vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│
|
|
╚══════════════════════════════════════════════════════════════════════════════╝
|
|
│ @author (c) Marco Paland (info@paland.com) │
|
|
│ 2014-2019, PALANDesign Hannover, Germany │
|
|
│ │
|
|
│ @license The MIT License (MIT) │
|
|
│ │
|
|
│ Permission is hereby granted, free of charge, to any person obtaining a copy │
|
|
│ of this software and associated documentation files (the "Software"), to deal│
|
|
│ in the Software without restriction, including without limitation the rights │
|
|
│ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell │
|
|
│ copies of the Software, and to permit persons to whom the Software is │
|
|
│ furnished to do so, subject to the following conditions: │
|
|
│ │
|
|
│ The above copyright notice and this permission notice shall be included in │
|
|
│ all copies or substantial portions of the Software. │
|
|
│ │
|
|
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR │
|
|
│ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, │
|
|
│ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE │
|
|
│ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER │
|
|
│ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,│
|
|
│ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN │
|
|
│ THE SOFTWARE. │
|
|
└─────────────────────────────────────────────────────────────────────────────*/
|
|
|
|
asm(".ident\t\"\\n\\n\
|
|
Paland Printf (MIT License)\\n\
|
|
Copyright 2014-2019 Marco Paland\\n\
|
|
PALANDesign Hannover, Germany\\n\
|
|
info@paland.com\"");
|
|
|
|
#include "libc/mem/mem.h"
|
|
#include "libc/str/internal.h"
|
|
#include "libc/sysv/errfuns.h"
|
|
|
|
#define FLAGS_ZEROPAD (1U << 0U)
|
|
#define FLAGS_LEFT (1U << 1U)
|
|
#define FLAGS_PLUS (1U << 2U)
|
|
#define FLAGS_SPACE (1U << 3U)
|
|
#define FLAGS_HASH (1U << 4U)
|
|
#define FLAGS_PRECISION (1U << 5U)
|
|
#define FLAGS_ISSIGNED (1U << 6U)
|
|
#define FLAGS_NOQUOTE (1U << 7U)
|
|
#define FLAGS_QUOTE FLAGS_SPACE
|
|
#define FLAGS_GROUPING FLAGS_NOQUOTE
|
|
#define FLAGS_REPR FLAGS_PLUS
|