Commit graph

1175 commits

Author SHA1 Message Date
Gautham
c32e2d4486
Set stackaddr if mmap is called in pthread_create (#606) 2022-09-08 21:07:53 -07:00
Paul Kulchenko
5140897c27
Update redbean to include params in slash redirect (#604) 2022-09-08 19:14:54 -07:00
Justine Tunney
9f963dc597
Clean up some of the threading code 2022-09-08 12:31:56 -07:00
Justine Tunney
0547eabcd6
Polyfill IPv6 on non-Linux 2022-09-08 06:06:22 -07:00
Justine Tunney
b73e35c6fa
Improve open source compatibility
This change tunes the default stack size for the outside world to 8mb
while at the same time, reducing Cosmopolitan's default stack size to
64kb. You can override the stack size using STATIC_STACK_SIZE(). Your
build scripts should point to o//ape/public/ape.lds

This change also fixes the definition of SOMAXCONN and removes AF_RDS
since it's not polyfilled and Python 3.11 complained.
2022-09-08 03:19:35 -07:00
Justine Tunney
0e2b1bfeed
Make garbage collection thread safe
- You can now use _gc(malloc()) in multithreaded programs
- This change fixes a bug where fork() on NT disabled TLS
- Fixed TLS code morphing on XNU/NT, for R8-R15 registers
2022-09-08 02:33:01 -07:00
Justine Tunney
571c2c3c69
Fix race condition in makedirs() 2022-09-07 23:12:44 -07:00
Gavin Hayes
b7c07d548c
Add FP_ILOGB constants (#599) 2022-09-07 21:37:53 -07:00
Justine Tunney
6c323383e5
Make some fixups to POSIX threads 2022-09-07 21:13:50 -07:00
Justine Tunney
de511bc71a
Add phtread_setname_np() and pthread_getname_np() 2022-09-07 19:04:05 -07:00
Justine Tunney
114176c304
Add more foo64() functions for Rust 2022-09-07 05:48:57 -07:00
Gavin Hayes
a849a63771
Implement sigpending for sysv and nt (#597) 2022-09-07 05:38:12 -07:00
Justine Tunney
4339d9f15e
Add pthread attributes and other libc functions 2022-09-07 05:28:32 -07:00
Justine Tunney
d5c9308a43
Don't sandbox documentation generator 2022-09-06 20:45:21 -07:00
Justine Tunney
8bd9ad8342
Simplify redbean serialization code 2022-09-06 20:07:29 -07:00
tkchia
3fdb1c14f1
Add VGA support on bare metal (#588)
If your main module has this declaration:

    STATIC_YOINK("vga_console");

Then a VGA driver will be linked into your executable which
displays your stdio characters on the PC display, whereas
before we could only use the serial port. Your display is an
ANSI terminal and it's still a work in progress.
2022-09-06 18:41:08 -07:00
Gavin Hayes
598640864a
Fix inability to add some signals to mask on NT (#596) 2022-09-06 18:35:26 -07:00
Justine Tunney
d861d2787b
Import OpenBSD sorting algorithms
OpenBSD's qsort() function is more secure than the ones used by
FreeBSD, NetBSD and MacOS. The best part is it goes faster too!
This change also imports the OpenBSD mergesort() and heapsort()
2022-09-06 17:52:26 -07:00
Justine Tunney
dbf12c30b0
Make more compatibility improvements 2022-09-06 12:36:34 -07:00
Justine Tunney
11ec60d5fc
Use a better sorting algorithm
This change changes qsort() to use the same code as NetBSD and MacOS
because it goes 6x faster than Musl's SmoothSort function. Smoothsort
can still be used if you need something that's provenly linearithmic.
This change also improves GNU Make performance on whole by 7 percent!

netbsd nearly   l:    70,196c    22,673ns   m:    68,428c    22,102ns
musl nearly     l:    53,844c    17,391ns   m:    58,726c    18,968ns
unixv6 nearly   l:    65,885c    21,280ns   m:    63,082c    20,375ns

netbsd reverse  l:   120,290c    38,853ns   m:   122,619c    39,605ns
musl reverse    l:   801,826c   258,985ns   m:   794,689c   256,680ns
unixv6 reverse  l:    58,977c    19,049ns   m:    59,764c    19,303ns

netbsd random   l:   146,745c    47,398ns   m:   145,782c    47,087ns
musl random     l:   855,804c   276,420ns   m:   850,912c   274,840ns
unixv6 random   l:   214,325c    69,226ns   m:   213,906c    69,090ns

netbsd 2n       l:    77,299c    24,967ns   m:    76,773c    24,797ns
musl 2n         l:   818,012c   264,213ns   m:   818,282c   264,301ns
unixv6 2n       l: 3,967,009c 1,281,322ns   m: 3,941,792c 1,273,177ns

https://justine.lol/dox/sort.pdf
2022-09-06 11:06:10 -07:00
Justine Tunney
55c6297e13
Make more compatibility improvements 2022-09-06 07:04:13 -07:00
Justine Tunney
12d9e1e128
Improve quality of our ANSI C clock() function
It now works most excellently across all supported operating
sytsems (earlier it didn't work on NT and XNU). Demo code is
available in examples/clock.c and this change also adds some
of the newer ANSI C time functions like timespec_get(), plus
timespec_getres() which hasn't even come out yet as it's C23
2022-09-05 23:03:49 -07:00
Justine Tunney
7ff0ea8c13
Make pthread mutexes more scalable
pthread_mutex_lock() now uses a better algorithm which goes much faster
in multithreaded environments that have lock contention. This comes at
the cost of adding some fixed-cost overhead to mutex invocations. That
doesn't matter for Cosmopolitan because our core libraries all encode
locking operations as NOP instructions when in single-threaded mode.
Overhead only applies starting the moment you first call clone().
2022-09-05 15:57:51 -07:00
Gavin Hayes
7de2f229a7
Discard ignored signals on New Technology (#592) 2022-09-05 09:17:56 -07:00
Gautham
4b4ea046c4
Ensure libcxx.a is built when providing folder (#591) 2022-09-05 09:17:16 -07:00
Justine Tunney
44c315d789
Disable pthread broadcast test temporarily
This fixes the GitHub Actions build.
2022-09-05 09:06:16 -07:00
Justine Tunney
8cd4248f7f
Make SIG_DFL / SIG_IGN C++ compatible 2022-09-05 08:49:26 -07:00
Justine Tunney
d721ff8938
Remove testonly keyword 2022-09-05 08:41:43 -07:00
Justine Tunney
9be364d40a
Implement POSIX threads API 2022-09-05 08:27:15 -07:00
Justine Tunney
af24f21556
Unsandbox assembly generation 2022-09-05 08:27:15 -07:00
Paul Kulchenko
b0287ef34c
Tune a log message priority in redbean (#589) 2022-09-04 07:43:06 -07:00
Justine Tunney
6a04bc3318
Release redbean 2.0.18 2022-09-04 06:57:59 -07:00
Justine Tunney
8dd4ec68d0
Add more missing C / C++ headers 2022-09-04 04:53:52 -07:00
Justine Tunney
b9dc74b672
Do some work on unbuffer command 2022-09-04 02:25:34 -07:00
Justine Tunney
e1590e1e38
Remove accidental comment 2022-09-04 00:41:09 -07:00
tkchia
8569704c1d
Stop APE bare metal loader from reading beyond program image end (#574)
This allows e.g. `qemu-system-x86_64 -s o/examples/hello.com
-serial stdio` to work without having to add extra padding to
the end of the `hello.com` "disk image".

(The sector count computation is divided among two instructions
in the assembly code.  This is done on purpose, to prevent an
ASCII 0x27 (single quote) byte from appearing in the bare
metal loader code, which will break the shell script loader.
There is probably a better way.)

Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
2022-09-04 00:19:08 -07:00
Gavin Hayes
9c017c98d3
Add sysconf to unistd.h (#575) 2022-09-04 00:10:17 -07:00
Gavin Hayes
74879bf067
Add pollfd to poll.h (#576) 2022-09-04 00:09:50 -07:00
Paul Kulchenko
8a3d8497e3
Update README to add a note about binfmt-related errors (#587) 2022-09-04 00:09:24 -07:00
Justine Tunney
3c00d8c29c Fix TLS linker warning
Fixes #565
Closes #577
Co-authored-by: tkchia <tkchia-cosmo@gmx.com>
2022-09-04 00:05:30 -07:00
Gavin Hayes
1ef955c33b
Improve zipos path handling (#579)
This change adds opendir, readdir, and stat support for the /zip/ root,
as well as directories not explicitly encoded in the zip file.
2022-09-03 22:50:23 -07:00
Gavin Hayes
494d74271b
Fix inet_ntop(AF_INET6) buffer length (#582) 2022-09-03 22:46:45 -07:00
Ilya Brin
12212894eb
Highlight GDB syntax in README.md (#560) 2022-09-03 22:19:55 -07:00
Justine Tunney
a4522fba8d Fix build 2022-09-03 21:10:37 -07:00
Justine Tunney
0c70e8963d Add notpossible keyword
This is the same as `unreachable` except it always traps violations,
even if we're not running in MODE=dbg. This is useful for impossible
conditions relating to system calls. It avoids terrifying bugs where
control falls through to an unrelated function.
2022-09-03 20:35:31 -07:00
Justine Tunney
b66bd064d8 Improve quality of uname/gethostname/getdomainname 2022-09-03 20:20:40 -07:00
Justine Tunney
c5c4dfcd21 Improve quality of raise(), abort(), and tkill()
This change fixes a nasty bug where SIG_IGN and SIG_DFL weren't working
as advertised on BSDs. This change also fixes the tkill() definition on
MacOS so it maps to __pthread_kill().
2022-09-03 20:17:54 -07:00
Justine Tunney
c5659b93f8 Create unit test framework for subprocesses 2022-09-03 18:02:01 -07:00
Gavin Hayes
263711965f
Change sigaction_f to match sysv signature (#585) 2022-09-02 05:08:35 -07:00
Paul Kulchenko
33b5b5b312
Remove path escaping from LaunchBrowser (#584)
This is so you can have `?query=args`.
2022-08-31 22:14:06 -07:00