Commit Graph

128 Commits

Author SHA1 Message Date
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
888cfa74d7 Merge pull request #40 from nicholatian/jart
Add VS Code IntelliSense support scaffolding
2021-02-04 15:45:07 -08:00
46d8fd8c3f remove semicolons from #defines 2021-02-04 08:38:21 -05: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
a8d7195777 Make Cosmopolitan ANSI C89 compatible
You can now use cosmopolitan.h with an ANSI C89 compiler like MSVC. The
Cosmopolitan codebase itself won't support being compiled that way. But
you can build objects that link against Cosmopolitan using any compiler
and you can furthermore use tools like IntelliSense that can't even GNU

See also #40
2021-02-03 17:48:59 -08:00
46085797b6 Make ANSI mode closer to being ANSI 2021-02-03 17:14:17 -08:00
28135b7a20 Add q keyboard shortcut to printvideo.com (#37) 2021-02-03 15:53:33 -08:00
ec9bfd8c56 finish intellisense support and sync with upstream 2021-02-03 13:50:08 -05:00
4e56d89dcd Eliminate some flakes
- Get ASAN working on Windows.

- Deleting directories and then recreating them with the same name in a
  short period of time appears to be a no-no on Windows.

- There's no reason to call FlushFileBuffers on close() for pipes, and
  it's harmful since it might block indefinitely for no good reason.
2021-02-03 06:25:27 -08:00
27c899af56 Make mmap() work better
- Mapping file offsets now works on Windows
- Mapping stack memory now works on OpenBSD
2021-02-03 00:10:12 -08:00
23a14b537c Delete LIBC_CALLS_HEFTY
- fork() no longer requires malloc()
- readdir() moved to LIBC_STDIO
- Custom APIs moved to LIBC_X
2021-02-02 22:17:53 -08:00
c843243322 Implement more security stuff
- Support deterministic stacks on OpenBSD
- Support OpenBSD system call origin verification
- Fix overrun by one in chibicc string token allocator
- Get all chibicc tests passing under Address Sanitizer
2021-02-02 20:21:06 -08:00
7642710155 wip on intellisense (again) 2021-02-02 11:14:45 -05:00
9841e2186a wip vscode intellisense support 2021-02-02 07:29:00 -05:00
cbfd4ccd1e Make more functions friendly to Address Sanitizer 2021-02-02 03:45:31 -08:00
3ab76b2312 Fix cosmopolitan.h for C++
We now have an integration test that runs the amalgamated sources
through a C++ compiler, to prevent the recurrence of such issues.

Fixes #38
Thanks @gbbnfhb for the report!
2021-02-01 04:04:44 -08:00
1ff9ab95ac Make C memory safe like Rust
This change enables Address Sanitizer systemically w/ `make MODE=dbg`.
Our version of Rust's `unsafe` keyword is named `noasan` which is used
for two functions that do aligned memory chunking, like `strcpy.c` and
we need to fix the tiny DEFLATE code, but that's it everything else is
fabulous you can have all the fischer price security blankets you need

Best of all is we're now able to use the ASAN data in Blinkenlights to
colorize the memory dumps. See the screenshot below of a test program:

  https://justine.lol/blinkenlights/asan.png

Which is operating on float arrays stored on the stack, with red areas
indicating poisoned memory, and the green areas indicate valid memory.
2021-02-01 03:58:46 -08:00
fdc3fa9148 Remove sun musl fdlibm math library
The libm code from musl wasn't being used since most of these functions
are implemented using x87 which goes faster than a library intended for
risc machines.
2021-01-31 18:25:16 -08:00
e6481efa80 Use make SILENT=0 by default
Silent build configs are good for the core developers of a project
because they understand the build config, however it's an obstacle
for newcomers who'll be better served by seeing the build commands
2021-01-31 11:30:42 -08:00
39bb91fc44 Improve fcntl(F_{SET,GET}FL) implementation (#32) 2021-01-30 13:10:32 -08:00
4072e40bb8 Cosmopolitan 0.1.2 2021-01-30 10:13:13 -08:00
393a642c22 Increase Windows stack size (#32)
We're now using the same values CMD.EXE uses.
2021-01-30 10:08:28 -08:00
95173645a1 Implement getcwd() for XNU 2021-01-30 08:54:12 -08:00
417797d218 Support dirfd relative iops on Windows
We always favor calling functions like openat(), fstatat(), etc. because
Linux, XNU, FreeBSD, and OpenBSD all elected to support them, while some
systems like Android love them so much, that they stopped supporting the
old interfaces.

This change ensures that when dirfd is actually a dirfd and not AT_FDCWD
we'll do the right thing on Windows NT. We use an API that's been around
since Vista to accomplish that.

This change also adds exponential backoff to chdir() on Windows since it
seems almost as flaky on Windows 7 as the rmdir() function.
2021-01-30 01:49:43 -08:00
b8d26e2418 Fix fork() on Windows after chdir() 2021-01-29 23:19:29 -08:00
21e1023d28 Reduce memory requirements for execve() 2021-01-29 22:00:10 -08:00
eaca5b3e81 Add exponential backoff to rmdir() on Windows 2021-01-29 21:48:40 -08:00
bf8b1623c8 Normalize mkdir() error codes 2021-01-29 21:21:06 -08:00
6070319f84 Create FUNDING.yml 2021-01-29 14:56:22 -08:00
36b4bf74f7 Cosmopolitan 0.1.1
This fixes a few bugs that slipped through the 0.1 release process.
2021-01-29 01:30:51 -08:00
caee314a50 Make PATH search do the right thing w/ empty path 2021-01-29 01:27:09 -08:00
a5f3456333 Refix readdir() on OpenBSD
We now have better tests which are catching these kinds of bugs.
2021-01-29 01:25:14 -08:00
f7c7b949fd Explore comfort level with posix_spawn
Justine says nay for the time being. Only XNU implements this. It's not
clear what ABI XNU is using but it's obviously not the one in the POSIX
documentation link below. Since all platforms implement vfork, it might
be better to empirically gauge the intersection of consensus which will
have better performance than this interface.

https://pubs.opengroup.org/onlinepubs/009696699/xrat/xsh_chap03.html
2021-01-29 01:24:54 -08:00
b2260c2278 Remove printfs accidentally in release :( 2021-01-29 00:07:53 -08:00
7ce8ccb94f Cosmopolitan 0.1
All 196 tests passing on the following systems is confirmed:

  - Alpine Linux 5.4.43
  - Debian Linux 10 Buster 4.19.0
  - Red Hat Enterprise Linux 7 3.10.0
  - Red Hat Enterprise Linux 5 2.6.18
  - XNU 19.6.0
  - Windows 7
  - Windows 10
  - FreeBSD 12.1
  - OpenBSD 6.8

Proof:

  https://justine.lol/cosmopolitan/cosmopolitan-0.1.png

My name is Justine Tunney and I approve this release.
2021-01-28 16:19:10 -08:00
971bc8147f Check for EINTR in poll$nt()
This is a bandaid that lets CTRL-C work in daemons until a better
solution for signals on Windows can be implemented.
2021-01-28 15:53:06 -08:00
d8fffd2123 Change stack address on Windows
I rebooted Windows 7 and noticed that KERNEL32.DLL got relocated.
Microsoft needs to change and embrace the dream that was MULTICS.
Until then we'll need a better way to work around their dominion.
2021-01-28 13:42:53 -08:00
b4dffa4726 Add more win32 definitions to cosmopolitan.a 2021-01-27 22:18:23 -08:00
efc66f8525 Fix our remarkable 184kb x86_64 emulator
Here's how to build it from source and try it out!

    m=tiny
    make -j18 MODE=$m o/$m/tool/build/tinyemu.com
    make -j18 MODE=$m o/$m/tool/viz/deathstar.com
    o/$m/tool/build/tinyemu.com o/$m/tool/viz/deathstar.com
2021-01-27 20:02:23 -08:00
d7ac16a9ed Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
de703b182c Fix amalgamated release objects for older distros
We now pass -Wa,--nocompress-debug-sections to GCC so it won't use ELF
compression, since that causes "unable to initialize decompress status
for section .debug_aranges" when linked with past releases of binutils

Please note: this issue only impacts users who download cosmopolitan.a
from the website. Building from source isn't impacted, since we vendor
GCC 9.2.0 and Binutils 2.32 static binaries in the third_party folder.

Thanks @vshymanskyy for reporting this!
See #32
2021-01-27 16:21:01 -08:00
45b72485ad Fix XNU / FreeBSD / OpenBSD / RHEL5 / NT bugs
For the first time ever, all tests in this codebase now pass, when
run automatically on macos, freebsd, openbsd, rhel5, rhel7, alpine
and windows via the network using the runit and runitd build tools

- Fix vfork exec path etc.
- Add XNU opendir() support
- Add OpenBSD opendir() support
- Add Linux history to syscalls.sh
- Use copy_file_range on FreeBSD 13+
- Fix system calls with 7+ arguments
- Fix Windows with greater than 16 FDs
- Fix RUNIT.COM and RUNITD.COM flakiness
- Fix OpenBSD munmap() when files are mapped
- Fix long double so it's actually long on Windows
- Fix OpenBSD truncate() and ftruncate() thunk typo
- Let Windows fcntl() be used on socket files descriptors
- Fix Windows fstat() which had an accidental printf statement
- Fix RHEL5 CLOCK_MONOTONIC by not aliasing to CLOCK_MONOTONIC_RAW

This is wonderful. I never could have dreamed it would be possible
to get it working so well on so many platforms with tiny binaries.

Fixes #31
Fixes #25
Fixes #14
2021-01-25 18:31:17 -08:00
c20dad3534 Fix another bootloader glitch (#20)
Thanks again to @Theldus for reporting this
2021-01-17 17:55:42 -08:00
23b1b462c9 Update website documentation html 2021-01-17 17:55:12 -08:00
78add3cb17 Fix AR.COM on RHEL7 (#24)
Doing this required improving the copyfd() polyfill needed by
copy_file_range() so it'll work harder to avoid short writes.
2021-01-17 10:28:52 -08:00