216 Commits

Author SHA1 Message Date
6cd1037692 Get VSCode working with Linux and WSL (#116) 2021-03-09 10:12:39 -08:00
3f35b37b68 Remove nonstandard defines from limits.h (#115) 2021-03-08 17:34:44 -08:00
67c27d9e6e Add Hello World example for LUA C API (#97) 2021-03-08 14:15:59 -08:00
2a3037d4e8 Delete Duktape (#97) 2021-03-08 13:17:52 -08:00
0a61fe4ea0 Add smoke test for timezone loading (#114) 2021-03-08 11:46:04 -08:00
33e8fc8687 Expose public garbage collector API for C language
You can now do epic things like this:

    puts(_gc(xasprintf("%d", 123)));

The _gc() API is shorthand for _defer() which works like Go's keyword:

    const char *s = xasprintf("%d", 123);
    _defer(free, s);
    puts(s);

Be sure to always use -fno-omit-frame-pointer which makes code fast too.

Enjoy! See also #114
2021-03-08 10:59:34 -08:00
0ad609268f Improve system call polyfills
- Polyfill open() w/ O_CLOEXEC on RHEL5
- Remove old workaround from rmdir() on the New Technology
- preadv() and pwritev() are now smarter about demodernization
- preadv() and pwritev() are now available on the New Technology
2021-03-08 10:07:02 -08:00
816b0e1851 Improve tmpfile api (#114) 2021-03-07 21:08:27 -08:00
2bd1e72d5a Remove garbage collector macro from header (#114)
We can put this back the moment someone requests it. Pain-free garbage
collection for the C language is pretty cool. All it does is overwrite
the return address with a trampoline that calls free(). It's not clear
what it should be named if it's made a public API.
2021-03-07 20:23:29 -08:00
5ce83b08c8 Add posix_spawn (#114) 2021-03-07 20:14:07 -08:00
a8945714e8 Make gdtoa less tunable (#104)
The -fno-math-errno flag shouldn't impact libraries since it's mostly
intended for permitting the compiler to generate sqrt() instructions.
2021-03-07 16:41:59 -08:00
8a6ac6dd63 Set errno when out of range in strtoimax (#111) 2021-03-07 14:38:56 -08:00
f5da4efcaf Set errno in strtol family of functions (#110) 2021-03-07 14:18:08 -08:00
aad841610e Fix freopen so it resets stream buffer (#61) 2021-03-07 12:12:02 -08:00
67b9675c81 Make tgmath.h available (#109) 2021-03-06 22:40:18 -08:00
813e11b90b Fix int parsing with base 2 and 16 (#107) 2021-03-06 21:12:32 -08:00
fb7b7c6e21 Fix isystem headers including wrong files (#108) 2021-03-06 21:06:29 -08:00
d769df3482 Fix issues with stdio needed for Lua
See #61
2021-03-06 19:04:26 -08:00
c3ed8d6c7f Make %p consistent with glibc and musl
See #61
2021-03-06 14:36:44 -08:00
937d921018 Add tests for the greatest of all libm functions 2021-03-06 12:59:35 -08:00
bfef17eb6d Add more math fixes 2021-03-06 11:44:40 -08:00
11ec99931b Add Musl multibyte functions
These are standard functions that are needed to help support the Skull
language. Note that normally this codebase uses libc/str/thompike.h

See #105
2021-03-06 09:53:16 -08:00
cfd453d125 Add more real formatting tests
See #61
2021-03-06 08:45:44 -08:00
6fa049c9c7 Add macro for static_assert (#106) 2021-03-05 20:32:25 -08:00
3364fc5b03 Add modf(), modff(), and modfl()
See #104
2021-03-05 10:47:14 -08:00
f064183646 Support proper %g, %f, and %a float formatting
See #61
See #104
2021-03-05 10:31:16 -08:00
e26bdbec52 Make examples folder somewhat more focused 2021-03-05 06:09:12 -08:00
5141d00992 Perform some minor code cleanup 2021-03-04 13:22:32 -08:00
43b2475aaa Handle more pow cases (#61) 2021-03-04 06:14:07 -08:00
2134ffe005 Add features needed by Janet language
See #97
See https://github.com/ahgamut/janet/tree/f838e36#compiling-janet-on-cosmopolitan
2021-03-03 13:26:46 -08:00
8af91bcbe7 Make pow() conform to standard definition 2021-03-03 09:21:27 -08:00
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