mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
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
This commit is contained in:
parent
c20dad3534
commit
45b72485ad
1032 changed files with 6083 additions and 2348 deletions
|
@ -15,7 +15,6 @@
|
|||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/hefty/spawn.h"
|
||||
#include "libc/calls/struct/itimerval.h"
|
||||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/errno.h"
|
||||
|
@ -148,7 +147,6 @@ struct ZipGames {
|
|||
static int frame_;
|
||||
static int drain_;
|
||||
static int playfd_;
|
||||
static int devnull_;
|
||||
static int playpid_;
|
||||
static bool exited_;
|
||||
static bool timeout_;
|
||||
|
@ -308,21 +306,6 @@ void GetTermSize(void) {
|
|||
WriteStringNow("\e[0m\e[H\e[J");
|
||||
}
|
||||
|
||||
bool TrySpeaker(const char* prog, char* const* args) {
|
||||
int rc;
|
||||
int fds[3];
|
||||
fds[0] = -1;
|
||||
fds[1] = devnull_;
|
||||
fds[2] = devnull_;
|
||||
if ((rc = spawnve(0, fds, prog, args, environ)) != -1) {
|
||||
playpid_ = rc;
|
||||
playfd_ = fds[0];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void IoInit(void) {
|
||||
GetTermSize();
|
||||
xsigaction(SIGINT, (void*)OnCtrlC, 0, 0, NULL);
|
||||
|
@ -1700,6 +1683,8 @@ char* GetLine(void) {
|
|||
|
||||
int PlayGame(const char* romfile, const char* opt_tasfile) {
|
||||
FILE* fp;
|
||||
int devnull;
|
||||
int pipefds[2];
|
||||
inputfn_ = opt_tasfile;
|
||||
|
||||
if (!(fp = fopen(romfile, "rb"))) {
|
||||
|
@ -1716,13 +1701,23 @@ int PlayGame(const char* romfile, const char* opt_tasfile) {
|
|||
|
||||
// open speaker
|
||||
// todo: this needs plenty of work
|
||||
devnull_ = open("/dev/null", O_WRONLY);
|
||||
if ((ffplay_ = commandvenv("FFPLAY", "ffplay"))) {
|
||||
const char* args[] = {
|
||||
"ffplay", "-nodisp", "-loglevel", "quiet", "-fflags", "nobuffer", "-ac",
|
||||
"1", "-ar", "1789773", "-f", "s16le", "pipe:", NULL,
|
||||
};
|
||||
TrySpeaker(ffplay_, (char* const*)args);
|
||||
devnull = open("/dev/null", O_WRONLY | O_CLOEXEC);
|
||||
pipe2(pipefds, O_CLOEXEC);
|
||||
if (!(playpid_ = vfork())) {
|
||||
const char* const args[] = {
|
||||
"ffplay", "-nodisp", "-loglevel", "quiet", "-fflags",
|
||||
"nobuffer", "-ac", "1", "-ar", "1789773",
|
||||
"-f", "s16le", "pipe:", NULL,
|
||||
};
|
||||
dup2(pipefds[0], 0);
|
||||
dup2(devnull, 1);
|
||||
dup2(devnull, 2);
|
||||
execv(ffplay_, (char* const*)args);
|
||||
abort();
|
||||
}
|
||||
close(pipefds[0]);
|
||||
playfd_ = pipefds[1];
|
||||
} else {
|
||||
fputs("\nWARNING\n\
|
||||
\n\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue