Commit graph

801 commits

Author SHA1 Message Date
Justine Tunney
4b8874ceb9
Make some simple fixes 2023-02-03 02:09:15 -08:00
Justine Tunney
cf19e3e46a
Fix SO_LINGER on Apple 2023-02-02 20:05:37 -08:00
Justine Tunney
1429a7b3ef
Fix bug in ASAN reporting 2023-02-02 02:28:58 -08:00
Justine Tunney
7486a2cd51
Perform minor cleanups 2023-02-02 02:28:58 -08:00
Gavin Hayes
fd0da9c0df
Implement zipos mmap (#725) 2023-02-02 02:28:50 -08:00
Justine Tunney
1473eafd1a
Fix the build and introduce some APIs
The tcgetwinsize() and tcsetwinsize() APIs are now available. The
printargs.com example also now displays the baud rate.
2023-01-20 09:25:45 -08:00
Justine Tunney
cac86197cb
Add fix for Blink detection 2023-01-19 09:12:49 -08:00
Justine Tunney
006c44ff5d
Update tests and CPU detection for Blink 2023-01-18 00:56:09 -08:00
Justine Tunney
be3e109309
Fix build break 2023-01-08 15:35:08 -08:00
Justine Tunney
2bad436abf
Return error on fopen(NULL)
https://sqlite.org/forum/forumpost/d1c96a9032e564f8
2023-01-08 15:17:44 -08:00
Justine Tunney
416e173448
Improve the cosmocc toolchain
These changes were necessary to help Blink become buildable using
Cosmopolitan Libc.
2023-01-05 12:20:52 -08:00
Justine Tunney
eb69a42863
Fix --strace crashing on MacOS and Windows 2023-01-04 06:46:37 -08:00
Justine Tunney
6dcdf91458
Add a turfwar hilbert decoration 2023-01-03 18:28:35 -08:00
Justine Tunney
a4b6803556
Fix recursive locks when tid is huge
It turns out Linux may assign thread ids that are much larger than
previously thought. We now have fewer bits of depth so we can have
bigger tids.
2023-01-03 05:01:00 -08:00
Justine Tunney
10d1c6da18
Support argv[0] munging on Windows 2023-01-03 03:22:40 -08:00
ahgamut
5ed84e04f8 remove libc/sock/if.h
libc/sock/if.h is removed because:

- it contained only IFNAMSIZ, which was also defined in
  libc/sock/struct/ifreq.h
- it was not included in any file EXCEPT libc/isystem/net/if.h, which
  also included the libc/sock/struct/ifreq.h

hence we remove this file, and move the IFNAMSIZ definition to
libc/sock/struct/ifreq.h which is included in isystem.
2023-01-01 16:51:00 -08:00
ahgamut
25fa6acc4d check existence of IFNAMSIZ
IFNAMSIZ is defined in:

- libc/sock/if.h
- libc/sock/struct/ifreq.h

we add a check in the latter to avoid a complaint when using the
amalgamated header.
2023-01-01 16:51:00 -08:00
tkchia
73507d5f4e
Add some definitions for Linux frame buffer/console ioctl APIs (#712)
Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
2023-01-01 16:28:03 -08:00
Justine Tunney
2e5181666f
Fix the build 2022-12-21 23:06:55 -08:00
Ronsor
f6b3019796
Make curl example into a complete tool (#706)
You can now handily use `curl` with popen()/system() by
placing `STATIC_YOINK("_curl")` in your main source file.
2022-12-21 16:12:02 -08:00
Justine Tunney
dd04aeba1c
Increase stack size to 128k and guard size to 16k
This improves our compatibility with Apple M1.
2022-12-18 22:58:29 -08:00
Justine Tunney
6d39c6f646
Have redbean avoid gzip when emulated without jit 2022-12-18 02:22:58 -08:00
Justine Tunney
5a3c646307
Fix sysinfo() totalram on XNU
HW_MEMSIZE is the 64-bit version of HW_PHYSMEM, which is inaccurate on
systems having more than 4gb of RAM.
2022-12-18 02:22:46 -08:00
tkchia
0da47c51de
[metal] Allow programs larger than 440 KiB to run in bare metal mode (#685)
* [metal] Copy program pages to extended memory at startup
* [metal] Reclaim base memory pages for later app use
* [metal] Load program pages beyond 1st 440 KiB to extended memory

o//examples/hellolua.com now runs correctly under QEMU (in
legacy BIOS mode).

* [metal] Place GDT in read/write segment

The CPU absolutely needs to alter the GDT when loading the
task register (via ltr).  To account for this, I move the
GDT into a read/write data section.  There is still a "rump"
read-only GDT in the text section that is used by the real
mode bootloader.

We also delay the loading of the task register (ltr) until
after the IDT and TSS are finally set up.

* [metal] Get examples/vga2.c serial output working for UEFI boot
* [metal] Get examples/vga2.c VGA output working for UEFI boot
* [metal] Allow munmap() to reclaim dynamically allocated pages
* Place TLS sections right after .text, not after embedded zip file

Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
2022-12-17 17:51:20 -08:00
Justine Tunney
120079b0a6
Remove evil constants from cosmopolitan.h
- `I` a.k.a. `_Complex_I` (fixes #705)
- `B0`, `B50`, etc. (fixes #403)
2022-12-17 00:42:45 -08:00
Justine Tunney
3da887c58f
Introduce CPUID detection for Blink 2022-12-17 00:38:07 -08:00
Justine Tunney
ed161b240e
Clean up some code 2022-12-11 14:30:59 -08:00
Justine Tunney
531bfbd61f
Fix DNS resolution w/ commas in Windows Registry 2022-12-11 14:30:59 -08:00
Justine Tunney
d55b019284
Fix the build 2022-11-11 11:13:21 -08:00
Justine Tunney
f2af97711b
Make improvements
- Improve compatibility with Blink virtual machine
- Add non-POSIX APIs for joining threads and signal masks
- Never ever use anything except 32-bit integers for atomics
- Add some `#undef` statements to workaround `ctags` problems
2022-11-10 21:52:47 -08:00
Justine Tunney
cee6871710
Make detached threads work better
This change adds a double linked list of threads, so that pthread_exit()
will know when it should call exit() from an orphaned child. This change
also improves ftrace and strace logging.
2022-11-09 03:58:57 -08:00
Justine Tunney
b74d8c1acd
Remove unnecessary STRACE() statement 2022-11-08 15:33:16 -08:00
Justine Tunney
bf7843833f
Rename hidden keyword to _Hide 2022-11-08 12:55:28 -08:00
Justine Tunney
b407327972
Make fixes and improvements
- clock_nanosleep() is now much faster on OpenBSD and NetBSD
- Thread joining is now much faster on NetBSD
- FreeBSD timestamps are now more accurate
- Thread spawning now goes faster on XNU
- Clean up the clone() code
2022-11-08 10:11:46 -08:00
Justine Tunney
c995838e5c
Make improvements
- Clean up sigaction() code
- Add a port scanner example
- Introduce a ParseCidr() API
- Clean up our futex abstraction code
- Fix a harmless integer overflow in ParseIp()
- Use kernel semaphores on NetBSD to make threads much faster
2022-11-07 02:26:06 -08:00
Justine Tunney
539bddce8c
Fix regression in documentation page 2022-11-06 01:16:29 -07:00
Justine Tunney
002df0f16c
Fix regression in MODE=asan build 2022-11-06 01:05:13 -07:00
tkchia
cb9a0466f1
Work towards zipos / open(argv[0]) on metal (#667) 2022-11-06 00:29:47 -07:00
Justine Tunney
3f0bcdc3ef
Improve cancellations, randomness, and time
- Exhaustively document cancellation points
- Rename SIGCANCEL to SIGTHR just like BSDs
- Further improve POSIX thread cancellations
- Ensure asynchronous cancellations work correctly
- Elevate the quality of getrandom() and getentropy()
- Make futexes cancel correctly on OpenBSD 6.x and 7.x
- Add reboot.com and shutdown.com to examples directory
- Remove underscore prefix from awesome timespec_*() APIs
- Create assertions that help verify our cancellation points
- Remove bad timespec APIs (cmp generalizes eq/ne/gt/gte/lt/lte)
2022-11-05 23:45:32 -07:00
Justine Tunney
0d7c265392
Fix backtraces on cancellation points 2022-11-04 20:22:13 -07:00
Justine Tunney
022536cab6
Make futexes cancellable by pthreads 2022-11-04 18:36:34 -07:00
Justine Tunney
2278327eba
Implement support for POSIX thread cancellations
This change makes some miracle modifications to the System Five system
call support, which lets us have safe, correct, and atomic handling of
thread cancellations. It all turned out to be cheaper than anticipated
because it wasn't necessary to modify the system call veneers. We were
able to encode the cancellability of each system call into the magnums
found in libc/sysv/syscalls.sh. Since cancellations are so waq, we are
also supporting a lovely Musl Libc mask feature for raising ECANCELED.
2022-11-04 01:04:43 -07:00
Justine Tunney
37d40e087f
Ignore SIGSYS on BSD by default 2022-11-03 09:32:12 -07:00
Justine Tunney
179e048bba
Make some small fixes to recent changes 2022-11-03 05:45:33 -07:00
Justine Tunney
89d1e5b8f2
Rearrange code and make a faster sha256sum program 2022-11-02 23:19:16 -07:00
Justine Tunney
6b06a8176d
Fix some glitches in redbean
This change includes a fix to Fetch() where an out of bounds memory read
could happen, when the reverse proxied endpoint omits the content-length
header. This caused a bunch of NUL chars to appear on TurfWar's /statusz
since it wouldn't actually overrun the buffer, and if it did it would've
been caught by MODE=asan builds.
2022-11-02 09:46:34 -07:00
Justine Tunney
14d036b68d
Add WSL to test fleet
All tests pass now under WSL2. They should pass under WSL1 too, but only
WSL2 is integrated into the test fleet right now. This change also fills
in some gaps in the error numbers.

Fixes #665
2022-11-02 06:49:42 -07:00
Justine Tunney
fae0c0286f
Workaround WSL not supporting x87 in ucontext_t 2022-11-02 03:20:39 -07:00
Justine Tunney
d6ff4c754e
Workaround WSL misconfiguring the x87 FPU 2022-11-02 02:17:14 -07:00
Justine Tunney
f44d88707e
Workaround sendfile() bug in WSL 2022-11-02 02:17:03 -07:00