This change includes many bug fixes, for the NT polyfills, strings,
memory, boot, and math libraries which were discovered by adding more
tools for recreational programming, such as PC emulation. Lemon has also
been vendored because it works so well at parsing languages.
- Emulator can now test the αcτµαlly pδrταblε εxεcµταblε bootloader
- Whipped up a webserver named redbean. It services 150k requests per
second on a single core. Bundling assets inside zip enables extremely
fast serving for two reasons. The first is that zip central directory
lookups go faster than stat() system calls. The second is that both
zip and gzip content-encoding use DEFLATE, therefore, compressed
responses can be served via the sendfile() system call which does an
in-kernel copy directly from the zip executable structure. Also note
that red bean zip executables can be deployed easily to all platforms,
since these native executables work on Linux, Mac, BSD, and Windows.
- Address sanitizer now works very well
This is a recently introduced Linux Kernel feature that gives people
like Debian package mantainers the power to arbitrarily redefine how
executables are interpreted by the kernel. If your system gets tuned
this way and you're not able to disable it, then you need to restore
default behavior for the APE MZqFpD prefix as follows:
sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"
This prefix will cover all .com executables built with this tooling.
Please don't run the above command unless you're certain you need it.
See #2 for additional context.
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
Video game emulators seem to convert colors for modern displays poorly.
Check out https://youtu.be/Eds63YbGhDQ?t=481 where we notice in the CRT
displays Super Mario Bros with a blue sky, whereas the PC shows purple.
It's likely b/c NTSC used Illuminant C whereas sRGB uses Illuminant D65.
See the improvement: https://justine.storage.googleapis.com/nesemu3.png
Now you can play video games in the terminal as they looked in the 80's.
This change also reduces CPU usage to a third.
Cosmopolitan makes it easy to build and maintain programming languages,
since it abstracts system call #ifdef toil, so you can focus on vision.
Here's an example of a language that isn't turing complete, weighing in
at <1,000 lines of modern C, intended to help with testing libc / libm:
.1 .2 + .3 - abs epsilon < assert
pi sqrt pi sqrt * pi - abs epsilon < assert
-.5 rint dup 0 = assert signbit assert
-.5 nearbyint dup 0 = assert signbit assert
-.5 ceil dup 0 = assert signbit assert
-.5 trunc dup 0 = assert signbit assert
-.5 round -1 = assert
-.5 floor -1 = assert
0 signbit ! assert
CALCULATOR.COM pays homage to CALC.EXE recently removed from Windows 10.
Microsoft should bundle this app instead. It too is roughly 100kb, works
just fine w/ command prompt, and portable since it runs on Mac/Linux/BSD
too while bundling even more features than the calculator on Google.com.
It should be possible to run CALCULATOR.COM on Android and iOS too, just
in case anyone needs a backend pipe driven framework, for graphical user
interfaces of calculators. Sadly we haven't tried it since we don't know
how to run software on telephones so the system call support is a priori
One of the benefits of implementing system call support from scratch is
that we're able to have embedded zip filesystem support which trickles
into libraries such as stdio, without unportable symbolic interposition.
It's also be great if we could say open("gs://bucket/object", O_RDONLY)
for seamless GCS, similar to Java NIO, but abstracted by the C library.
The binary system interfaces designed at Bell Labs were what helped our
friends like Linus Torvalds become successful. It's why Torvalds always
respected syscall abi and made every effort to not break the userspace.
Sadly OpenBSD developer Theo de Raadt thinks respecting Bell interfaces
is a risk for security and conjured up the Return Oriented Programming
bogeyman to justify his policies, per https://lwn.net/Articles/806776/
See libc/nexgen32e/gc.S where we use ROP concepts for garbage collection
in C due to our belief that powerful programming techniques can be good.
See https://opensource.googleblog.com/2017/03/operation-rosehub.html for
an example of something similar to rop but potentially more of a concern