mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 15:28:30 +00:00
Make improvements
- Invent openatemp() API - Invent O_UNLINK open flag - Introduce getenv_secure() API - Remove `git pull` from cosmocc - Fix utimes() when path is NULL - Fix mktemp() to never return NULL - Fix utimensat() UTIME_OMIT on XNU - Improve utimensat() code for RHEL5 - Turn `argv[0]` C:/ to /C/ on Windows - Introduce tmpnam() and tmpnam_r() APIs - Fix more const issues with internal APIs - Permit utimes() on WIN32 in O_RDONLY mode - Fix fdopendir() to check fd is a directory - Fix recent crash regression in landlock make - Fix futimens(AT_FDCWD, NULL) to return EBADF - Use workaround so `make -j` doesn't fork bomb - Rename dontdiscard to __wur (just like glibc) - Fix st_size for WIN32 symlinks containing UTF-8 - Introduce stdio ext APIs needed by GNU coreutils - Fix lstat() on WIN32 for symlinks to directories - Move some constants from normalize.inc to limits.h - Fix segv with memchr() and memcmp() overlapping page - Implement POSIX fflush() behavior for reader streams - Implement AT_SYMLINK_NOFOLLOW for utimensat() on WIN32 - Don't change read-only status of existing files on WIN32 - Correctly handle `0x[^[:xdigit:]]` case in strtol() functions
This commit is contained in:
parent
8596e83cce
commit
f531acc8f9
297 changed files with 1920 additions and 1681 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/libgen.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/ftw.h"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ struct ElfWriter {
|
|||
struct Interner *shstrtab;
|
||||
};
|
||||
|
||||
struct ElfWriter *elfwriter_open(const char *, int) dontdiscard;
|
||||
struct ElfWriter *elfwriter_open(const char *, int) __wur;
|
||||
void elfwriter_cargoculting(struct ElfWriter *);
|
||||
void elfwriter_close(struct ElfWriter *);
|
||||
void elfwriter_align(struct ElfWriter *, size_t, size_t);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/fmt/libgen.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/ftw.h"
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/promises.internal.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
|
|
@ -196,7 +196,7 @@ void GetOpts(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
dontdiscard char *DescribeAddress(struct sockaddr_in *addr) {
|
||||
__wur char *DescribeAddress(struct sockaddr_in *addr) {
|
||||
char ip4buf[16];
|
||||
return xasprintf("%s:%hu",
|
||||
inet_ntop(addr->sin_family, &addr->sin_addr.s_addr, ip4buf,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/ftw.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/bsd.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -35,7 +35,7 @@ char *format(char *buf, const char *fmt, ...) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
dontdiscard char *tabpad(const char *s, unsigned width) {
|
||||
char *tabpad(const char *s, unsigned width) {
|
||||
char *p;
|
||||
size_t i, l, need;
|
||||
l = strlen(s);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_ASMCODEGEN_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_ASMCODEGEN_H_
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
@ -19,7 +20,7 @@ extern char b1[BUFSIZ];
|
|||
extern char b2[BUFSIZ];
|
||||
|
||||
char *format(char *buf, const char *fmt, ...);
|
||||
char *tabpad(const char *s, unsigned width) dontdiscard;
|
||||
char *tabpad(const char *s, unsigned width) __wur;
|
||||
void show(const char *directive, const char *value, const char *comment);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "tool/decode/lib/bitabuilder.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* @param id is the flags
|
||||
* @return NUL-terminated string that needs free()
|
||||
*/
|
||||
dontdiscard char *RecreateFlags(const struct IdName *names, unsigned long id) {
|
||||
char *RecreateFlags(const struct IdName *names, unsigned long id) {
|
||||
bool first;
|
||||
size_t bufi, bufn;
|
||||
char *bufp, extrabuf[20];
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
char *RecreateFlags(const struct IdName *, unsigned long) dontdiscard;
|
||||
char *RecreateFlags(const struct IdName *, unsigned long) __wur;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -48,12 +48,12 @@
|
|||
* @fileoverview Zip File Disassembler.
|
||||
*/
|
||||
|
||||
dontdiscard char *FormatDosDate(uint16_t dosdate) {
|
||||
static __wur char *FormatDosDate(uint16_t dosdate) {
|
||||
return xasprintf("%04u-%02u-%02u", ((dosdate >> 9) & 0b1111111) + 1980,
|
||||
(dosdate >> 5) & 0b1111, dosdate & 0b11111);
|
||||
}
|
||||
|
||||
dontdiscard char *FormatDosTime(uint16_t dostime) {
|
||||
static __wur char *FormatDosTime(uint16_t dostime) {
|
||||
return xasprintf("%02u:%02u:%02u", (dostime >> 11) & 0b11111,
|
||||
(dostime >> 5) & 0b111111, (dostime << 1) & 0b111110);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ Keywords={
|
|||
"warnifused",
|
||||
"attributeallocsize",
|
||||
"attributeallocalign",
|
||||
"dontdiscard",
|
||||
"__wur",
|
||||
"nointerpose",
|
||||
"returnsnonnull",
|
||||
"strftimeesque",
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
"warnifused"
|
||||
"attributeallocsize"
|
||||
"attributeallocalign"
|
||||
"dontdiscard"
|
||||
"__wur"
|
||||
"nointerpose"
|
||||
"returnsnonnull"
|
||||
"strftimeesque"
|
||||
|
|
|
@ -342,7 +342,7 @@ cosmo_kws = frozenset([
|
|||
"memcpyesque",
|
||||
"nocallback",
|
||||
"nodebuginfo",
|
||||
"dontdiscard",
|
||||
"__wur",
|
||||
"dontinline",
|
||||
"dontinstrument",
|
||||
"nointerpose",
|
||||
|
@ -401,7 +401,7 @@ cosmo_kws = frozenset([
|
|||
"memcpyesque",
|
||||
"nocallback",
|
||||
"nodebuginfo",
|
||||
"dontdiscard",
|
||||
"__wur",
|
||||
"dontinline",
|
||||
"noinstrument",
|
||||
"nointerpose",
|
||||
|
|
120
tool/viz/bf.c
120
tool/viz/bf.c
|
@ -1,120 +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 2021 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/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tab.internal.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
|
||||
/**
|
||||
* @fileoverview BingFold - A Hexdump Tool
|
||||
*/
|
||||
|
||||
#define W 64
|
||||
#define C 253
|
||||
|
||||
static unsigned long roundup2pow(unsigned long x) {
|
||||
return x > 1 ? 2ul << _bsrl(x - 1) : x ? 1 : 0;
|
||||
}
|
||||
|
||||
void bf(int fd) {
|
||||
ssize_t rc;
|
||||
uint64_t w;
|
||||
struct stat st;
|
||||
size_t i, n, o;
|
||||
int c, fg, fg2, bits;
|
||||
char ibuf[W], obuf[12 + 1 + W * 6 + 1 + W * (2 + 11) + 11 + 1];
|
||||
o = 0;
|
||||
if (fstat(fd, &st) != -1 && S_ISREG(st.st_mode) && st.st_size) {
|
||||
bits = _bsr(roundup2pow(st.st_size));
|
||||
bits = ROUNDUP(bits, 4);
|
||||
} else {
|
||||
bits = 48;
|
||||
}
|
||||
do {
|
||||
if ((rc = read(fd, ibuf, W)) == -1) exit(2);
|
||||
if (rc) {
|
||||
n = 0;
|
||||
n += uint64toarray_fixed16(o, obuf + n, bits);
|
||||
o += rc;
|
||||
obuf[n++] = ' ';
|
||||
for (i = 0; i < rc; ++i) {
|
||||
c = ibuf[i] & 0xff;
|
||||
w = tpenc(kCp437[c]);
|
||||
do {
|
||||
obuf[n++] = w;
|
||||
} while ((w >>= 8));
|
||||
}
|
||||
for (i = 0; i < W - rc + 1; ++i) {
|
||||
obuf[n++] = ' ';
|
||||
}
|
||||
for (fg = -1, i = 0; i < rc; ++i) {
|
||||
c = ibuf[i] & 0xff;
|
||||
if (c < 32) {
|
||||
fg2 = 237 + c * ((C - 237) / 32.);
|
||||
} else if (c >= 232) {
|
||||
fg2 = C + (c - 232) * ((255 - C) / (256. - 232));
|
||||
} else {
|
||||
fg2 = C;
|
||||
}
|
||||
if (fg2 != fg) {
|
||||
fg = fg2;
|
||||
obuf[n++] = 033;
|
||||
obuf[n++] = '[';
|
||||
obuf[n++] = '3';
|
||||
obuf[n++] = '8';
|
||||
obuf[n++] = ';';
|
||||
obuf[n++] = '5';
|
||||
obuf[n++] = ';';
|
||||
n = FormatInt64(obuf + n, fg) - (obuf + n);
|
||||
obuf[n++] = 'm';
|
||||
}
|
||||
obuf[n++] = "0123456789abcdef"[c >> 4];
|
||||
obuf[n++] = "0123456789abcdef"[c & 15];
|
||||
/* obuf[n++] = ' '; */
|
||||
}
|
||||
obuf[n++] = 033;
|
||||
obuf[n++] = '[';
|
||||
obuf[n++] = '0';
|
||||
obuf[n++] = 'm';
|
||||
obuf[n++] = '\n';
|
||||
write(1, obuf, n);
|
||||
}
|
||||
} while (rc == W);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, fd;
|
||||
if (argc > 1) {
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (i > 1) write(1, "\n", 1);
|
||||
if ((fd = open(argv[i], O_RDONLY)) == -1) exit(1);
|
||||
bf(fd);
|
||||
}
|
||||
} else {
|
||||
bf(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
106
tool/viz/comma.c
106
tool/viz/comma.c
|
@ -1,106 +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/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "third_party/getopt/getopt.internal.h"
|
||||
|
||||
#define USAGE \
|
||||
" [FLAGS] [PATH|FLEXDEC...] [<<<FLEXDEC...\\n...]\n\
|
||||
Turns numbers into decimal with commas.\n\
|
||||
\n\
|
||||
Values are tokenized by spaces. Anything that isn't an integer is\n\
|
||||
passed through. We parse integers the same way the C compiler does\n\
|
||||
so 0x,0b,0,etc. prefixes are fine. Unicode spacing characters are\n\
|
||||
supported.\n\
|
||||
\n\
|
||||
Flags:\n\
|
||||
-o PATH output path\n\
|
||||
-F STR\n\
|
||||
-T STR sets field tokenization charset [default is whitespace]\n\
|
||||
-w FLEXDEC\n\
|
||||
-n FLEXDEC set fixed number of columns [default is variable, based\n\
|
||||
on line breaks]\n\
|
||||
-?\n\
|
||||
-h shows this information\n\
|
||||
\n"
|
||||
|
||||
static size_t linecap_;
|
||||
static FILE *in_, *out_;
|
||||
static const char16_t *fieldtoks_;
|
||||
static char *inpath_, *outpath_, *line_;
|
||||
|
||||
void PrintUsage(int rc, FILE *f) {
|
||||
fputs("Usage: ", f);
|
||||
fputs(program_invocation_name, f);
|
||||
fputs(USAGE, f);
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
void GetOpts(int *argc, char *argv[]) {
|
||||
int opt;
|
||||
outpath_ = "-";
|
||||
fieldtoks_ = u" \t\v\n\r\f ";
|
||||
while ((opt = getopt(*argc, argv, "?ho:F:T:w:n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
outpath_ = optarg;
|
||||
break;
|
||||
case 'F':
|
||||
case 'T':
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
PrintUsage(EXIT_SUCCESS, stdout);
|
||||
default:
|
||||
PrintUsage(EX_USAGE, stderr);
|
||||
}
|
||||
}
|
||||
if (optind == *argc) {
|
||||
argv[(*argc)++] = "-";
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessFile(void) {
|
||||
while ((getline(&line_, &linecap_, in_)) != -1) {
|
||||
// TODO(jart)
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
size_t i;
|
||||
GetOpts(&argc, argv);
|
||||
CHECK_NOTNULL((out_ = fopen(outpath_, "w")));
|
||||
for (i = optind; i < argc; ++i) {
|
||||
CHECK_NOTNULL((in_ = fopen((inpath_ = argv[i]), "r")));
|
||||
ProcessFile();
|
||||
CHECK_NE(-1, fclose(in_));
|
||||
in_ = 0;
|
||||
}
|
||||
CHECK_NE(-1, fclose(out_));
|
||||
out_ = 0;
|
||||
free(line_);
|
||||
return 0;
|
||||
}
|
|
@ -1,42 +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.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
void double2int(const char *s) {
|
||||
double b64;
|
||||
uint64_t u64;
|
||||
b64 = strtod(s, NULL);
|
||||
memcpy(&u64, &b64, 8);
|
||||
printf("0x%016lx\n", u64);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
double2int(argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,28 +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 2022 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/calls/struct/termios.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct termios t;
|
||||
if (tcgetattr(0, &t) == -1) return 1;
|
||||
t.c_lflag ^= ECHOCTL;
|
||||
if (tcsetattr(0, TCSANOW, &t) == -1) return 2;
|
||||
}
|
|
@ -42,7 +42,7 @@ int end = 0x03134A /* 0x10FFFD */;
|
|||
int verbose;
|
||||
|
||||
struct winsize ws = {24, 80};
|
||||
signed char kThePerfectKernel[8] = {-1, -3, 3, 17, 17, 3, -3, -1};
|
||||
signed char kThePerfectKernel[8] = {-1, -1, 3, 15, 15, 3, -1, -1};
|
||||
|
||||
void PrintBar(unsigned char *p, size_t n) {
|
||||
size_t i, j;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/intrin/xchg.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/intrin/hilbert.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue