mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +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
|
@ -30,7 +30,6 @@
|
|||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/mem/copyfd.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
|
@ -322,8 +321,8 @@ int main(int argc, char *argv[]) {
|
|||
goto fail;
|
||||
}
|
||||
outsize += (remain = sizes.p[i]);
|
||||
if (_copyfd(fd, outfd, remain) == -1) {
|
||||
reason = "copy_file_range failed";
|
||||
if (copyfd(fd, outfd, remain) == -1) {
|
||||
reason = "copy failed";
|
||||
goto fail;
|
||||
}
|
||||
close(fd);
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/copyfd.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/kcpuids.h"
|
||||
|
@ -769,7 +768,7 @@ bool MovePreservingDestinationInode(const char *from, const char *to) {
|
|||
res = false;
|
||||
break;
|
||||
}
|
||||
res = _copyfd(fdin, fdout, -1) != -1;
|
||||
res = copyfd(fdin, fdout, -1) != -1;
|
||||
break;
|
||||
} else {
|
||||
res = false;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/mem/copyfd.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
@ -176,7 +175,7 @@ bool MovePreservingDestinationInode(const char *from, const char *to) {
|
|||
close(fdin);
|
||||
return false;
|
||||
}
|
||||
res = _copyfd(fdin, fdout, -1) != -1;
|
||||
res = copyfd(fdin, fdout, -1) != -1;
|
||||
close(fdin);
|
||||
close(fdout);
|
||||
return res;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/mem/copyfd.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/copyfd.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/kcpuids.h"
|
||||
|
@ -523,7 +522,7 @@ int Extract(const char *from, const char *to, int mode) {
|
|||
close(fdin);
|
||||
return -1;
|
||||
}
|
||||
if (_copyfd(fdin, fdout, -1) == -1) {
|
||||
if (copyfd(fdin, fdout, -1) == -1) {
|
||||
close(fdout);
|
||||
close(fdin);
|
||||
return -1;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/arch.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
|
|
@ -154,6 +154,10 @@ for x; do
|
|||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
if [ x"$MODE" = x"nox87" ]; then
|
||||
CCFLAGS="$CCFLAGS -mlong-double-64"
|
||||
fi
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"${MODE#tiny}" != x"${MODE}" ]; then
|
||||
# support --ftrace unless optimizing for size
|
||||
CXXFLAGS="$CXXFLAGS -fpatchable-function-entry=18,16"
|
||||
|
|
|
@ -154,6 +154,10 @@ for x; do
|
|||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
if [ x"$MODE" = x"nox87" ]; then
|
||||
CCFLAGS="$CCFLAGS -mlong-double-64"
|
||||
fi
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"${MODE#tiny}" != x"${MODE}" ]; then
|
||||
# support --ftrace unless optimizing for size
|
||||
CFLAGS="$CFLAGS -fpatchable-function-entry=18,16"
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
|
||||
float b32;
|
||||
double b64;
|
||||
long double b80;
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
int128_t x;
|
||||
|
||||
void int2float(const char *s) {
|
||||
x = strtoi128(s, NULL, 0);
|
||||
if ((0 <= x && x <= UINT32_MAX) && !_startswith(s, "-") &&
|
||||
(!_endswith(s, "l") && !_endswith(s, "L"))) {
|
||||
u32 = x;
|
||||
memcpy(&b32, &u32, 4);
|
||||
s = _gc(xdtoa(b32));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
s = _gc(xasprintf("%sf", s));
|
||||
puts(s);
|
||||
} else if ((0 <= x && x <= UINT64_MAX) && !_startswith(s, "-")) {
|
||||
u64 = x;
|
||||
memcpy(&b64, &u64, 8);
|
||||
s = _gc(xdtoa(b64));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
puts(s);
|
||||
} else if ((INT32_MIN <= x && x <= 0) &&
|
||||
(!_endswith(s, "l") && !_endswith(s, "L"))) {
|
||||
u32 = ABS(x);
|
||||
memcpy(&b32, &u32, 4);
|
||||
b32 = -b32;
|
||||
s = _gc(xdtoa(b32));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
s = _gc(xasprintf("%sf", s));
|
||||
puts(s);
|
||||
} else if (INT64_MIN <= x && x <= 0) {
|
||||
u64 = ABS(x);
|
||||
memcpy(&b64, &u64, 8);
|
||||
b64 = -b64;
|
||||
s = _gc(xdtoa(b64));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
puts(s);
|
||||
} else {
|
||||
memcpy(&b80, &x, 16);
|
||||
s = _gc(xdtoa(b80));
|
||||
if (!strchr(s, '.')) s = _gc(xasprintf("%s.", s));
|
||||
s = _gc(xasprintf("%sL", s));
|
||||
puts(s);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
int2float(argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -21,7 +21,6 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/copyfd.internal.h"
|
||||
#include "libc/nt/dll.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/enum/startf.h"
|
||||
|
@ -58,7 +57,7 @@ int NextBestThing(void) {
|
|||
int64_t fd = open("/proc/self/maps", O_RDONLY);
|
||||
posix_fadvise(fd, 0, 0, MADV_SEQUENTIAL);
|
||||
ssize_t wrote;
|
||||
while ((wrote = _copyfd(fd, 1, -1)) != -1) {
|
||||
while ((wrote = copyfd(fd, 1, -1)) != -1) {
|
||||
if (wrote == 0) break;
|
||||
}
|
||||
close(fd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue