Commit Graph

135 Commits

Author SHA1 Message Date
9367253b4d Add more libm unit tests and fixes
See #61
2021-03-02 13:57:23 -08:00
32e289b1d8 Add error and gamma functions
Fixes #99
2021-03-02 11:58:00 -08:00
d53a344e18 Remove getc() optimization
This has been reported as causing issues in #61 although it isn't clear
why that's happening. Having a function boundary is bullet proof.
2021-03-02 07:34:38 -08:00
3e19b96ab8 Add more POSIX function stubs
Cosmopolitan currently doesn't support threads and it doesn't do
anything fancy in longjmp/setjmp so this change was simple to do

- localeconv
- _setjmp (same as setjmp)
- _longjmp (same as longjmp)
- strcoll (same as strcmp)
- flockfile (does nothing)
- funlockfile (does nothing)
- ftrylockfile (does nothing)

See #61
2021-03-02 03:27:55 -08:00
1831e3ccf7 Bring life.com executable size back down to 12kb 2021-03-02 01:13:32 -08:00
4651962070 Limit frame size restriction to internal repo
Fixes #91
2021-03-02 01:05:37 -08:00
2596a59374 Use noasan attribute on XNU signal trampoline
The ucontext_t data structure XNU passes us doesn't appear to be part of
known memory. So we can't use ASAN during the trampoline, which converts
it to a Linux ucontext_t data structure. Please note that this change
doesn't impact the signal handler itself, only the trampoline.
2021-03-01 22:02:27 -08:00
f4298f10c2 Generate ZIP files the same way as Windows 2021-03-01 06:24:11 -08:00
d932948fb4 Remove more nonstandard stuff from cosmopolitan.h
Fixes #61
2021-03-01 00:18:23 -08:00
5e069a64d4 Improve limits.h
Fixes #84
See also #61
2021-02-28 20:59:19 -08:00
839e2f4cfb Add hyperbolic math functions
See #61
2021-02-28 01:27:50 -08:00
c42dbe0e9e Issue new Blinkenlights release 2021-02-27 22:35:50 -08:00
94afa982c3 Fix zip executables on MacOS
Here's why we got those `Killed: 11` failures on MacOS after modifying
the contentns of the redbean.com executable. If you were inserting a
small file, such as a HelloWorld.html file, then InfoZIP might have
decreased the size of the executable to less than what the Mach-O
section had been expecting.

That's because when zipobj.com put things like time zone data in the
executable, it aligned each zip file entry on a 64-byte boundary, simply
for the sake of readability in binary dumps. But when InfoZIP edited the
file it would rewrite every entry using ZIP's usual 2-byte alignment.
Thus causing shrinkage.

The solution was to reconfigure the linker script so that zip file bits
that get put into the executable at link-time, such as timezone data,
aren't officially part of the executable image, i.e. we don't want the
operating system to load that part.

The original decision to put the linked zip files into the .data section
was mostly made so that when the executable was run in its .com.dbg form
it would still have the zip entries be accessible, even though there was
tons of GNU debug data following the central directory. We're not going
to be able to do that. The .com executable should be the canonical
executable. We have really good tools for automatically attaching and
configuring GDB correctly with debug symbols even when the .com is run.
We'll have to rely on those in cases where zip embedding is used.

See #53
See #54
See #68
2021-02-27 18:16:59 -08:00
cc56038b05 Fix memzoom on Windows
Right now we can't call poll() on file and fifos on Windows. So we work
around that by simply blocking on keyboard input. This is OK because on
Windows we can't use /proc/*/mem for realtime monitoring, so there's no
reason not to block.

