mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Make improvements
- More timspec_*() and timeval_*() APIs have been introduced. - The copyfd() function is now simplified thanks to POSIX rules. - More Cosmo-specific APIs have been moved behind the COSMO define. - The setitimer() polyfill for Windows NT is now much higher quality. - Fixed build error for MODE=aarch64 due to -mstringop-strategy=loop. - This change introduces `make MODE=nox87 toolchain` which makes it possible to build programs using your cosmocc toolchain that don't have legacy fpu instructions. This is useful, for example, if you want to have a ~22kb tinier blink virtual machine.
This commit is contained in:
parent
8dc11afcf6
commit
c3440d040c
132 changed files with 539 additions and 587 deletions
|
@ -21,6 +21,8 @@
|
|||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
||||
#define N (PAGESIZE / 2 / sizeof(struct DescribeFlags))
|
||||
|
@ -29,17 +31,42 @@
|
|||
* Describes clock_gettime() clock argument.
|
||||
*/
|
||||
const char *(DescribeOpenFlags)(char buf[128], int x) {
|
||||
char *s;
|
||||
char *p;
|
||||
int i, n;
|
||||
const char *pipe;
|
||||
struct DescribeFlags d[N];
|
||||
if (x == -1) return "-1";
|
||||
// TODO(jart): unify DescribeFlags and MagnumStr data structures
|
||||
for (n = 0; kOpenFlags[n].x != MAGNUM_TERMINATOR; ++n) {
|
||||
if (n == N) notpossible;
|
||||
p = buf;
|
||||
switch (x & O_ACCMODE) {
|
||||
case O_RDONLY:
|
||||
p = stpcpy(p, "O_RDONLY");
|
||||
x &= ~O_ACCMODE;
|
||||
pipe = "|";
|
||||
break;
|
||||
case O_WRONLY:
|
||||
p = stpcpy(p, "O_WRONLY");
|
||||
x &= ~O_ACCMODE;
|
||||
pipe = "|";
|
||||
break;
|
||||
case O_RDWR:
|
||||
p = stpcpy(p, "O_RDWR");
|
||||
x &= ~O_ACCMODE;
|
||||
pipe = "|";
|
||||
break;
|
||||
default:
|
||||
pipe = "";
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < n; ++i) {
|
||||
d[i].flag = MAGNUM_NUMBER(kOpenFlags, i);
|
||||
d[i].name = MAGNUM_STRING(kOpenFlags, i);
|
||||
if (x) {
|
||||
p = stpcpy(p, pipe);
|
||||
for (n = 0; kOpenFlags[n].x != MAGNUM_TERMINATOR; ++n) {
|
||||
if (n == N) notpossible;
|
||||
}
|
||||
for (i = 0; i < n; ++i) {
|
||||
d[i].flag = MAGNUM_NUMBER(kOpenFlags, i);
|
||||
d[i].name = MAGNUM_STRING(kOpenFlags, i);
|
||||
}
|
||||
DescribeFlags(p, 128 - (p - buf), d, n, "O_", x);
|
||||
}
|
||||
return DescribeFlags(buf, 128, d, n, "O_", x);
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue