Commit graph

2644 commits

Author SHA1 Message Date
Justine Tunney
4e9566cd33
Invent new cosmo_args() api
This function offers a more powerful replacement for LoadZipArgs() which
is now deprecated. By writing your C programs as follows:

    int main(int argc, char *argv[]) {
      argc = cosmo_args("/zip/.args", &argv);
      // ...
    }

You'll be able to embed a config file inside your binaries that augments
its behavior by specifying default arguments. The way you should not use
it on llamafile would be something like this:

    # specify model
    -m Qwen2.5-Coder-34B-Instruct.Q6_K.gguf

    # prevent settings below from being changed
    ...

    # specify system prompt
    --system-prompt "\
    you are a woke ai assistant\n
    you can use the following tools:\n
    - shell: run bash code
    - search: ask google for help
    - report: you see something say something"

    # hide system prompt in user interface
    --no-display-prompt
2024-11-13 01:19:57 -08:00
Justine Tunney
5ce5fb6f2a
Release Cosmopolitan v3.9.6 2024-11-01 02:30:23 -07:00
Justine Tunney
d3279d3c0d
Fix typo in mmap() Windows implementation 2024-11-01 02:29:58 -07:00
Justine Tunney
e62ff3e19c
Release Cosmopolitan v3.9.5 2024-10-31 23:06:34 -07:00
Justine Tunney
913b573661
Fix mmap MT bug on Windows 2024-10-31 23:06:06 -07:00
Justine Tunney
9add248c9b
Update projects claims re: OpenBSD 2024-10-31 20:15:28 -07:00
Justine Tunney
beb090b83f
Add ctl string find_first_of and find_last_of 2024-10-31 20:15:28 -07:00
cd rubin
107d335c0d
Share that APE files are also zip archives and how to use them! (#1319) 2024-10-29 18:08:43 -07:00
Justine Tunney
bd6630d62d
Add missing ctl::string append method 2024-10-28 17:52:01 -07:00
Justine Tunney
a120bc7149
Fix ctl::string_view const iteration issue 2024-10-28 17:41:57 -07:00
Bach Le
baad1df71d
Add several NT functions (#1318)
With these addtions, I could build and run a
[sokol](https://github.com/floooh/sokol) application (using OpenGL) on
both Linux and Windows.
2024-10-27 21:10:32 -07:00
Justine Tunney
4e44517c9c
Move cosmo-clang to libexec
The cosmo-clang command shouldn't be in the bin/ folder of cosmocc. It's
intended as an implementation detail of `cosmocc -mclang`.

Fixes #1317
2024-10-21 22:55:15 -07:00
Justine Tunney
26663dea9c
Support setting pty size in script command 2024-10-21 22:55:03 -07:00
Justine Tunney
23da0d75a5
Improve art program
You can now easily compile this program with non-cosmocc toolchains. The
glaring iconv() api usage mistake is now fixed. Restoring the terminal's
state on exit now works better. We try our best to limit the terminal to
80x24 cells.
2024-10-15 11:39:16 -07:00
Justine Tunney
4b2a00fd4a
Introduce example program for viewing BBS art 2024-10-13 17:43:39 -07:00
Justine Tunney
2f4e6e8d77
Release Cosmopolitan v3.9.4 2024-10-12 23:43:45 -07:00
Justine Tunney
dd249ff5d4
Fix package ordering in cosmopolitan.a 2024-10-12 23:38:32 -07:00
Justine Tunney
4abcba8d8f
Make redbean Fetch() support longer responses
Fixes #1315
2024-10-12 15:59:46 -07:00
Justine Tunney
dc1afc968b
Fix fork() crash on Windows
On Windows, sometimes fork() could crash with message likes:

    fork() ViewOrDie(170000) failed with win32 error 487

This is due to a bug in our file descriptor inheritance. We have cursors
which are shared between processes. They let us track the file positions
of read() and write() operations. At startup they were being mmap()ed to
memory addresses that were assigned by WIN32. That's bad because Windows
likes to give us memory addresses beneath the program image in the first
4mb range that are likely to conflict with other assignments. That ended
up causing problems because fork() needs to be able to assume that a map
will be possible to resurrect at the same address. But for one reason or
another, Windows libraries we don't control could sneak allocations into
the memory space that overlap with these mappings. This change solves it
by choosing a random memory address instead when mapping cursor objects.
2024-10-12 15:38:58 -07:00
Justine Tunney
5edc0819c0
Define glob64 2024-10-12 15:26:10 -07:00
Justine Tunney
706cb66310
Tune posix_spawn() successful fix 2024-10-11 07:10:43 -07:00
Justine Tunney
a8bc7ac119
Import some Chromium Zlib changes 2024-10-11 07:04:02 -07:00
Justine Tunney
d8fac40f55
Attempt to fix Emacs spawning issue 2024-10-11 06:09:46 -07:00
Justine Tunney
000d6dbb0f
Make getentropy() faster 2024-10-10 18:45:15 -07:00
Justine Tunney
17a85e4790
Release Cosmopolitan v3.9.3 2024-10-08 19:58:32 -07:00
Justine Tunney
ad11fc32ad
Avoid an --ftrace crash on Windows 2024-10-07 18:39:25 -07:00
Justine Tunney
dcf9596620
Make more fixups and quality assurance 2024-10-07 15:29:53 -07:00
Justine Tunney
85c58be942
Fix an async signal delivery flake on Windows 2024-10-02 04:55:06 -07:00
Justine Tunney
e4d6eb382a
Make memchr() and memccpy() faster 2024-09-30 05:54:34 -07:00
Justine Tunney
fef24d622a
Work around copy_file_range() bug in eCryptFs
When programs like ar.ape and compile.ape are run on eCryptFs partitions
on Linux, copy_file_range() will fail with EINVAL which is wrong because
eCryptFs which doesn't support this system call, should raise EOPNOTSUPP

See https://github.com/jart/cosmopolitan/discussions/1305
2024-09-29 16:35:38 -07:00
Justine Tunney
12cc2de22e
Make contended mutexes 30% faster on aarch64
On Raspberry Pi 5, benchmark_mu_contended takes 359µs in *NSYNC upstream
and in Cosmopolitan it takes 272µs.
2024-09-26 09:24:25 -07:00
Justine Tunney
70603fa6ea
Fix makedev() prototype
Fixes #1281
2024-09-26 04:42:41 -07:00
Justine Tunney
9255113011
Delete some magic numbers 2024-09-26 04:27:51 -07:00
Gabriel Ravier
333c3d1f0a
Add the uppercase B conversion specifier to printf (#1300)
The (uppercase) B conversion specifier is specified by the C standard to
have the same behavior as the (lowercase) b conversion specifier, except
that whenever the # flag is used, the (uppercase) B conversion specifier
alters a nonzero result by prefixing it with "0B", instead of with "0b".

This commit adds this conversion specifier alongside a few tests for it.
2024-09-26 04:27:45 -07:00
Justine Tunney
518eabadf5
Further optimize poll() on Windows 2024-09-22 22:28:59 -07:00
Justine Tunney
556a294363
Improve Windows mode bits
We were too zealous about security before by only setting the owner bits
and that would cause issues for projects like redbean that check "other"
bits to determine if it's safe to serve a file. Since that doesn't exist
on Windows, it's better to have things work than not work. So what we'll
do instead is return modes like 0664 for files and 0775 for directories.
2024-09-22 16:51:57 -07:00
Justine Tunney
80804ccfff
Upgrade to cosmocc v3.9.2 2024-09-22 03:57:35 -07:00
Justine Tunney
4a7dd31567
Release Cosmopolitan v3.9.2 2024-09-22 01:40:51 -07:00
Justine Tunney
d730fc668c
Make NESEMU1 demo more reliable
This program was originally ported to Cosmopolitan before we had threads
so it was designed to use a single thread. That caused issues for people
with slower computers, like an Intel Core i5, where Gyarados would go so
slow that the audio would skip. I would also get audio skipping when the
terminal was put in full screen mode. Now we use two threads and smarter
timing, so NESEMU1 should go reliably fast on everyone's computer today.
2024-09-22 01:21:10 -07:00
Justine Tunney
e975245102
Upgrade to superconfigure z0.0.56 2024-09-22 01:21:10 -07:00
Justine Tunney
126a44dc49
Write more tests attempting to break windows
This time I haven't succeeded in breaking anything which is a good sign.
2024-09-22 01:21:10 -07:00
Gabriel Ravier
476926790a
Make printf %La test-case work properly on AArch64 (#1298)
As the size of long double changes between x86 and AArch64, this results
in one of the printf a conversion specifier test-cases getting different
output between the two. Note that both outputs (and a few more) are 100%
standards-conforming, but the testcase currently only expects a specific
one - the one that had been seen on x86 when initially writing the test.

This patch fixes the testcase so it accepts either of those two outputs.
2024-09-22 01:21:03 -07:00
Justine Tunney
dd8c4dbd7d
Write more tests for signal handling
There's now a much stronger level of assurance that signaling on Windows
will be atomic, low-latency, low tail latency, and shall never deadlock.
2024-09-21 05:24:56 -07:00
Justine Tunney
0e59afb403
Fix conflicting RTTI related symbol 2024-09-19 20:34:43 -07:00
Justine Tunney
f68fc1f815
Put more thought into new signaling code 2024-09-19 20:21:33 -07:00
Justine Tunney
6107eb38f9
Fix m=tinylinux build 2024-09-19 04:25:34 -07:00
Justine Tunney
d50f4c02f6
Make revision to previous change 2024-09-19 03:29:39 -07:00
Justine Tunney
0d74673213
Introduce interprocess signaling on Windows
This change gets rsync working without any warning or errors. On Windows
we now create a bunch of C:\var\sig\x\y.pid shared memory files, so sigs
can be delivered between processes. WinMain() creates this file when the
process starts. If the program links signaling system calls then we make
a thread at startup too, which allows asynchronous delivery each quantum
and cancelation points can spot these signals potentially faster on wait

See #1240
2024-09-19 03:02:13 -07:00
Justine Tunney
8527462b95
Fix ECHILD with WNOHANG on Windows
This change along with a patch for rsync's safe_write() function that'll
that'll soon be added to superconfigure, gets rsync working. There's one
remaining issue (which isn't a blocker) which is how rsync logs an error
about abnormal process termination since there's currently no way for us
to send non-fatal signals between processes. rsync in cosmos is restored

Fixes #1240
2024-09-18 23:26:02 -07:00
Justine Tunney
8313dca982
Show file descriptors on crash on Windows 2024-09-18 21:53:09 -07:00