See #65
2021-02-27 15:01:00 -08:00
da199b7a45 Further refine printf long double change (#66) 2021-02-27 13:30:17 -08:00
5d334b9ce0 Support %lf and %lF in format string
Per C99 this should resolve to double.
2021-02-27 13:14:09 -08:00
35c7edac49 Restore Windows command prompt mode on exit
Fixes #60
2021-02-27 12:53:51 -08:00
218ef49147 Fix redbean zip central directory lookup
This regression snuck in at some point. It resulted in the program
sometimes failing to load when the zip content was changed.
2021-02-27 12:08:28 -08:00
19d0c15e03 Perform some code cleanup 2021-02-27 10:33:32 -08:00
40291c9db3 Improve signal handling and math
- Polyfill ucontext_t on FreeBSD/OpenBSD/NetBSD
- Add tests confirming signals can edit CPU state
- Work towards supporting ZIP filesystem on bare metal
- Add more tinymath unit tests for POSIX conformance
- Add X87 and SSE status flags to crash report
- Fix some bugs in blinkenlights
- Fix llvm build breakage
2021-02-25 18:33:33 -08:00
cdc54ea1fd Use unsigned leb128 for magnums 2021-02-24 04:00:38 -08:00
edd9297eba Support malloc() on bare metal
Your Actually Portable Executables now contains a simple virtual memory
that works similarly to the Linux Kernel in the sense that it maps your
physical memory to negative addresses. This is needed to support mmap()
and malloc(). This functionality has zero code size impact. For example
the MODE=tiny LIFE.COM executable is still only 12KB in size.

The APE bootloader code has also been simplified to improve readibility
and further elevate the elegance by which we're able to support so many
platforms thereby enhancing verifiability so that we may engender trust
in this bootloading process.
2021-02-24 00:53:24 -08:00
ac3b1dfb21 Parse EFI command line arguments (#12) 2021-02-21 23:33:44 -08:00
537c21338b Add UEFI support
This is mutually exclusive with Windows support. Documentation for how
to use it has been written in libc/runtime/efimain.c
2021-02-21 21:33:04 -08:00
c6c9b5dfde Further refine hypot implementation
Thanks go to Fabian Giesen on Twitter for code review and advice.
2021-02-21 12:53:01 -08:00
4a5698b5c9 Implement better hypot function 2021-02-21 11:06:18 -08:00
7a393c06fe Add IP address conversion helpers
Fixes #47
2021-02-20 22:53:22 -08:00
e85aeda4ba Fix some more build issues (#43)
We're now scrubbing environment variables in compile.com since gnu make
was not behaving as expected. It also appears there was a regression in
recent revisions that caused ASAN to be turned off for most binaries in
dbg mode, which has now been fixed. Cosmopolitan is fully ASAN hardened
down to the lowest level libraries and it doesn't need any interceptors
2021-02-20 12:39:39 -08:00
3e1fd1d962 Add tool for parsing strace output 2021-02-20 10:45:55 -08:00
b740cca642 Improve build system
- Reduce full build latency from ~20s to ~18s
- Bring back silent mode if `make V=0` is passed
- Demodernize utimes() polyfill so it works RHEL5
- Delete some old shell scripts that are no longer needed
- Truncate long lines when outputting builds to Emacs buffers
2021-02-19 23:03:34 -08:00
5f1415af3a Add help dialog to Blinkenlights emulator 2021-02-19 17:16:17 -08:00
2c15efc249 Add curl example (#42)
make -j8 o//examples/curl.com
    o//examples/curl.com http://justine.lol/ape.html
2021-02-18 19:20:41 -08:00
667ab245fe Implement setlocale() stub (#43) 2021-02-18 17:06:06 -08:00
bfa8581537 Trim down executable sizes 2021-02-11 08:37:18 -08:00
e75ffde09e Get codebase completely working with LLVM
You can now build Cosmopolitan with Clang:

    make -j8 MODE=llvm
    o/llvm/examples/hello.com

The assembler and linker code is now friendly to LLVM too.
So it's not needed to configure Clang to use binutils under
the hood. If you love LLVM then you can now use pure LLVM.
2021-02-09 02:57:32 -08:00
0e36cb3ac4 Improve dead code elimination 2021-02-08 04:04:42 -08:00
2f3bd90216 Apply some touchups 2021-02-07 07:02:46 -08:00
9f149e1de3 Elevate .text.syscall to .privileged
It turns out adding OpenBSD msyscall() origin verification broke the
--ftrace flag. The executable needs to issue raw syscalls while it's
rewriting itself. So they need to be in the same section, and that's
just plain simpler too.
2021-02-06 04:49:22 -08:00
d7733579d3 Fix Clang support
The amalgamated release is now confirmed to be working with Clang,
including its integrated assembler.

Fixes #41
2021-02-06 00:29:09 -08:00
e06c90fafc Cleanup socket code 2021-02-05 23:58:50 -08:00
a91ba89d85 Fix sigsuspend() and sigprocmask() on OpenBSD
Test reliability is now iron clad.
2021-02-05 12:19:43 -08:00
b2cd58a322 Get all tests passing on NetBSD 2021-02-05 09:49:28 -08:00
23ae9dfceb Add NetBSD support 2021-02-05 06:19:45 -08:00
2fdc19e7a7 Write more memory mapping tests
Microsoft claims to support COW but it's probably not true.
2021-02-04 18:24:33 -08:00
74d48f7cb6 Definen LLP64 data model for code completion
This change should not be interpreted as an intent to support MSVC which
appears to live on in VSCode IntelliSense for what's dead will never die
2021-02-04 16:56:43 -08:00
3384a5a48c Apply touchups to last PR
Compilers like GCC require comments on lines like `#endif rdmsr`. Since
the rdmsr macro was only being used in arch_prctl(), I've localized the
macro, and I'm considering deleting arch_prctl() too, since there isn't
any way to have mem segments unfortunately across operating systems ;_;
The remaining changed lines are due to clang-format which runs on auto.
2021-02-04 16:41:34 -08:00
dbd7edba10 sync and try changes 2021-02-04 08:33:22 -05:00
c93a4661a3 Add Cosmopolitan Honeybadger to README.md 2021-02-04 03:31:03 -08:00
d934f38c99 Polyfill auxiliary values on XNU 2021-02-03 20:37:52 -08:00
a37960a3af Remove dollars from system call support symbols 2021-02-03 19:35:29 -08:00