diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0f663b93f..908e74a8a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- mode: ["", tiny, rel, aarch64]
+ mode: ["", tiny, rel]
steps:
- uses: actions/checkout@v3
diff --git a/examples/unbourne.c b/examples/unbourne.c
index ef1f576e5..d1850c14e 100644
--- a/examples/unbourne.c
+++ b/examples/unbourne.c
@@ -1744,14 +1744,14 @@ static char *sstrdup(const char *p) {
return memcpy(stalloc(len), p, len);
}
-int xwrite(int, const void *, uint64_t);
+int __xwrite(int, const void *, uint64_t);
static void flushout(struct output *dest) {
unsigned len;
len = dest->nextc - dest->buf;
if (!len || dest->fd < 0) return;
dest->nextc = dest->buf;
- if ((xwrite(dest->fd, dest->buf, len))) dest->flags |= OUTPUT_ERR;
+ if ((__xwrite(dest->fd, dest->buf, len))) dest->flags |= OUTPUT_ERR;
}
static void flushall(void) {
@@ -1817,7 +1817,7 @@ static void outmem(const char *p, unsigned len, struct output *dest) {
}
nleft = dest->end - dest->nextc;
if (nleft > len) goto buffered;
- if ((xwrite(dest->fd, p, len))) {
+ if ((__xwrite(dest->fd, p, len))) {
dest->flags |= OUTPUT_ERR;
}
}
@@ -9179,7 +9179,7 @@ static int64_t openhere(union node *redir) {
}
len = strlen(p);
if (len <= PIPESIZE) {
- xwrite(pip[1], p, len);
+ __xwrite(pip[1], p, len);
goto out;
}
if (forkshell((struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) {
@@ -9188,7 +9188,7 @@ static int64_t openhere(union node *redir) {
signal(SIGQUIT, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGPIPE, SIG_DFL);
- xwrite(pip[1], p, len);
+ __xwrite(pip[1], p, len);
_exit(0);
}
out:
diff --git a/libc/calls/fadvise.c b/libc/calls/fadvise.c
index 265fa103c..2c89cb1ae 100644
--- a/libc/calls/fadvise.c
+++ b/libc/calls/fadvise.c
@@ -65,3 +65,5 @@ int fadvise(int fd, uint64_t offset, uint64_t len, int advice) {
STRACE("fadvise(%d, %'lu, %'lu, %d) → %d% m", fd, offset, len, advice, rc);
return rc;
}
+
+__strong_reference(fadvise, fadvise64);
diff --git a/libc/calls/fadvise64.S b/libc/calls/fadvise64.S
deleted file mode 100644
index 317fdd306..000000000
--- a/libc/calls/fadvise64.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-fadvise64:
- jmp fadvise
- .endfn fadvise64,globl
diff --git a/libc/calls/fstat.c b/libc/calls/fstat.c
index f5773f2ad..ed36fa6b9 100644
--- a/libc/calls/fstat.c
+++ b/libc/calls/fstat.c
@@ -53,3 +53,5 @@ int fstat(int fd, struct stat *st) {
STRACE("fstat(%d, [%s]) → %d% m", fd, DescribeStat(rc, st), rc);
return rc;
}
+
+__strong_reference(fstat, fstat64);
diff --git a/libc/calls/fstat64.S b/libc/calls/fstat64.S
deleted file mode 100644
index f85a9b6c1..000000000
--- a/libc/calls/fstat64.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-fstat64:
- jmp fstat
- .endfn fstat64,globl
diff --git a/libc/calls/fstatat.c b/libc/calls/fstatat.c
index 848fc8c45..be8cb1f03 100644
--- a/libc/calls/fstatat.c
+++ b/libc/calls/fstatat.c
@@ -75,3 +75,5 @@ int fstatat(int dirfd, const char *path, struct stat *st, int flags) {
DescribeStat(rc, st), __strace_fstatat_flags(alloca(12), flags), rc);
return rc;
}
+
+__strong_reference(fstatat, fstatat64);
diff --git a/libc/calls/fstatat64.S b/libc/calls/fstatat64.S
deleted file mode 100644
index 8b0c3e5f8..000000000
--- a/libc/calls/fstatat64.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
-╞══════════════════════════════════════════════════════════════════════════════╡
-│ This is free and unencumbered software released into the public domain. │
-│ │
-│ Anyone is free to copy, modify, publish, use, compile, sell, or │
-│ distribute this software, either in source code form or as a compiled │
-│ binary, for any purpose, commercial or non-commercial, and by any │
-│ means. │
-│ │
-│ In jurisdictions that recognize copyright laws, the author or authors │
-│ of this software dedicate any and all copyright interest in the │
-│ software to the public domain. We make this dedication for the benefit │
-│ of the public at large and to the detriment of our heirs and │
-│ successors. We intend this dedication to be an overt act of │
-│ relinquishment in perpetuity of all present and future rights to this │
-│ software under copyright law. │
-│ │
-│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
-│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
-│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
-│ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │
-│ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
-│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │
-│ OTHER DEALINGS IN THE SOFTWARE. │
-╚─────────────────────────────────────────────────────────────────────────────*/
-#include "libc/macros.internal.h"
-
-fstatat64:
- jmp fstatat
- .endfn fstatat64,globl
diff --git a/libc/calls/ftruncate.c b/libc/calls/ftruncate.c
index a1aa9e86a..a8cb392fa 100644
--- a/libc/calls/ftruncate.c
+++ b/libc/calls/ftruncate.c
@@ -87,3 +87,5 @@ int ftruncate(int fd, int64_t length) {
STRACE("ftruncate(%d, %'ld) → %d% m", fd, length, rc);
return rc;
}
+
+__strong_reference(ftruncate, ftruncate64);
diff --git a/libc/calls/ftruncate64.S b/libc/calls/ftruncate64.S
deleted file mode 100644
index a4a2a5080..000000000
--- a/libc/calls/ftruncate64.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
-╞══════════════════════════════════════════════════════════════════════════════╡
-│ This is free and unencumbered software released into the public domain. │
-│ │
-│ Anyone is free to copy, modify, publish, use, compile, sell, or │
-│ distribute this software, either in source code form or as a compiled │
-│ binary, for any purpose, commercial or non-commercial, and by any │
-│ means. │
-│ │
-│ In jurisdictions that recognize copyright laws, the author or authors │
-│ of this software dedicate any and all copyright interest in the │
-│ software to the public domain. We make this dedication for the benefit │
-│ of the public at large and to the detriment of our heirs and │
-│ successors. We intend this dedication to be an overt act of │
-│ relinquishment in perpetuity of all present and future rights to this │
-│ software under copyright law. │
-│ │
-│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
-│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
-│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
-│ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │
-│ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
-│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │
-│ OTHER DEALINGS IN THE SOFTWARE. │
-╚─────────────────────────────────────────────────────────────────────────────*/
-#include "libc/macros.internal.h"
-
-ftruncate64:
- jmp ftruncate
- .endfn ftruncate64,globl
diff --git a/libc/calls/lseek.c b/libc/calls/lseek.c
index 19d4fda31..ca6bbffa5 100644
--- a/libc/calls/lseek.c
+++ b/libc/calls/lseek.c
@@ -90,3 +90,5 @@ int64_t lseek(int fd, int64_t offset, int whence) {
rc);
return rc;
}
+
+__strong_reference(lseek, lseek64);
diff --git a/libc/calls/lseek64.S b/libc/calls/lseek64.S
deleted file mode 100644
index e6b61d743..000000000
--- a/libc/calls/lseek64.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-lseek64:
- jmp lseek
- .endfn lseek64,globl
diff --git a/libc/calls/lstat.c b/libc/calls/lstat.c
index cb2aa1a98..6d4ab1163 100644
--- a/libc/calls/lstat.c
+++ b/libc/calls/lstat.c
@@ -26,3 +26,5 @@
int lstat(const char *pathname, struct stat *st) {
return fstatat(AT_FDCWD, pathname, st, AT_SYMLINK_NOFOLLOW);
}
+
+__strong_reference(lstat, lstat64);
diff --git a/libc/calls/lstat64.S b/libc/calls/lstat64.S
deleted file mode 100644
index 7cfe4b329..000000000
--- a/libc/calls/lstat64.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
-╞══════════════════════════════════════════════════════════════════════════════╡
-│ This is free and unencumbered software released into the public domain. │
-│ │
-│ Anyone is free to copy, modify, publish, use, compile, sell, or │
-│ distribute this software, either in source code form or as a compiled │
-│ binary, for any purpose, commercial or non-commercial, and by any │
-│ means. │
-│ │
-│ In jurisdictions that recognize copyright laws, the author or authors │
-│ of this software dedicate any and all copyright interest in the │
-│ software to the public domain. We make this dedication for the benefit │
-│ of the public at large and to the detriment of our heirs and │
-│ successors. We intend this dedication to be an overt act of │
-│ relinquishment in perpetuity of all present and future rights to this │
-│ software under copyright law. │
-│ │
-│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
-│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
-│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
-│ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │
-│ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
-│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │
-│ OTHER DEALINGS IN THE SOFTWARE. │
-╚─────────────────────────────────────────────────────────────────────────────*/
-#include "libc/macros.internal.h"
-
-lstat64:
- jmp lstat
- .endfn lstat64,globl
diff --git a/libc/calls/open.c b/libc/calls/open.c
index 9ac2b3986..98889d3ab 100644
--- a/libc/calls/open.c
+++ b/libc/calls/open.c
@@ -43,3 +43,5 @@ int open(const char *file, int flags, ...) {
va_end(va);
return openat(AT_FDCWD, file, flags, mode);
}
+
+__strong_reference(open, open64);
diff --git a/libc/calls/open64.S b/libc/calls/open64.S
deleted file mode 100644
index f6fe23521..000000000
--- a/libc/calls/open64.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-open64: jmp open
- .endfn open64,globl
diff --git a/libc/calls/pread.c b/libc/calls/pread.c
index 1bdf10459..b114b272e 100644
--- a/libc/calls/pread.c
+++ b/libc/calls/pread.c
@@ -83,3 +83,5 @@ ssize_t pread(int fd, void *buf, size_t size, int64_t offset) {
MAX(0, MIN(40, rc)), buf, rc > 40 ? "..." : "", size, offset, rc);
return rc;
}
+
+__strong_reference(pread, pread64);
diff --git a/libc/calls/pread64.S b/libc/calls/pread64.S
deleted file mode 100644
index 25682b540..000000000
--- a/libc/calls/pread64.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-pread64:
- jmp pread
- .endfn pread64,globl
diff --git a/libc/calls/pwrite.c b/libc/calls/pwrite.c
index 425a2bdb8..022a4b29d 100644
--- a/libc/calls/pwrite.c
+++ b/libc/calls/pwrite.c
@@ -80,3 +80,5 @@ ssize_t pwrite(int fd, const void *buf, size_t size, int64_t offset) {
MAX(0, MIN(40, rc)), buf, rc > 40 ? "..." : "", size, offset, rc);
return rc;
}
+
+__strong_reference(pwrite, pwrite64);
diff --git a/libc/calls/pwrite64.S b/libc/calls/pwrite64.S
deleted file mode 100644
index 389b984e3..000000000
--- a/libc/calls/pwrite64.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-pwrite64:
- jmp pwrite
- .endfn pwrite64,globl
diff --git a/libc/calls/stat.c b/libc/calls/stat.c
index 4827c7039..dcd741ca4 100644
--- a/libc/calls/stat.c
+++ b/libc/calls/stat.c
@@ -38,3 +38,5 @@
int stat(const char *path, struct stat *st) {
return fstatat(AT_FDCWD, path, st, 0);
}
+
+__strong_reference(stat, stat64);
diff --git a/libc/calls/stat64.S b/libc/calls/stat64.S
deleted file mode 100644
index e61b7bb04..000000000
--- a/libc/calls/stat64.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
-╞══════════════════════════════════════════════════════════════════════════════╡
-│ This is free and unencumbered software released into the public domain. │
-│ │
-│ Anyone is free to copy, modify, publish, use, compile, sell, or │
-│ distribute this software, either in source code form or as a compiled │
-│ binary, for any purpose, commercial or non-commercial, and by any │
-│ means. │
-│ │
-│ In jurisdictions that recognize copyright laws, the author or authors │
-│ of this software dedicate any and all copyright interest in the │
-│ software to the public domain. We make this dedication for the benefit │
-│ of the public at large and to the detriment of our heirs and │
-│ successors. We intend this dedication to be an overt act of │
-│ relinquishment in perpetuity of all present and future rights to this │
-│ software under copyright law. │
-│ │
-│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
-│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
-│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
-│ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │
-│ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
-│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │
-│ OTHER DEALINGS IN THE SOFTWARE. │
-╚─────────────────────────────────────────────────────────────────────────────*/
-#include "libc/macros.internal.h"
-
-stat64: jmp stat
- .endfn stat64,globl
diff --git a/libc/elf/elf.h b/libc/elf/elf.h
index 9df8827ac..9669d2a46 100644
--- a/libc/elf/elf.h
+++ b/libc/elf/elf.h
@@ -7,6 +7,7 @@
#include "libc/runtime/ezmap.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § executable & linkable format ─╬─│┼
@@ -29,6 +30,7 @@ const char *GetElfSectionName(const Elf64_Ehdr *, size_t, Elf64_Shdr *);
Elf64_Sym *GetElfDynSymbolTable(const Elf64_Ehdr *, size_t, Elf64_Xword *);
char *GetElfDynStringTable(const Elf64_Ehdr *, size_t);
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_ELF_H_ */
diff --git a/libc/fmt/atol.c b/libc/fmt/atol.c
index da13f1484..756cc3620 100644
--- a/libc/fmt/atol.c
+++ b/libc/fmt/atol.c
@@ -48,3 +48,5 @@ long atol(const char *s) {
}
return x;
}
+
+__weak_reference(atol, atoll);
diff --git a/libc/fmt/atoll.c b/libc/fmt/atoll.c
deleted file mode 100644
index 11b25e768..000000000
--- a/libc/fmt/atoll.c
+++ /dev/null
@@ -1,31 +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"
-
-/**
- * Decodes decimal number from ASCII string.
- *
- * @param s is a non-null nul-terminated string
- * @return the decoded signed saturated integer
- */
-long long atoll(const char *s) {
- _Static_assert(LONG_MAX == LONG_LONG_MAX, "need atoll impl");
- return atol(s);
-}
diff --git a/libc/fmt/div.c b/libc/fmt/div.c
index 4d36dfeee..53e32d70e 100644
--- a/libc/fmt/div.c
+++ b/libc/fmt/div.c
@@ -18,6 +18,19 @@
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/fmt/conv.h"
+/**
+ * Divides integers yielding numerator and denominator.
+ */
div_t(div)(int num, int den) {
- return div(num, den);
+ div_t retval;
+ retval.quot = num / den;
+ retval.rem = num % den;
+#if __STDC_VERSION__ + 0 < 199901L
+ // satisfy quot*denominator+rem == numerator
+ if (n > 0 && retval.rem < 0) {
+ retval.quot += 1;
+ retval.rem -= d;
+ }
+#endif
+ return retval;
}
diff --git a/libc/fmt/i128abs.c b/libc/fmt/i128abs.c
deleted file mode 100644
index c35be4f75..000000000
--- a/libc/fmt/i128abs.c
+++ /dev/null
@@ -1,24 +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/macros.internal.h"
-
-int128_t i128abs(int128_t x) {
- return ABS(x);
-}
diff --git a/libc/fmt/imaxabs.c b/libc/fmt/imaxabs.c
deleted file mode 100644
index 11a640d9f..000000000
--- a/libc/fmt/imaxabs.c
+++ /dev/null
@@ -1,24 +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/macros.internal.h"
-
-intmax_t imaxabs(intmax_t x) {
- return ABS(x);
-}
diff --git a/libc/fmt/imaxdiv.c b/libc/fmt/imaxdiv.c
deleted file mode 100644
index 4268a0813..000000000
--- a/libc/fmt/imaxdiv.c
+++ /dev/null
@@ -1,32 +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/fmt/conv.h"
-
-imaxdiv_t imaxdiv(intmax_t n, intmax_t d) {
- imaxdiv_t retval;
-
- retval.quot = n / d;
- retval.rem = n % d;
- // satisfy quot*denominator+rem == numerator
- if (n > 0 && retval.rem < 0) {
- retval.quot += 1;
- retval.rem -= d;
- }
- return (retval);
-}
diff --git a/libc/fmt/itoa.h b/libc/fmt/itoa.h
index a492328d1..e547a11e3 100644
--- a/libc/fmt/itoa.h
+++ b/libc/fmt/itoa.h
@@ -2,6 +2,26 @@
#define COSMOPOLITAN_LIBC_FMT_ITOA_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
+
+#define LengthInt64 __LengthInt64
+#define LengthUint64 __LengthUint64
+#define LengthInt64Thousands __LengthInt64Thousands
+#define LengthUint64Thousands __LengthUint64Thousands
+#define FormatInt32 __FormatInt32
+#define FormatUint32 __FormatUint32
+#define FormatInt64 __FormatInt64
+#define FormatUint64 __FormatUint64
+#define FormatInt64Thousands __FormatInt64Thousands
+#define FormatUint64Thousands __FormatUint64Thousands
+#define FormatOctal32 __FormatOctal32
+#define FormatOctal64 __FormatOctal64
+#define FormatBinary64 __FormatBinary64
+#define FormatHex64 __FormatHex64
+#define FormatFlex64 __FormatFlex64
+#define uint64toarray_radix16 __uint64toarray_radix16
+#define uint64toarray_fixed16 __uint64toarray_fixed16
+#define uint64toarray_radix8 __uint64toarray_radix8
unsigned LengthInt64(int64_t) pureconst;
unsigned LengthUint64(uint64_t) pureconst;
@@ -27,6 +47,7 @@ size_t int128toarray_radix10(int128_t, char *);
size_t uint128toarray_radix10(uint128_t, char *);
#endif
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_FMT_ITOA_H_ */
diff --git a/libc/fmt/ldiv.c b/libc/fmt/ldiv.c
index 5068a4572..4e21ceee4 100644
--- a/libc/fmt/ldiv.c
+++ b/libc/fmt/ldiv.c
@@ -18,6 +18,22 @@
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/fmt/conv.h"
+/**
+ * Divides integers yielding numerator and denominator.
+ */
ldiv_t(ldiv)(long num, long den) {
- return ldiv(num, den);
+ ldiv_t retval;
+ retval.quot = num / den;
+ retval.rem = num % den;
+#if __STDC_VERSION__ + 0 < 199901L
+ // satisfy quot*denominator+rem == numerator
+ if (n > 0 && retval.rem < 0) {
+ retval.quot += 1;
+ retval.rem -= d;
+ }
+#endif
+ return retval;
}
+
+__weak_reference(ldiv, lldiv);
+__weak_reference(ldiv, imaxdiv);
diff --git a/libc/fmt/leb128.h b/libc/fmt/leb128.h
index a16f2e960..d74d1aefb 100644
--- a/libc/fmt/leb128.h
+++ b/libc/fmt/leb128.h
@@ -2,6 +2,17 @@
#define COSMOPOLITAN_LIBC_FMT_LEB128_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
+
+#define sleb64 __sleb64
+#define zleb64 __zleb64
+#define uleb64 __uleb64
+#define unzleb64 __unzleb64
+#define unuleb64 __unuleb64
+#define sleb128 __sleb128
+#define zleb128 __zleb128
+#define uleb128 __uleb128
+#define unsleb128 __unsleb128
char *sleb64(char *, int64_t);
char *zleb64(char[hasatleast 10], int64_t);
@@ -16,6 +27,7 @@ char *uleb128(char *, uint128_t);
int unsleb128(const void *, size_t, int128_t *);
#endif /* __STRICT_ANSI__ */
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_FMT_LEB128_H_ */
diff --git a/libc/fmt/lldiv.c b/libc/fmt/lldiv.c
deleted file mode 100644
index fe844f7b9..000000000
--- a/libc/fmt/lldiv.c
+++ /dev/null
@@ -1,23 +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"
-
-lldiv_t(lldiv)(long long num, long long den) {
- return lldiv(num, den);
-}
diff --git a/libc/fmt/strtoimax.c b/libc/fmt/strtoimax.c
deleted file mode 100644
index d91291ed0..000000000
--- a/libc/fmt/strtoimax.c
+++ /dev/null
@@ -1,61 +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/conv.h"
-#include "libc/fmt/strtol.internal.h"
-#include "libc/limits.h"
-#include "libc/str/str.h"
-#include "libc/str/tab.internal.h"
-
-/**
- * Decodes intmax_t from ASCII string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded saturated integer
- * @see strtoumax()
- */
-intmax_t strtoimax(const char *s, char **endptr, int base) {
- char t = 0;
- int d, c = *s;
- intmax_t x = 0;
- CONSUME_SPACES(s, c);
- GET_SIGN(s, c, d);
- GET_RADIX(s, c, base);
- if ((c = kBase36[c & 255]) && --c < base) {
- if (!((t |= 1) & 2)) {
- do {
- if (__builtin_mul_overflow(x, base, &x) ||
- __builtin_add_overflow(x, c * d, &x)) {
- x = d > 0 ? INTMAX_MAX : INTMAX_MIN;
- errno = ERANGE;
- t |= 2;
- }
- } while ((c = kBase36[*++s & 255]) && --c < base);
- }
- }
- if (t && endptr) *endptr = s;
- return x;
-}
diff --git a/libc/fmt/strtol.c b/libc/fmt/strtol.c
index b37720662..f1bb38f69 100644
--- a/libc/fmt/strtol.c
+++ b/libc/fmt/strtol.c
@@ -70,3 +70,7 @@ long strtol(const char *s, char **endptr, int base) {
if (t && endptr) *endptr = s;
return x;
}
+
+__weak_reference(strtol, strtoimax);
+__weak_reference(strtol, strtoll);
+__weak_reference(strtol, strtoll_l);
diff --git a/libc/fmt/strtoll.c b/libc/fmt/strtoll.c
deleted file mode 100644
index 17d04d1cf..000000000
--- a/libc/fmt/strtoll.c
+++ /dev/null
@@ -1,38 +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"
-
-/**
- * Decodes signed integer from ASCII string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded signed saturated integer
- */
-long long strtoll(const char *s, char **endptr, int base) {
- _Static_assert(LONG_MAX == LONG_LONG_MAX, "need strtoll impl");
- return strtol(s, endptr, base);
-}
diff --git a/libc/fmt/strtoll_l.c b/libc/fmt/strtoll_l.c
deleted file mode 100644
index 377bf4cc8..000000000
--- a/libc/fmt/strtoll_l.c
+++ /dev/null
@@ -1,24 +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/fmt/conv.h"
-#include "libc/str/locale.h"
-
-long long strtoll_l(const char *nptr, char **endptr, int base, locale_t l) {
- return strtoll(nptr, endptr, base);
-}
diff --git a/libc/fmt/strtoul.c b/libc/fmt/strtoul.c
index dc3945a03..ef049fa1e 100644
--- a/libc/fmt/strtoul.c
+++ b/libc/fmt/strtoul.c
@@ -58,3 +58,7 @@ unsigned long strtoul(const char *s, char **endptr, int base) {
if (t && endptr) *endptr = s;
return d > 0 ? x : -x;
}
+
+__weak_reference(strtoul, strtoumax);
+__weak_reference(strtoul, strtoull);
+__weak_reference(strtoul, strtoull_l);
diff --git a/libc/fmt/strtoull.c b/libc/fmt/strtoull.c
deleted file mode 100644
index 4d2721e89..000000000
--- a/libc/fmt/strtoull.c
+++ /dev/null
@@ -1,38 +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"
-
-/**
- * Decodes unsigned integer from ASCII string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded integer mod 2⁶⁴ negated if leading `-`
- */
-unsigned long long strtoull(const char *s, char **endptr, int base) {
- _Static_assert(LONG_MAX == LONG_LONG_MAX, "need strtoull impl");
- return strtoul(s, endptr, base);
-}
diff --git a/libc/fmt/strtoull_l.c b/libc/fmt/strtoull_l.c
deleted file mode 100644
index 4f526865b..000000000
--- a/libc/fmt/strtoull_l.c
+++ /dev/null
@@ -1,25 +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/fmt/conv.h"
-#include "libc/str/locale.h"
-
-unsigned long long strtoull_l(const char *nptr, char **endptr, int base,
- locale_t l) {
- return strtoull(nptr, endptr, base);
-}
diff --git a/libc/fmt/strtoumax.c b/libc/fmt/strtoumax.c
deleted file mode 100644
index c1f41910c..000000000
--- a/libc/fmt/strtoumax.c
+++ /dev/null
@@ -1,54 +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/fmt/strtol.internal.h"
-#include "libc/str/str.h"
-#include "libc/str/tab.internal.h"
-
-/**
- * Decodes uintmax_t from ASCII string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded integer mod 2¹²⁸ negated if leading `-`
- * @see strtoimax()
- */
-uintmax_t strtoumax(const char *s, char **endptr, int base) {
- char t = 0;
- int d, c = *s;
- uintmax_t x = 0;
- CONSUME_SPACES(s, c);
- GET_SIGN(s, c, d);
- GET_RADIX(s, c, base);
- if ((c = kBase36[c & 255]) && --c < base) {
- t |= 1;
- do {
- x *= base;
- x += c;
- } while ((c = kBase36[*++s & 255]) && --c < base);
- }
- if (t && endptr) *endptr = s;
- return d > 0 ? x : -x;
-}
diff --git a/libc/fmt/wcscoll.c b/libc/fmt/wcscoll.c
deleted file mode 100644
index efef6a1e0..000000000
--- a/libc/fmt/wcscoll.c
+++ /dev/null
@@ -1,25 +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/str/locale.h"
-#include "libc/str/str.h"
-#include "libc/thread/tls.h"
-
-int wcscoll(const wchar_t *p, const wchar_t *q) {
- return wcscoll_l(p, q, (locale_t)__get_tls()->tib_locale);
-}
diff --git a/libc/fmt/wcstoimax.c b/libc/fmt/wcstoimax.c
deleted file mode 100644
index 10bf752a1..000000000
--- a/libc/fmt/wcstoimax.c
+++ /dev/null
@@ -1,61 +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/conv.h"
-#include "libc/fmt/strtol.internal.h"
-#include "libc/limits.h"
-#include "libc/str/str.h"
-#include "libc/str/tab.internal.h"
-
-/**
- * Decodes intmax_t from wide string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded saturated integer
- * @see strtoumax()
- */
-intmax_t wcstoimax(const wchar_t *s, wchar_t **endptr, int base) {
- char t = 0;
- intmax_t x = 0;
- int d, c = *s;
- CONSUME_SPACES(s, c);
- GET_SIGN(s, c, d);
- GET_RADIX(s, c, base);
- if ((c = kBase36[c & 255]) && --c < base) {
- if (!((t |= 1) & 2)) {
- do {
- if (__builtin_mul_overflow(x, base, &x) ||
- __builtin_add_overflow(x, c * d, &x)) {
- x = d > 0 ? INTMAX_MAX : INTMAX_MIN;
- errno = ERANGE;
- t |= 2;
- }
- } while ((c = kBase36[*++s & 255]) && --c < base);
- }
- }
- if (t && endptr) *endptr = s;
- return x;
-}
diff --git a/libc/fmt/wcstol.c b/libc/fmt/wcstol.c
index 28562afb4..c7e8b335a 100644
--- a/libc/fmt/wcstol.c
+++ b/libc/fmt/wcstol.c
@@ -58,3 +58,7 @@ long wcstol(const wchar_t *s, wchar_t **endptr, int base) {
if (t && endptr) *endptr = s;
return x;
}
+
+__weak_reference(wcstol, wcstoimax);
+__weak_reference(wcstol, wcstoll);
+__weak_reference(wcstol, wcstoll_l);
diff --git a/libc/fmt/wcstoll.c b/libc/fmt/wcstoll.c
deleted file mode 100644
index 6851237ed..000000000
--- a/libc/fmt/wcstoll.c
+++ /dev/null
@@ -1,60 +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/conv.h"
-#include "libc/fmt/strtol.internal.h"
-#include "libc/limits.h"
-#include "libc/str/str.h"
-#include "libc/str/tab.internal.h"
-
-/**
- * Decodes signed long long integer from wide string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return the decoded signed saturated number
- */
-long long wcstoll(const wchar_t *s, wchar_t **endptr, int base) {
- char t = 0;
- int d, c = *s;
- long long x = 0;
- CONSUME_SPACES(s, c);
- GET_SIGN(s, c, d);
- GET_RADIX(s, c, base);
- if ((c = kBase36[c & 255]) && --c < base) {
- if (!((t |= 1) & 2)) {
- do {
- if (__builtin_mul_overflow(x, base, &x) ||
- __builtin_add_overflow(x, c * d, &x)) {
- x = d > 0 ? LONG_LONG_MAX : LONG_LONG_MIN;
- errno = ERANGE;
- t |= 2;
- }
- } while ((c = kBase36[*++s & 255]) && --c < base);
- }
- }
- if (t && endptr) *endptr = s;
- return x;
-}
diff --git a/libc/fmt/wcstoll_l.c b/libc/fmt/wcstoll_l.c
deleted file mode 100644
index 6cd67cea8..000000000
--- a/libc/fmt/wcstoll_l.c
+++ /dev/null
@@ -1,25 +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/fmt/conv.h"
-#include "libc/str/locale.h"
-
-long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base,
- locale_t l) {
- return wcstoll(nptr, endptr, base);
-}
diff --git a/libc/fmt/wcstoul.c b/libc/fmt/wcstoul.c
index 192bc28c3..14f6d124a 100644
--- a/libc/fmt/wcstoul.c
+++ b/libc/fmt/wcstoul.c
@@ -57,3 +57,7 @@ unsigned long wcstoul(const wchar_t *s, wchar_t **endptr, int base) {
if (t && endptr) *endptr = s;
return d > 0 ? x : -x;
}
+
+__weak_reference(wcstoul, wcstoumax);
+__weak_reference(wcstoul, wcstoull);
+__weak_reference(wcstoul, wcstoull_l);
diff --git a/libc/fmt/wcstoull.c b/libc/fmt/wcstoull.c
deleted file mode 100644
index 73739c6ca..000000000
--- a/libc/fmt/wcstoull.c
+++ /dev/null
@@ -1,54 +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/conv.h"
-#include "libc/fmt/strtol.internal.h"
-#include "libc/str/str.h"
-#include "libc/str/tab.internal.h"
-
-/**
- * Decodes unsigned long long integer from wide string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded integer mod 2⁶⁴ negated if leading `-`
- */
-unsigned long long wcstoull(const wchar_t *s, wchar_t **endptr, int base) {
- char t = 0;
- int d, c = *s;
- unsigned long long x = 0;
- CONSUME_SPACES(s, c);
- GET_SIGN(s, c, d);
- GET_RADIX(s, c, base);
- if ((c = kBase36[c & 255]) && --c < base) {
- t |= 1;
- do {
- x *= base;
- x += c;
- } while ((c = kBase36[*++s & 255]) && --c < base);
- }
- if (t && endptr) *endptr = s;
- return d > 0 ? x : -x;
-}
diff --git a/libc/fmt/wcstoull_l.c b/libc/fmt/wcstoull_l.c
deleted file mode 100644
index e6003b8e0..000000000
--- a/libc/fmt/wcstoull_l.c
+++ /dev/null
@@ -1,25 +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/fmt/conv.h"
-#include "libc/str/locale.h"
-
-unsigned long long wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base,
- locale_t l) {
- return wcstoull(nptr, endptr, base);
-}
diff --git a/libc/fmt/wcstoumax.c b/libc/fmt/wcstoumax.c
deleted file mode 100644
index 8fc617813..000000000
--- a/libc/fmt/wcstoumax.c
+++ /dev/null
@@ -1,54 +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/fmt/strtol.internal.h"
-#include "libc/str/str.h"
-#include "libc/str/tab.internal.h"
-
-/**
- * Decodes uintmax_t from wide string.
- *
- * @param s is a non-null nul-terminated string
- * @param endptr if non-null will always receive a pointer to the char
- * following the last one this function processed, which is usually
- * the NUL byte, or in the case of invalid strings, would point to
- * the first invalid character
- * @param base can be anywhere between [2,36] or 0 to auto-detect based
- * on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
- * decimal (base 10) by default
- * @return decoded integer mod 2¹²⁸ negated if leading `-`
- * @see strtoimax()
- */
-uintmax_t wcstoumax(const wchar_t *s, wchar_t **endptr, int base) {
- char t = 0;
- int d, c = *s;
- uintmax_t x = 0;
- CONSUME_SPACES(s, c);
- GET_SIGN(s, c, d);
- GET_RADIX(s, c, base);
- if ((c = kBase36[c & 255]) && --c < base) {
- t |= 1;
- do {
- x *= base;
- x += c;
- } while ((c = kBase36[*++s & 255]) && --c < base);
- }
- if (t && endptr) *endptr = s;
- return d > 0 ? x : -x;
-}
diff --git a/libc/integral/c.inc b/libc/integral/c.inc
index f4ba8ff0b..a86663525 100644
--- a/libc/integral/c.inc
+++ b/libc/integral/c.inc
@@ -859,9 +859,10 @@ void abort(void) wontreturn;
#define __strong_reference(sym, aliassym) \
extern typeof(sym) aliassym __attribute__((__alias__(#sym)))
-#define __weak_reference(sym, alias) \
- asm(".weak\t" #alias "\n\t" \
- ".equ\t" #alias ", " #sym)
+#define __weak_reference(sym, alias) \
+ asm(".weak\t" #alias "\n\t" \
+ ".equ\t" #alias ", " #sym "\n\t" \
+ ".type\t" #alias ",@notype")
#define __funline \
extern __inline \
diff --git a/libc/intrin/aarch64/strchr.S b/libc/intrin/aarch64/strchr.S
index 6ab0ba2f3..2672c2978 100644
--- a/libc/intrin/aarch64/strchr.S
+++ b/libc/intrin/aarch64/strchr.S
@@ -28,6 +28,7 @@
#include "libc/intrin/aarch64/asmdefs.internal.h"
#define __strchr_aarch64 strchr
+#define __index_aarch64 index
.ident "\n\n\
Optimized Routines (MIT License)\n\
@@ -77,6 +78,7 @@ Copyright 2022 ARM Limited\n"
/* Locals and temporaries. */
+ENTRY_ALIAS (__strchr_aarch64, __index_aarch64)
ENTRY (__strchr_aarch64)
PTR_ARG (0)
/* Magic constant 0xc0300c03 to allow us to identify which lane
diff --git a/libc/intrin/aarch64/strrchr.S b/libc/intrin/aarch64/strrchr.S
index 162c5b11d..6ce4aa30f 100644
--- a/libc/intrin/aarch64/strrchr.S
+++ b/libc/intrin/aarch64/strrchr.S
@@ -28,6 +28,7 @@
#include "libc/intrin/aarch64/asmdefs.internal.h"
#define __strrchr_aarch64 strrchr
+#define __rindex_aarch64 rindex
.ident "\n\n\
Optimized Routines (MIT License)\n\
@@ -81,6 +82,7 @@ Copyright 2022 ARM Limited\n"
in the original string a count_trailing_zeros() operation will
identify exactly which byte is causing the termination, and why. */
+ENTRY_ALIAS (__strrchr_aarch64, __rindex_aarch64)
ENTRY (__strrchr_aarch64)
PTR_ARG (0)
/* Magic constant 0x40100401 to allow us to identify which lane
diff --git a/libc/intrin/abs.c b/libc/intrin/abs.c
index 8115c7019..f27c4d000 100644
--- a/libc/intrin/abs.c
+++ b/libc/intrin/abs.c
@@ -41,9 +41,5 @@ long labs(long x) {
return x < 0 ? -x : x;
}
-/**
- * Returns absolute value of 𝑥.
- */
-long long llabs(long long x) {
- return x < 0 ? -x : x;
-}
+__weak_reference(labs, llabs);
+__weak_reference(labs, imaxabs);
diff --git a/libc/intrin/bits.h b/libc/intrin/bits.h
index d79a1ed8a..586ebeb1c 100644
--- a/libc/intrin/bits.h
+++ b/libc/intrin/bits.h
@@ -2,6 +2,7 @@
#define COSMOPOLITAN_LIBC_BITS_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
#define CheckUnsigned(x) ((x) / !((typeof(x))(-1) < 0))
@@ -11,8 +12,6 @@ COSMOPOLITAN_C_START_
extern const uint8_t kReverseBits[256];
-uint32_t gray(uint32_t) pureconst;
-uint32_t ungray(uint32_t) pureconst;
int _bitreverse8(int) libcesque pureconst;
int _bitreverse16(int) libcesque pureconst;
uint32_t _bitreverse32(uint32_t)
@@ -22,7 +21,6 @@ libcesque pureconst;
unsigned long _roundup2pow(unsigned long) libcesque pureconst;
unsigned long _roundup2log(unsigned long) libcesque pureconst;
unsigned long _rounddown2pow(unsigned long) libcesque pureconst;
-unsigned long _hamming(unsigned long, unsigned long) pureconst;
unsigned _bextra(const unsigned *, size_t, char);
/*───────────────────────────────────────────────────────────────────────────│─╗
@@ -157,6 +155,7 @@ unsigned _bextra(const unsigned *, size_t, char);
})
#endif /* __GNUC__ && !__STRICT_ANSI__ */
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_H_ */
diff --git a/libc/intrin/bsf.c b/libc/intrin/bsf.c
index bc52e568e..da6eca51e 100644
--- a/libc/intrin/bsf.c
+++ b/libc/intrin/bsf.c
@@ -60,23 +60,4 @@ int(_bsfl)(long x) {
return _bsfl(x);
}
-/**
- * Returns position of first bit set.
- *
- * ctz(𝑥) 31^clz(𝑥) clz(𝑥)
- * uint32 𝑥 _bsf(𝑥) tzcnt(𝑥) ffs(𝑥) _bsr(𝑥) lzcnt(𝑥)
- * 0x00000000 wut 32 0 wut 32
- * 0x00000001 0 0 1 0 31
- * 0x80000001 0 0 1 31 0
- * 0x80000000 31 31 32 31 0
- * 0x00000010 4 4 5 4 27
- * 0x08000010 4 4 5 27 4
- * 0x08000000 27 27 28 27 4
- * 0xffffffff 0 0 1 31 0
- *
- * @param 𝑥 is a 64-bit integer
- * @return number in range 0..63 or undefined if 𝑥 is 0
- */
-int(_bsfll)(long long x) {
- return _bsfll(x);
-}
+__weak_reference(_bsfl, _bsfll);
diff --git a/libc/intrin/bsr.c b/libc/intrin/bsr.c
index d8505a3b6..31e25879e 100644
--- a/libc/intrin/bsr.c
+++ b/libc/intrin/bsr.c
@@ -60,23 +60,4 @@ int(_bsrl)(long x) {
return _bsrl(x);
}
-/**
- * Returns binary logarithm of 𝑥.
- *
- * ctz(𝑥) 31^clz(𝑥) clz(𝑥)
- * uint32 𝑥 _bsf(𝑥) tzcnt(𝑥) ffs(𝑥) _bsr(𝑥) lzcnt(𝑥)
- * 0x00000000 wut 32 0 wut 32
- * 0x00000001 0 0 1 0 31
- * 0x80000001 0 0 1 31 0
- * 0x80000000 31 31 32 31 0
- * 0x00000010 4 4 5 4 27
- * 0x08000010 4 4 5 27 4
- * 0x08000000 27 27 28 27 4
- * 0xffffffff 0 0 1 31 0
- *
- * @param x is a 64-bit integer
- * @return number in range 0..63 or undefined if 𝑥 is 0
- */
-int(_bsrll)(long long x) {
- return _bsrll(x);
-}
+__weak_reference(_bsrl, _bsrll);
diff --git a/libc/str/explicit_bzero.c b/libc/intrin/bswap.c
similarity index 67%
rename from libc/str/explicit_bzero.c
rename to libc/intrin/bswap.c
index a75103613..6effaa925 100644
--- a/libc/str/explicit_bzero.c
+++ b/libc/intrin/bswap.c
@@ -16,16 +16,32 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
-#include "libc/str/str.h"
+#include "libc/intrin/bswap.h"
+#include "libc/intrin/newbie.h"
+#include "libc/sock/sock.h"
-/**
- * Sets memory to zero w/ accompanying non-optimizing macro.
- *
- * This is intended for security-conscious applications.
- *
- * @param p points to bytes that'll be cleared
- * @param n is number of bytes to clear
- */
-void explicit_bzero(void *p, size_t n) {
- bzero(p, n);
+uint16_t(bswap_16)(uint16_t x) {
+ return (0x00ff & x) << 010 | (0xff00 & x) >> 010;
+}
+
+__strong_reference(bswap_16, ntohs);
+__strong_reference(bswap_16, htons);
+
+uint32_t(bswap_32)(uint32_t x) {
+ return (0x000000ffu & x) << 030 | (0x0000ff00u & x) << 010 |
+ (0x00ff0000u & x) >> 010 | (0xff000000u & x) >> 030;
+}
+
+__strong_reference(bswap_32, ntohl);
+__strong_reference(bswap_32, htonl);
+
+uint64_t(bswap_64)(uint64_t x) {
+ return (0x00000000000000ffull & x) << 070 |
+ (0x000000000000ff00ull & x) << 050 |
+ (0x0000000000ff0000ull & x) << 030 |
+ (0x00000000ff000000ull & x) << 010 |
+ (0x000000ff00000000ull & x) >> 010 |
+ (0x0000ff0000000000ull & x) >> 030 |
+ (0x00ff000000000000ull & x) >> 050 |
+ (0xff00000000000000ull & x) >> 070;
}
diff --git a/libc/intrin/bswap.h b/libc/intrin/bswap.h
index 1dad0e4b5..9de9280e0 100644
--- a/libc/intrin/bswap.h
+++ b/libc/intrin/bswap.h
@@ -5,7 +5,7 @@ COSMOPOLITAN_C_START_
uint16_t bswap_16(uint16_t) pureconst;
uint32_t bswap_32(uint32_t) pureconst;
-uint32_t bswap_64(uint32_t) pureconst;
+uint64_t bswap_64(uint64_t) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define bswap_16(x) __builtin_bswap16(x)
diff --git a/libc/intrin/bzero.c b/libc/intrin/bzero.c
index b97233545..a751b7122 100644
--- a/libc/intrin/bzero.c
+++ b/libc/intrin/bzero.c
@@ -165,3 +165,5 @@ void bzero(void *p, size_t n) {
bzero128(b, n);
}
}
+
+__weak_reference(bzero, explicit_bzero);
diff --git a/libc/intrin/exit.c b/libc/intrin/exit.c
index 9c7c0ba8c..8b2b954f7 100644
--- a/libc/intrin/exit.c
+++ b/libc/intrin/exit.c
@@ -91,3 +91,5 @@ wontreturn void _Exit(int exitcode) {
unreachable;
#endif
}
+
+__strong_reference(_Exit, _exit);
diff --git a/libc/intrin/fenv.S b/libc/intrin/fenv.S
index 5c9dfac9c..0ca23467e 100644
--- a/libc/intrin/fenv.S
+++ b/libc/intrin/fenv.S
@@ -39,7 +39,9 @@
// - `FE_INEXACT`
// - `FE_ALL_EXCEPT` (all of the above)
// @return 0 on success, or nonzero on error
+ .ftrace1
feclearexcept:
+ .ftrace2
#ifdef __x86_64__
// maintain exceptions in the sse mxcsr, clear x87 exceptions
mov %edi,%ecx
@@ -79,6 +81,7 @@ feclearexcept:
// volatile double x = 0, y = 1 / x;
// assert(fetestexcept(FE_ALL_EXCEPT) == FE_DIVBYZERO);
//
+ .ftrace1
// @param excepts may bitwise-or the following:
// - `FE_INVALID`
// - `FE_DIVBYZERO`
@@ -88,7 +91,9 @@ feclearexcept:
// - `FE_ALL_EXCEPT` (all of the above)
// @return mask of which exception status codes are currently set,
// or zero if there aren't any floating point exceptions
+ .ftrace1
fetestexcept:
+ .ftrace2
#ifdef __x86_64__
and $0x3f,%edi
push %rax
@@ -106,7 +111,9 @@ fetestexcept:
#endif
.endfn fetestexcept,globl
+ .ftrace1
feraiseexcept:
+ .ftrace2
#ifdef __x86_64__
and $0x3f,%edi
stmxcsr -8(%rsp)
@@ -124,7 +131,9 @@ feraiseexcept:
#endif
.endfn feraiseexcept,globl
+ .ftrace1
__fesetround:
+ .ftrace2
#ifdef __x86_64__
push %rax
xor %eax,%eax
@@ -150,7 +159,9 @@ __fesetround:
#endif
.endfn __fesetround,globl,hidden
+ .ftrace1
fegetround:
+ .ftrace2
#ifdef __x86_64__
push %rax
stmxcsr (%rsp)
@@ -165,7 +176,9 @@ fegetround:
#endif
.endfn fegetround,globl
+ .ftrace1
fegetenv:
+ .ftrace2
#ifdef __x86_64__
xor %eax,%eax
fnstenv (%rdi)
@@ -180,7 +193,9 @@ fegetenv:
#endif
.endfn fegetenv,globl
+ .ftrace1
fesetenv:
+ .ftrace2
#ifdef __x86_64__
xor %eax,%eax
inc %rdi
diff --git a/libc/intrin/ffs.c b/libc/intrin/ffs.c
index e5ecae566..257adb0ab 100644
--- a/libc/intrin/ffs.c
+++ b/libc/intrin/ffs.c
@@ -31,9 +31,4 @@ long ffsl(long x) {
return __builtin_ffsl(x);
}
-/**
- * Finds lowest set bit in word.
- */
-long long ffsll(long long x) {
- return __builtin_ffsll(x);
-}
+__weak_reference(ffsl, ffsll);
diff --git a/libc/intrin/gray.c b/libc/intrin/gray.c
deleted file mode 100644
index 2d2bef523..000000000
--- a/libc/intrin/gray.c
+++ /dev/null
@@ -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 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/intrin/bits.h"
-
-/**
- * Returns gray code for x.
- * @see https://en.wikipedia.org/wiki/Gray_code
- * @see ungray()
- */
-uint32_t gray(uint32_t x) {
- return x ^ (x >> 1);
-}
diff --git a/libc/intrin/hamming.c b/libc/intrin/hamming.c
deleted file mode 100644
index 1b61ee614..000000000
--- a/libc/intrin/hamming.c
+++ /dev/null
@@ -1,27 +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/intrin/popcnt.h"
-
-/**
- * Counts number of different bits.
- * @see https://en.wikipedia.org/wiki/Hamming_code
- */
-unsigned long _hamming(unsigned long x, unsigned long y) {
- return popcnt(x ^ y);
-}
diff --git a/libc/intrin/hilbert.h b/libc/intrin/hilbert.h
index 49ba62a7d..1b4b477ac 100644
--- a/libc/intrin/hilbert.h
+++ b/libc/intrin/hilbert.h
@@ -2,10 +2,14 @@
#define COSMOPOLITAN_LIBC_BITS_HILBERT_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
+#define hilbert __hilbert
+#define unhilbert __unhilbert
long hilbert(long, long, long) pureconst;
axdx_t unhilbert(long, long) pureconst;
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_HILBERT_H_ */
diff --git a/libc/intrin/kprintf.h b/libc/intrin/kprintf.h
index 98548985c..6c5d442b4 100644
--- a/libc/intrin/kprintf.h
+++ b/libc/intrin/kprintf.h
@@ -1,8 +1,22 @@
#ifndef COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_
#define COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_
+#ifdef COSMO
+
+#define kprintf __kprintf
+#define ksnprintf __ksnprintf
+#define kvprintf __kvprintf
+#define kvsnprintf __kvsnprintf
+#define kisdangerous __kisdangerous
+
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+void kprintf(const char *, ...);
+size_t ksnprintf(char *, size_t, const char *, ...);
+void kvprintf(const char *, va_list);
+size_t kvsnprintf(char *, size_t, const char *, va_list);
+bool kisdangerous(const void *);
+
void kprintf(const char *, ...);
size_t ksnprintf(char *, size_t, const char *, ...);
void kvprintf(const char *, va_list);
@@ -12,4 +26,5 @@ void _klog(const char *, size_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
+#endif /* COSMO */
#endif /* COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_ */
diff --git a/libc/intrin/likely.h b/libc/intrin/likely.h
index 3f96b4cf8..c05e671c7 100644
--- a/libc/intrin/likely.h
+++ b/libc/intrin/likely.h
@@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_BITS_LIKELY_H_
#define COSMOPOLITAN_LIBC_BITS_LIKELY_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
+#ifdef COSMO
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
@@ -17,5 +18,6 @@
#define VERY_UNLIKELY(x) UNLIKELY(x)
#endif
+#endif /* COSMO */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_LIKELY_H_ */
diff --git a/libc/intrin/lockxadd.h b/libc/intrin/lockxadd.h
deleted file mode 100644
index b47c53f39..000000000
--- a/libc/intrin/lockxadd.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef COSMOPOLITAN_LIBC_BITS_LOCKXADD_H_
-#define COSMOPOLITAN_LIBC_BITS_LOCKXADD_H_
-#if !(__ASSEMBLER__ + __LINKER__ + 0)
-COSMOPOLITAN_C_START_
-
-intptr_t _lockxadd(void *, intptr_t, size_t);
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86__)
-#define _lockxadd(PTR, VAL) \
- ({ \
- typeof(*(PTR)) Res; \
- typeof(Res) Val = (VAL); \
- asm volatile("lock xadd\t%0,%1" : "=r"(Res), "+m"(*(PTR)) : "0"(Val)); \
- Res; /* contains *PTR before addition cf. InterlockedAdd() */ \
- })
-#else
-#define _lockxadd(MEM, VAL) _lockxadd(MEM, (intptr_t)(VAL), sizeof(*(MEM)))
-#endif /* GNUC && !ANSI && x86 */
-
-COSMOPOLITAN_C_END_
-#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
-#endif /* COSMOPOLITAN_LIBC_BITS_LOCKXADD_H_ */
diff --git a/libc/intrin/memmove.c b/libc/intrin/memmove.c
index 357058d38..a3a0c1018 100644
--- a/libc/intrin/memmove.c
+++ b/libc/intrin/memmove.c
@@ -342,6 +342,6 @@ void *memmove(void *dst, const void *src, size_t n) {
}
}
-__strong_reference(memmove, memcpy);
+__weak_reference(memmove, memcpy);
#endif /* __aarch64__ */
diff --git a/libc/intrin/morton.c b/libc/intrin/morton.c
index d0d4c5753..ab03b777b 100644
--- a/libc/intrin/morton.c
+++ b/libc/intrin/morton.c
@@ -23,7 +23,7 @@
* @see https://en.wikipedia.org/wiki/Z-order_curve
* @see unmorton()
*/
-unsigned long(morton)(unsigned long y, unsigned long x) {
+unsigned long morton(unsigned long y, unsigned long x) {
x = (x | x << 020) & 0x0000FFFF0000FFFF;
x = (x | x << 010) & 0x00FF00FF00FF00FF;
x = (x | x << 004) & 0x0F0F0F0F0F0F0F0F;
diff --git a/libc/intrin/morton.h b/libc/intrin/morton.h
index f749573d4..215ece255 100644
--- a/libc/intrin/morton.h
+++ b/libc/intrin/morton.h
@@ -1,24 +1,16 @@
#ifndef COSMOPOLITAN_LIBC_BITS_MORTON_H_
#define COSMOPOLITAN_LIBC_BITS_MORTON_H_
-#include "libc/intrin/pdep.h"
-#include "libc/intrin/pext.h"
-#include "libc/nexgen32e/x86feature.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
+
+#define morton __morton
+#define unmorton __unmorton
unsigned long morton(unsigned long, unsigned long) libcesque;
axdx_t unmorton(unsigned long) libcesque;
-#ifndef __STRICT_ANSI__
-#define morton(Y, X) \
- (X86_NEED(BMI2) ? pdep(X, 0x5555555555555555) | pdep(Y, 0xAAAAAAAAAAAAAAAA) \
- : morton(Y, X))
-#define unmorton(I) \
- (X86_NEED(BMI2) \
- ? (axdx_t){pext(I, 0xAAAAAAAAAAAAAAAA), pext(I, 0x5555555555555555)} \
- : unmorton(I))
-#endif
-
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_MORTON_H_ */
diff --git a/libc/intrin/newbie.h b/libc/intrin/newbie.h
index 2d29f8fba..46528b0ae 100644
--- a/libc/intrin/newbie.h
+++ b/libc/intrin/newbie.h
@@ -2,11 +2,6 @@
#define COSMOPOLITAN_LIBC_BITS_NEWBIE_H_
#include "libc/intrin/bswap.h"
-/*
- * Macros for newbies.
- * https://justine.lol/endian.html
- */
-
#define BYTE_ORDER __BYTE_ORDER__
#define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define BIG_ENDIAN __ORDER_BIG_ENDIAN__
diff --git a/libc/intrin/pushpop.h b/libc/intrin/pushpop.h
index 1b1f6f185..56bb847ee 100644
--- a/libc/intrin/pushpop.h
+++ b/libc/intrin/pushpop.h
@@ -2,6 +2,7 @@
#define COSMOPOLITAN_LIBC_BITS_PUSHPOP_H_
#include "libc/macros.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
+#ifdef COSMO
#if !defined(__GNUC__) || defined(__STRICT_ANSI__) || !defined(__x86_64__)
#define pushpop(x) (x)
@@ -51,5 +52,6 @@
})
#endif
+#endif /* COSMO */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_PUSHPOP_H_ */
diff --git a/libc/intrin/repmovsb.h b/libc/intrin/repmovsb.h
index bb15832ed..b6b0b6a01 100644
--- a/libc/intrin/repmovsb.h
+++ b/libc/intrin/repmovsb.h
@@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_
#define COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
+#ifdef COSMO
forceinline void repmovsb(void **dest, const void **src, size_t cx) {
char *di = (char *)*dest;
@@ -22,5 +23,6 @@ forceinline void repmovsb(void **dest, const void **src, size_t cx) {
})
#endif
+#endif /* COSMO */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_ */
diff --git a/libc/intrin/repstosb.h b/libc/intrin/repstosb.h
index 554682da0..1f2051866 100644
--- a/libc/intrin/repstosb.h
+++ b/libc/intrin/repstosb.h
@@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_
#define COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
+#ifdef COSMO
forceinline void *repstosb(void *dest, unsigned char al, size_t cx) {
unsigned char *di = (unsigned char *)dest;
@@ -21,5 +22,6 @@ forceinline void *repstosb(void *dest, unsigned char al, size_t cx) {
})
#endif
+#endif /* COSMO */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_ */
diff --git a/libc/intrin/segmentation.h b/libc/intrin/segmentation.h
index 66e281745..862519730 100644
--- a/libc/intrin/segmentation.h
+++ b/libc/intrin/segmentation.h
@@ -2,6 +2,7 @@
#define COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#ifdef COSMO
/**
* Reads scalar from memory, offset by segment.
@@ -20,6 +21,7 @@
Pk; \
})
+#endif /* COSMO */
#endif /* __GNUC__ && !__STRICT_ANSI__ */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_SEGMENTATION_H_ */
diff --git a/libc/intrin/strchr.c b/libc/intrin/strchr.c
index 0024fb367..4190b9191 100644
--- a/libc/intrin/strchr.c
+++ b/libc/intrin/strchr.c
@@ -117,4 +117,6 @@ char *strchr(const char *s, int c) {
#endif
}
+__strong_reference(strchr, index);
+
#endif /* __aarch64__ */
diff --git a/libc/intrin/strrchr.c b/libc/intrin/strrchr.c
index d55a45911..59a230c71 100644
--- a/libc/intrin/strrchr.c
+++ b/libc/intrin/strrchr.c
@@ -31,4 +31,6 @@ char *strrchr(const char *s, int c) {
return memrchr(s, c, strlen(s));
}
+__strong_reference(strrchr, rindex);
+
#endif /* __aarch64__ */
diff --git a/libc/intrin/syscall.S b/libc/intrin/syscall.S
deleted file mode 100644
index e94eb339a..000000000
--- a/libc/intrin/syscall.S
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-.privileged
-
-// Invokes SYSCALL for libfatal forceinline asm() routines.
-//
-// @param rax is ordinal
-// @param rdi is arg1
-// @param rsi is arg2
-// @param rdx is arg3
-// @param rcx is arg4
-// @param r8 is arg5
-// @param r9 is arg6
-// @param rsp may contain more args
-// @return rdx:rax where rax holds -errno on error
-// @clob rax,rdx,memory,cc
-__syscall__:
- mov %rcx,.Lrcx(%rip)
- mov %rdi,.Lrdi(%rip)
- mov %rsi,.Lrsi(%rip)
- mov %r8,.Lr8(%rip)
- mov %r9,.Lr9(%rip)
- mov %r10,.Lr10(%rip)
- mov %r11,.Lr11(%rip)
- mov %rcx,%r10
- clc
- syscall
- jnc 1f
- neg %rax
-1: mov .Lrcx(%rip),%rcx
- mov .Lrdi(%rip),%rdi
- mov .Lrsi(%rip),%rsi
- mov .Lr8(%rip),%r8
- mov .Lr9(%rip),%r9
- mov .Lr10(%rip),%r10
- mov .Lr11(%rip),%r11
- ret
- .endfn __syscall__,globl,hidden
-
- .bss
- .balign 8
-.Lrcx: .quad 0 // clobbered by syscall
-.Lrdi: .quad 0 // just in case
-.Lrsi: .quad 0 // just in case
-.Lr8: .quad 0 // freebsd bug?
-.Lr9: .quad 0 // just in case
-.Lr10: .quad 0 // just in case
-.Lr11: .quad 0 // clobbered by syscall
diff --git a/libc/intrin/ungray.c b/libc/intrin/ungray.c
deleted file mode 100644
index f9b3ce120..000000000
--- a/libc/intrin/ungray.c
+++ /dev/null
@@ -1,33 +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/intrin/bits.h"
-
-/**
- * Decodes gray code.
- * @see https://en.wikipedia.org/wiki/Gray_code
- * @see gray()
- */
-uint32_t ungray(uint32_t x) {
- x ^= x >> 16;
- x ^= x >> 8;
- x ^= x >> 4;
- x ^= x >> 2;
- x ^= x >> 1;
- return x;
-}
diff --git a/libc/intrin/unmorton.c b/libc/intrin/unmorton.c
index 5f98e1c28..9c1e3ab84 100644
--- a/libc/intrin/unmorton.c
+++ b/libc/intrin/unmorton.c
@@ -36,6 +36,6 @@ static unsigned long GetOddBits(unsigned long x) {
* @see en.wikipedia.org/wiki/Z-order_curve
* @see morton()
*/
-axdx_t(unmorton)(unsigned long i) {
+axdx_t unmorton(unsigned long i) {
return (axdx_t){GetOddBits(i >> 1), GetOddBits(i)};
}
diff --git a/libc/intrin/xadd.h b/libc/intrin/xadd.h
deleted file mode 100644
index c5c1af334..000000000
--- a/libc/intrin/xadd.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef COSMOPOLITAN_LIBC_BITS_XADD_H_
-#define COSMOPOLITAN_LIBC_BITS_XADD_H_
-#if !(__ASSEMBLER__ + __LINKER__ + 0)
-COSMOPOLITAN_C_START_
-
-#define _xadd(p, v) \
- ({ \
- typeof(*(p)) Res; \
- autotype(Res) Val = (v); \
- asm volatile("xadd\t%0,%1" : "=r"(Res), "+m"(*(p)) : "0"(Val)); \
- Res + Val; \
- })
-
-COSMOPOLITAN_C_END_
-#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
-#endif /* COSMOPOLITAN_LIBC_BITS_XADD_H_ */
diff --git a/libc/runtime/exit2.c b/libc/runtime/exit2.c
deleted file mode 100644
index 438fc680f..000000000
--- a/libc/runtime/exit2.c
+++ /dev/null
@@ -1,34 +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/runtime/runtime.h"
-
-/**
- * Terminates process, ignoring destructors and atexit() handlers.
- *
- * When running on bare metal, this function will reboot your computer
- * by hosing the interrupt descriptors and triple faulting the system.
- *
- * @param exitcode is masked with 255
- * @asyncsignalsafe
- * @vforksafe
- * @noreturn
- */
-wontreturn void _exit(int exitcode) {
- _Exit(exitcode);
-}
diff --git a/libc/sock/sock.h b/libc/sock/sock.h
index ccfa6b1ad..88de46834 100644
--- a/libc/sock/sock.h
+++ b/libc/sock/sock.h
@@ -9,10 +9,10 @@ COSMOPOLITAN_C_START_
#define INET_ADDRSTRLEN 22
#define IFHWADDRLEN 6
-uint16_t htons(uint16_t);
-uint16_t ntohs(uint16_t);
-uint32_t htonl(uint32_t);
-uint32_t ntohl(uint32_t);
+uint16_t htons(uint16_t) pureconst;
+uint16_t ntohs(uint16_t) pureconst;
+uint32_t htonl(uint32_t) pureconst;
+uint32_t ntohl(uint32_t) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define htons(x) __builtin_bswap16(x)
diff --git a/libc/stdio/append.h b/libc/stdio/append.h
index c6560a99d..49817097b 100644
--- a/libc/stdio/append.h
+++ b/libc/stdio/append.h
@@ -1,9 +1,20 @@
#ifndef COSMOPOLITAN_LIBC_STDIO_APPEND_H_
#define COSMOPOLITAN_LIBC_STDIO_APPEND_H_
#include "libc/fmt/pflink.h"
+#ifdef COSMO
#define APPEND_COOKIE 21578
+#define appendz __appendz
+#define appendr __appendr
+#define appendd __appendd
+#define appendw __appendw
+#define appends __appends
+#define appendf __appendf
+#define vappendf __vappendf
+#define kappendf __kappendf
+#define kvappendf __kvappendf
+
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
@@ -22,11 +33,7 @@ ssize_t vappendf(char **, const char *, va_list);
ssize_t kappendf(char **, const char *, ...);
ssize_t kvappendf(char **, const char *, va_list);
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define appendf(BUF, FMT, ...) appendf(BUF, PFLINK(FMT), ##__VA_ARGS__)
-#define vappendf(BUF, FMT, VA) vappendf(BUF, PFLINK(FMT), VA)
-#endif
-
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
+#endif /* COSMO */
#endif /* COSMOPOLITAN_LIBC_STDIO_APPEND_H_ */
diff --git a/libc/stdio/fgetc.c b/libc/stdio/fgetc.c
index 8dda15ace..9b8de9fe5 100644
--- a/libc/stdio/fgetc.c
+++ b/libc/stdio/fgetc.c
@@ -34,3 +34,5 @@ int fgetc(FILE *f) {
funlockfile(f);
return rc;
}
+
+__strong_reference(fgetc, getc);
diff --git a/libc/stdio/fgetc_unlocked.c b/libc/stdio/fgetc_unlocked.c
index 51a299220..03fb0c505 100644
--- a/libc/stdio/fgetc_unlocked.c
+++ b/libc/stdio/fgetc_unlocked.c
@@ -34,3 +34,5 @@ int fgetc_unlocked(FILE *f) {
return b[0];
}
}
+
+__strong_reference(fgetc_unlocked, getc_unlocked);
diff --git a/libc/stdio/fgetwc.c b/libc/stdio/fgetwc.c
index aecf07615..39cc5b2b2 100644
--- a/libc/stdio/fgetwc.c
+++ b/libc/stdio/fgetwc.c
@@ -34,3 +34,5 @@ wint_t fgetwc(FILE *f) {
funlockfile(f);
return wc;
}
+
+__strong_reference(fgetwc, getwc);
diff --git a/libc/stdio/fgetwc_unlocked.c b/libc/stdio/fgetwc_unlocked.c
index 7f5a421d5..62ae0fea2 100644
--- a/libc/stdio/fgetwc_unlocked.c
+++ b/libc/stdio/fgetwc_unlocked.c
@@ -49,3 +49,5 @@ wint_t fgetwc_unlocked(FILE *f) {
}
return x;
}
+
+__strong_reference(fgetwc_unlocked, getwc_unlocked);
diff --git a/libc/stdio/fputc.c b/libc/stdio/fputc.c
index 28b8a3b72..4a4fe5b0b 100644
--- a/libc/stdio/fputc.c
+++ b/libc/stdio/fputc.c
@@ -33,3 +33,5 @@ int fputc(int c, FILE *f) {
funlockfile(f);
return rc;
}
+
+__strong_reference(fputc, putc);
diff --git a/libc/stdio/fputc_unlocked.c b/libc/stdio/fputc_unlocked.c
index 8aa5e1494..41494f8eb 100644
--- a/libc/stdio/fputc_unlocked.c
+++ b/libc/stdio/fputc_unlocked.c
@@ -36,3 +36,5 @@ int fputc_unlocked(int c, FILE *f) {
return b;
}
}
+
+__strong_reference(fputc_unlocked, putc_unlocked);
diff --git a/libc/stdio/fputwc.c b/libc/stdio/fputwc.c
index 6356c1aed..9cecb6f8f 100644
--- a/libc/stdio/fputwc.c
+++ b/libc/stdio/fputwc.c
@@ -34,3 +34,5 @@ wint_t fputwc(wchar_t wc, FILE *f) {
funlockfile(f);
return rc;
}
+
+__strong_reference(fputwc, putwc);
diff --git a/libc/stdio/fputwc_unlocked.c b/libc/stdio/fputwc_unlocked.c
index ede03584d..0c6338022 100644
--- a/libc/stdio/fputwc_unlocked.c
+++ b/libc/stdio/fputwc_unlocked.c
@@ -40,3 +40,5 @@ wint_t fputwc_unlocked(wchar_t wc, FILE *f) {
return -1;
}
}
+
+__strong_reference(fputwc_unlocked, putwc_unlocked);
diff --git a/libc/stdio/fseek.c b/libc/stdio/fseek.c
deleted file mode 100644
index f9c92c79f..000000000
--- a/libc/stdio/fseek.c
+++ /dev/null
@@ -1,36 +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/stdio/stdio.h"
-
-/**
- * Repositions open file stream.
- *
- * This function flushes the buffer (unless it's currently in the EOF
- * state) and then calls lseek() on the underlying file. If the stream
- * is in the EOF state, this function can be used to restore it without
- * needing to reopen the file.
- *
- * @param f is a non-null stream handle
- * @param offset is the byte delta
- * @param whence can be SEET_SET, SEEK_CUR, or SEEK_END
- * @returns 0 on success or -1 on error
- */
-int fseek(FILE *f, long offset, int whence) {
- return fseeko(f, offset, whence);
-}
diff --git a/libc/stdio/fseeko.c b/libc/stdio/fseeko.c
index c20380c31..4d0bb3b93 100644
--- a/libc/stdio/fseeko.c
+++ b/libc/stdio/fseeko.c
@@ -44,3 +44,5 @@ int fseeko(FILE *f, int64_t offset, int whence) {
funlockfile(f);
return rc;
}
+
+__strong_reference(fseeko, fseek);
diff --git a/libc/stdio/ftell.c b/libc/stdio/ftell.c
deleted file mode 100644
index 1f843eab1..000000000
--- a/libc/stdio/ftell.c
+++ /dev/null
@@ -1,29 +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/stdio/stdio.h"
-
-/**
- * Returns current position of stream.
- *
- * @param stream is a non-null stream handle
- * @returns current byte offset from beginning, or -1 w/ errno
- */
-long ftell(FILE *f) {
- return ftello(f);
-}
diff --git a/libc/stdio/ftello.c b/libc/stdio/ftello.c
index 0f12ba119..782f3579b 100644
--- a/libc/stdio/ftello.c
+++ b/libc/stdio/ftello.c
@@ -55,3 +55,5 @@ int64_t ftello(FILE *f) {
funlockfile(f);
return rc;
}
+
+__strong_reference(ftello, ftell);
diff --git a/libc/stdio/getc.c b/libc/stdio/getc.c
deleted file mode 100644
index 906621ee6..000000000
--- a/libc/stdio/getc.c
+++ /dev/null
@@ -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=8 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/stdio/stdio.h"
-
-/**
- * Reads byte from stream.
- * @return byte in range 0..255, or -1 w/ errno
- * @threadsafe
- */
-int(getc)(FILE *f) {
- return fgetc(f);
-}
diff --git a/libc/stdio/getc_unlocked.c b/libc/stdio/getc_unlocked.c
deleted file mode 100644
index 8f4ea49c2..000000000
--- a/libc/stdio/getc_unlocked.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
-│vi: set net ft=c ts=8 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/stdio/stdio.h"
-
-/**
- * Reads byte from stream.
- * @return byte in range 0..255, or -1 w/ errno
- */
-int(getc_unlocked)(FILE *f) {
- return fgetc_unlocked(f);
-}
diff --git a/libc/stdio/getwc.c b/libc/stdio/getwc.c
deleted file mode 100644
index e8ee98759..000000000
--- a/libc/stdio/getwc.c
+++ /dev/null
@@ -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 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/stdio/stdio.h"
-
-/**
- * Reads UTF-8 character from stream.
- * @return wide character or -1 on EOF or error
- * @threadsafe
- */
-wint_t(getwc)(FILE *f) {
- return fgetwc(f);
-}
diff --git a/libc/stdio/getwc_unlocked.c b/libc/stdio/getwc_unlocked.c
deleted file mode 100644
index 0bb9975e6..000000000
--- a/libc/stdio/getwc_unlocked.c
+++ /dev/null
@@ -1,27 +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/stdio/stdio.h"
-
-/**
- * Reads UTF-8 character from stream.
- * @return wide character or -1 on EOF or error
- */
-wint_t(getwc_unlocked)(FILE *f) {
- return fgetwc_unlocked(f);
-}
diff --git a/libc/stdio/lcg.internal.h b/libc/stdio/lcg.internal.h
index 6efd36d42..845c12026 100644
--- a/libc/stdio/lcg.internal.h
+++ b/libc/stdio/lcg.internal.h
@@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_LCG_H_
#define COSMOPOLITAN_LIBC_LCG_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
+#ifdef COSMO
forceinline uint64_t KnuthLinearCongruentialGenerator(uint64_t prev[1]) {
/* Knuth, D.E., "The Art of Computer Programming," Vol 2,
@@ -10,5 +11,6 @@ forceinline uint64_t KnuthLinearCongruentialGenerator(uint64_t prev[1]) {
return prev[0]; /* be sure to shift! */
}
+#endif /* COSMO */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_LCG_H_ */
diff --git a/libc/stdio/putc.c b/libc/stdio/putc.c
deleted file mode 100644
index a71b6fa05..000000000
--- a/libc/stdio/putc.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
-│vi: set net ft=c ts=8 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/stdio/stdio.h"
-
-/**
- * Writes byte to stream.
- *
- * @param c is byte to buffer or write, which is masked
- * @return c as unsigned char if written or -1 w/ errno
- * @threadsafe
- */
-int(putc)(int c, FILE *f) {
- return fputc(c, f);
-}
diff --git a/libc/stdio/putc_unlocked.c b/libc/stdio/putc_unlocked.c
deleted file mode 100644
index a587d245d..000000000
--- a/libc/stdio/putc_unlocked.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
-│vi: set net ft=c ts=8 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/stdio/stdio.h"
-
-/**
- * Writes byte to stream.
- *
- * @param c is byte to buffer or write, which is masked
- * @return c as unsigned char if written or -1 w/ errno
- */
-int(putc_unlocked)(int c, FILE *f) {
- return fputc_unlocked(c, f);
-}
diff --git a/libc/stdio/putwc.c b/libc/stdio/putwc.c
deleted file mode 100644
index eafe3212f..000000000
--- a/libc/stdio/putwc.c
+++ /dev/null
@@ -1,29 +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/stdio/stdio.h"
-
-/**
- * Writes wide character to stream.
- *
- * @return wc if written or -1 w/ errno
- * @threadsafe
- */
-wint_t(putwc)(wchar_t wc, FILE *f) {
- return fputwc(wc, f);
-}
diff --git a/libc/stdio/rand.h b/libc/stdio/rand.h
index 76ff8b4ff..37c42dc97 100644
--- a/libc/stdio/rand.h
+++ b/libc/stdio/rand.h
@@ -22,6 +22,12 @@ char *setstate(char *);
long random(void);
void srandom(unsigned);
+#ifdef COSMO
+#define vigna __vigna
+#define vigna_r __vigna_r
+#define rngset __rngset
+#define rdrand __rdrand
+#define rdseed __rdseed
uint64_t lemur64(void);
uint64_t _rand64(void);
uint64_t vigna(void);
@@ -37,6 +43,7 @@ double _real2(uint64_t);
double _real3(uint64_t);
double MeasureEntropy(const char *, size_t);
void *rngset(void *, size_t, uint64_t (*)(void), size_t);
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
diff --git a/libc/stdio/xorshift.h b/libc/stdio/xorshift.h
index 8ff8ad571..585ec65a5 100644
--- a/libc/stdio/xorshift.h
+++ b/libc/stdio/xorshift.h
@@ -1,5 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_RAND_XORSHIFT_H_
#define COSMOPOLITAN_LIBC_RAND_XORSHIFT_H_
+#ifdef COSMO
#define kMarsagliaXorshift64Seed 88172645463325252
#define kMarsagliaXorshift32Seed 2463534242
@@ -12,4 +13,5 @@ uint64_t MarsagliaXorshift64(uint64_t[hasatleast 1]);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
+#endif /* COSMO */
#endif /* COSMOPOLITAN_LIBC_RAND_XORSHIFT_H_ */
diff --git a/libc/str/index.c b/libc/str/index.c
deleted file mode 100644
index 6e1decccf..000000000
--- a/libc/str/index.c
+++ /dev/null
@@ -1,31 +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/str/str.h"
-
-/**
- * Returns pointer to first instance of character, the BSD way.
- *
- * @param s is a NUL-terminated string
- * @param is masked with 255 as byte to search for
- * @return is pointer to first instance of c or NULL if not found,
- * noting that c being NUL will return a pointer to terminator
- */
-char *index(const char *s, int c) {
- return strchr(s, c);
-}
diff --git a/libc/str/isalnum.c b/libc/str/isalnum.c
index f4866bbba..c1cd5fe69 100644
--- a/libc/str/isalnum.c
+++ b/libc/str/isalnum.c
@@ -25,3 +25,5 @@ int isalnum(int c) {
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') ||
('a' <= c && c <= 'z');
}
+
+__weak_reference(isalnum, isalnum_l);
diff --git a/libc/str/isalpha.c b/libc/str/isalpha.c
index 583053d61..8230c02f0 100644
--- a/libc/str/isalpha.c
+++ b/libc/str/isalpha.c
@@ -24,3 +24,5 @@
int isalpha(int c) {
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
}
+
+__weak_reference(isalpha, isalpha_l);
diff --git a/libc/str/isascii.c b/libc/str/isascii.c
index b545e51a6..bcb152e55 100644
--- a/libc/str/isascii.c
+++ b/libc/str/isascii.c
@@ -24,3 +24,5 @@
int isascii(int c) {
return 0x00 <= c && c <= 0x7F;
}
+
+__weak_reference(isascii, isascii_l);
diff --git a/libc/str/isblank.c b/libc/str/isblank.c
index 3e0a4b94c..141855a72 100644
--- a/libc/str/isblank.c
+++ b/libc/str/isblank.c
@@ -24,3 +24,5 @@
int isblank(int c) {
return c == ' ' || c == '\t';
}
+
+__weak_reference(isblank, isblank_l);
diff --git a/libc/str/iscntrl.c b/libc/str/iscntrl.c
index 4f484e722..2d8570f75 100644
--- a/libc/str/iscntrl.c
+++ b/libc/str/iscntrl.c
@@ -24,3 +24,5 @@
int iscntrl(int c) {
return (0x00 <= c && c <= 0x1F) || c == 0x7F;
}
+
+__weak_reference(iscntrl, iscntrl_l);
diff --git a/libc/str/isdigit.c b/libc/str/isdigit.c
index f7fca46a7..4758f1d0d 100644
--- a/libc/str/isdigit.c
+++ b/libc/str/isdigit.c
@@ -24,3 +24,5 @@
int isdigit(int c) {
return '0' <= c && c <= '9';
}
+
+__weak_reference(isdigit, isdigit_l);
diff --git a/libc/str/isdigit_l.c b/libc/str/isdigit_l.c
deleted file mode 100644
index c6aa06f73..000000000
--- a/libc/str/isdigit_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int isdigit_l(int c, locale_t l) {
- return iswdigit(c);
-}
diff --git a/libc/str/isgraph.c b/libc/str/isgraph.c
index 16a91cf94..2deb852d3 100644
--- a/libc/str/isgraph.c
+++ b/libc/str/isgraph.c
@@ -24,3 +24,5 @@
int isgraph(int c) {
return 0x21 <= c && c <= 0x7E;
}
+
+__weak_reference(isgraph, isgraph_l);
diff --git a/libc/str/islower.c b/libc/str/islower.c
index c7079e22b..e83fec919 100644
--- a/libc/str/islower.c
+++ b/libc/str/islower.c
@@ -24,3 +24,5 @@
int islower(int c) {
return 'a' <= c && c <= 'z';
}
+
+__weak_reference(islower, islower_l);
diff --git a/libc/str/islower_l.c b/libc/str/islower_l.c
deleted file mode 100644
index 0a437afd5..000000000
--- a/libc/str/islower_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int islower_l(int c, locale_t l) {
- return islower(c);
-}
diff --git a/libc/str/isprint.c b/libc/str/isprint.c
index 1746288e5..147d97f0f 100644
--- a/libc/str/isprint.c
+++ b/libc/str/isprint.c
@@ -24,3 +24,5 @@
int isprint(int c) {
return 0x20 <= c && c <= 0x7E;
}
+
+__weak_reference(isprint, isprint_l);
diff --git a/libc/str/ispunct.c b/libc/str/ispunct.c
index f792c7eed..25277c275 100644
--- a/libc/str/ispunct.c
+++ b/libc/str/ispunct.c
@@ -25,3 +25,5 @@ int ispunct(int c) {
return (0x21 <= c && c <= 0x7E) && !('0' <= c && c <= '9') &&
!('A' <= c && c <= 'Z') && !('a' <= c && c <= 'z');
}
+
+__weak_reference(ispunct, ispunct_l);
diff --git a/libc/str/isspace.c b/libc/str/isspace.c
index 2c18305c7..dad06361f 100644
--- a/libc/str/isspace.c
+++ b/libc/str/isspace.c
@@ -26,3 +26,5 @@ int isspace(int c) {
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f' ||
c == '\v';
}
+
+__weak_reference(isspace, isspace_l);
diff --git a/libc/str/isupper.c b/libc/str/isupper.c
index 6c6d6cd5e..b2afc3083 100644
--- a/libc/str/isupper.c
+++ b/libc/str/isupper.c
@@ -24,3 +24,5 @@
int isupper(int c) {
return 'A' <= c && c <= 'Z';
}
+
+__weak_reference(isupper, isupper_l);
diff --git a/libc/str/isupper_l.c b/libc/str/isupper_l.c
deleted file mode 100644
index f4c2c61ea..000000000
--- a/libc/str/isupper_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int isupper_l(int c, locale_t l) {
- return isupper(c);
-}
diff --git a/libc/str/iswalnum.c b/libc/str/iswalnum.c
index 58e54da55..c4d36543b 100644
--- a/libc/str/iswalnum.c
+++ b/libc/str/iswalnum.c
@@ -24,3 +24,5 @@
int iswalnum(wint_t c) {
return iswdigit(c) || iswalpha(c);
}
+
+__weak_reference(iswalnum, iswalnum_l);
diff --git a/libc/str/iswalpha.c b/libc/str/iswalpha.c
index fa246056c..a853a60c8 100644
--- a/libc/str/iswalpha.c
+++ b/libc/str/iswalpha.c
@@ -24,3 +24,5 @@
int iswalpha(wint_t c) {
return iswupper(c) || iswlower(c);
}
+
+__weak_reference(iswalpha, iswalpha_l);
diff --git a/libc/str/iswalpha_l.c b/libc/str/iswalpha_l.c
deleted file mode 100644
index 2382dd560..000000000
--- a/libc/str/iswalpha_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswalpha_l(wint_t c, locale_t l) {
- return iswalpha(c);
-}
diff --git a/libc/str/iswblank.c b/libc/str/iswblank.c
index d3af4a1ba..06c56c734 100644
--- a/libc/str/iswblank.c
+++ b/libc/str/iswblank.c
@@ -24,3 +24,5 @@
int iswblank(wint_t c) {
return c == ' ' || c == '\t';
}
+
+__weak_reference(iswblank, iswblank_l);
diff --git a/libc/str/iswblank_l.c b/libc/str/iswblank_l.c
deleted file mode 100644
index fd2320500..000000000
--- a/libc/str/iswblank_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswblank_l(wint_t c, locale_t l) {
- return iswblank(c);
-}
diff --git a/libc/str/iswcntrl.c b/libc/str/iswcntrl.c
index 5ce225bcb..1197136b1 100644
--- a/libc/str/iswcntrl.c
+++ b/libc/str/iswcntrl.c
@@ -24,3 +24,5 @@
int iswcntrl(wint_t c) {
return (0x00 <= c && c <= 0x1F) || (0x7F <= c && c <= 0x9F);
}
+
+__weak_reference(iswcntrl, iswcntrl_l);
diff --git a/libc/str/iswcntrl_l.c b/libc/str/iswcntrl_l.c
deleted file mode 100644
index e38525447..000000000
--- a/libc/str/iswcntrl_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswcntrl_l(wint_t c, locale_t l) {
- return iswcntrl(c);
-}
diff --git a/libc/str/iswdigit.c b/libc/str/iswdigit.c
index 9a008c422..6c98046a8 100644
--- a/libc/str/iswdigit.c
+++ b/libc/str/iswdigit.c
@@ -24,3 +24,5 @@
int iswdigit(wint_t c) {
return '0' <= c && c <= '9';
}
+
+__weak_reference(iswdigit, iswdigit_l);
diff --git a/libc/str/iswdigit_l.c b/libc/str/iswdigit_l.c
deleted file mode 100644
index 5738a1dc0..000000000
--- a/libc/str/iswdigit_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswdigit_l(wint_t c, locale_t l) {
- return iswdigit(c);
-}
diff --git a/libc/str/iswgraph.c b/libc/str/iswgraph.c
index b4c740b02..efe2dadba 100644
--- a/libc/str/iswgraph.c
+++ b/libc/str/iswgraph.c
@@ -24,3 +24,5 @@
int iswgraph(wint_t c) {
return iswprint(c) && !iswspace(c);
}
+
+__weak_reference(iswgraph, iswgraph_l);
diff --git a/libc/str/iswlower.c b/libc/str/iswlower.c
index 5173701c0..57d9ed92a 100644
--- a/libc/str/iswlower.c
+++ b/libc/str/iswlower.c
@@ -516,3 +516,5 @@ int iswlower(wint_t c) {
}
}
}
+
+__weak_reference(iswlower, iswlower_l);
diff --git a/libc/str/iswlower_l.c b/libc/str/iswlower_l.c
deleted file mode 100644
index e5fc19f31..000000000
--- a/libc/str/iswlower_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswlower_l(wint_t c, locale_t l) {
- return iswlower(c);
-}
diff --git a/libc/str/iswprint.c b/libc/str/iswprint.c
index bb794f612..6f98ed127 100644
--- a/libc/str/iswprint.c
+++ b/libc/str/iswprint.c
@@ -25,3 +25,5 @@ int iswprint(wint_t c) {
return !((0x00 <= c && c <= 0x1F) || (0x7F <= c && c <= 0x9F) ||
(0xFFF9 <= c && c <= 0xFFFB) || c == 0x2028 || c == 0x2029);
}
+
+__weak_reference(iswprint, iswprint_l);
diff --git a/libc/str/iswprint_l.c b/libc/str/iswprint_l.c
deleted file mode 100644
index d95218571..000000000
--- a/libc/str/iswprint_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswprint_l(wint_t c, locale_t l) {
- return iswprint(c);
-}
diff --git a/libc/str/iswpunct.c b/libc/str/iswpunct.c
index e0410a885..df8c20ffb 100644
--- a/libc/str/iswpunct.c
+++ b/libc/str/iswpunct.c
@@ -539,3 +539,5 @@ int iswpunct(wint_t c) {
return 0;
}
}
+
+__weak_reference(iswpunct, iswpunct_l);
diff --git a/libc/str/iswpunct_l.c b/libc/str/iswpunct_l.c
deleted file mode 100644
index e99c93b2b..000000000
--- a/libc/str/iswpunct_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswpunct_l(wint_t c, locale_t l) {
- return iswpunct(c);
-}
diff --git a/libc/str/iswspace.c b/libc/str/iswspace.c
index b1b08cd7f..8712b90a9 100644
--- a/libc/str/iswspace.c
+++ b/libc/str/iswspace.c
@@ -54,3 +54,5 @@ int iswspace(wint_t c) {
return 0;
}
}
+
+__weak_reference(iswspace, iswspace_l);
diff --git a/libc/str/iswspace_l.c b/libc/str/iswspace_l.c
deleted file mode 100644
index e79eeaa74..000000000
--- a/libc/str/iswspace_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswspace_l(wint_t c, locale_t l) {
- return iswspace(c);
-}
diff --git a/libc/str/iswupper.c b/libc/str/iswupper.c
index d746628c4..e13ca81d8 100644
--- a/libc/str/iswupper.c
+++ b/libc/str/iswupper.c
@@ -160,3 +160,5 @@ int iswupper(wint_t c) {
}
}
}
+
+__weak_reference(iswupper, iswupper_l);
diff --git a/libc/str/iswupper_l.c b/libc/str/iswupper_l.c
deleted file mode 100644
index 517eb31c9..000000000
--- a/libc/str/iswupper_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswupper_l(wint_t c, locale_t l) {
- return iswupper(c);
-}
diff --git a/libc/str/iswxdigit.c b/libc/str/iswxdigit.c
index 5abc42c37..dd697b03b 100644
--- a/libc/str/iswxdigit.c
+++ b/libc/str/iswxdigit.c
@@ -25,3 +25,5 @@ int iswxdigit(wint_t c) {
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
('a' <= c && c <= 'f');
}
+
+__weak_reference(iswxdigit, iswxdigit_l);
diff --git a/libc/str/iswxdigit_l.c b/libc/str/iswxdigit_l.c
deleted file mode 100644
index f7fb95fbd..000000000
--- a/libc/str/iswxdigit_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int iswxdigit_l(wint_t c, locale_t l) {
- return iswxdigit(c);
-}
diff --git a/libc/str/isxdigit.c b/libc/str/isxdigit.c
index 2aae1c040..190c7eadf 100644
--- a/libc/str/isxdigit.c
+++ b/libc/str/isxdigit.c
@@ -28,3 +28,5 @@ int isxdigit(int c) {
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
('a' <= c && c <= 'f');
}
+
+__weak_reference(isxdigit, isxdigit_l);
diff --git a/libc/str/isxdigit_l.c b/libc/str/isxdigit_l.c
deleted file mode 100644
index 1cc1214e4..000000000
--- a/libc/str/isxdigit_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int isxdigit_l(int c, locale_t l) {
- return iswxdigit(c);
-}
diff --git a/libc/str/rindex.S b/libc/str/rindex.S
deleted file mode 100644
index c90367706..000000000
--- a/libc/str/rindex.S
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
-│vi: set et ft=asm ts=8 tw=8 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/macros.internal.h"
-
-// Returns pointer to last instance of character the BSD way.
-//
-// @param rdi is a non-null NUL-terminated string pointer
-// @param esi is the search byte
-// @return rax points to result, or NULL if not found
-rindex: jmp strrchr
- .endfn rindex,globl
diff --git a/libc/str/strcasecmp.c b/libc/str/strcasecmp.c
index cc05da1ec..70e06e8ab 100644
--- a/libc/str/strcasecmp.c
+++ b/libc/str/strcasecmp.c
@@ -63,3 +63,5 @@ noasan int strcasecmp(const char *a, const char *b) {
return x - y;
}
}
+
+__weak_reference(strcasecmp, strcasecmp_l);
diff --git a/libc/str/strcasecmp_l.c b/libc/str/strcasecmp_l.c
deleted file mode 100644
index 607ed4fa1..000000000
--- a/libc/str/strcasecmp_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int strcasecmp_l(const char *a, const char *b, locale_t l) {
- return strcasecmp(a, b);
-}
diff --git a/libc/str/strcoll.c b/libc/str/strcoll.c
index aaeb9e164..b7445fa90 100644
--- a/libc/str/strcoll.c
+++ b/libc/str/strcoll.c
@@ -24,3 +24,5 @@
int strcoll(const char *p, const char *q) {
return strcmp(p, q);
}
+
+__weak_reference(strcoll, strcoll_l);
diff --git a/libc/str/strcoll_l.c b/libc/str/strcoll_l.c
deleted file mode 100644
index 4509e2654..000000000
--- a/libc/str/strcoll_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int strcoll_l(const char *p, const char *q, locale_t l) {
- return strcmp(p, q);
-}
diff --git a/libc/str/strncasecmp.c b/libc/str/strncasecmp.c
index f63658d01..d82c5296e 100644
--- a/libc/str/strncasecmp.c
+++ b/libc/str/strncasecmp.c
@@ -37,3 +37,5 @@ int strncasecmp(const char *a, const char *b, size_t n) {
}
return x - y;
}
+
+__weak_reference(strncasecmp, strncasecmp_l);
diff --git a/libc/str/strncasecmp_l.c b/libc/str/strncasecmp_l.c
deleted file mode 100644
index 782313b2e..000000000
--- a/libc/str/strncasecmp_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int strncasecmp_l(const char *a, const char *b, size_t n, locale_t l) {
- return strncasecmp(a, b, n);
-}
diff --git a/libc/str/strxfrm.c b/libc/str/strxfrm.c
index 1a28b2610..ff665250f 100644
--- a/libc/str/strxfrm.c
+++ b/libc/str/strxfrm.c
@@ -45,3 +45,5 @@ size_t strxfrm(char *dest, const char *src, size_t count) {
_unassert(dest == NULL ? count == 0 : 1);
return strlcpy(dest, src, count);
}
+
+__weak_reference(strxfrm, strxfrm_l);
diff --git a/libc/str/strxfrm_l.c b/libc/str/strxfrm_l.c
deleted file mode 100644
index 6672189f1..000000000
--- a/libc/str/strxfrm_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-size_t strxfrm_l(char *dest, const char *src, size_t count, locale_t l) {
- return strxfrm(dest, src, count);
-}
diff --git a/libc/str/toascii.c b/libc/str/toascii.c
index e631a798c..acf7b039c 100644
--- a/libc/str/toascii.c
+++ b/libc/str/toascii.c
@@ -21,3 +21,5 @@
int toascii(int c) {
return c & 127;
}
+
+__weak_reference(toascii, toascii_l);
diff --git a/libc/str/tolower.c b/libc/str/tolower.c
index 7b0d7b8ae..91956e17b 100644
--- a/libc/str/tolower.c
+++ b/libc/str/tolower.c
@@ -24,3 +24,5 @@
int tolower(int c) {
return 'A' <= c && c <= 'Z' ? c + ('a' - 'A') : c;
}
+
+__weak_reference(tolower, tolower_l);
diff --git a/libc/str/tolower_l.c b/libc/str/tolower_l.c
deleted file mode 100644
index 91ad9fd0a..000000000
--- a/libc/str/tolower_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int tolower_l(int c, locale_t l) {
- return tolower(c);
-}
diff --git a/libc/str/toupper.c b/libc/str/toupper.c
index 28f4f21b3..e7ce4e1c8 100644
--- a/libc/str/toupper.c
+++ b/libc/str/toupper.c
@@ -24,3 +24,5 @@
int toupper(int c) {
return 'a' <= c && c <= 'z' ? c - ('a' - 'A') : c;
}
+
+__weak_reference(toupper, toupper_l);
diff --git a/libc/str/toupper_l.c b/libc/str/toupper_l.c
deleted file mode 100644
index 47fb05bd3..000000000
--- a/libc/str/toupper_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int toupper_l(int c, locale_t l) {
- return toupper(c);
-}
diff --git a/libc/str/towlower.c b/libc/str/towlower.c
index fcea20604..93cacfd9d 100644
--- a/libc/str/towlower.c
+++ b/libc/str/towlower.c
@@ -232,3 +232,5 @@ wint_t towlower(wint_t c) {
}
}
}
+
+__weak_reference(towlower, towlower_l);
diff --git a/libc/str/towlower_l.c b/libc/str/towlower_l.c
deleted file mode 100644
index 0f9bd9ca0..000000000
--- a/libc/str/towlower_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-wint_t towlower_l(wint_t c, locale_t l) {
- return towlower(c);
-}
diff --git a/libc/str/towupper.c b/libc/str/towupper.c
index 26126f505..791d425b4 100644
--- a/libc/str/towupper.c
+++ b/libc/str/towupper.c
@@ -195,3 +195,5 @@ wint_t towupper(wint_t c) {
}
}
}
+
+__weak_reference(towupper, towupper_l);
diff --git a/libc/str/towupper_l.c b/libc/str/towupper_l.c
deleted file mode 100644
index f8498db9b..000000000
--- a/libc/str/towupper_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-wint_t towupper_l(wint_t c, locale_t l) {
- return towupper(c);
-}
diff --git a/libc/str/wcscmp.c b/libc/str/wcscmp.c
index 2a39814b1..3a0f49e57 100644
--- a/libc/str/wcscmp.c
+++ b/libc/str/wcscmp.c
@@ -32,3 +32,6 @@ int wcscmp(const wchar_t *a, const wchar_t *b) {
while (a[i] == b[i] && b[i]) ++i;
return (int)a[i] < (int)b[i] ? -1 : (int)a[i] > (int)b[i];
}
+
+__weak_reference(wcscmp, wcscoll);
+__weak_reference(wcscmp, wcscoll_l);
diff --git a/libc/str/wcscoll_l.c b/libc/str/wcscoll_l.c
deleted file mode 100644
index a4e5e27f6..000000000
--- a/libc/str/wcscoll_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-int wcscoll_l(const wchar_t *p, const wchar_t *q, locale_t l) {
- return wcscmp(p, q);
-}
diff --git a/libc/str/wcsxfrm.c b/libc/str/wcsxfrm.c
index 28a96d245..35d6d79f4 100644
--- a/libc/str/wcsxfrm.c
+++ b/libc/str/wcsxfrm.c
@@ -29,3 +29,5 @@ size_t wcsxfrm(wchar_t *d, const wchar_t *s, size_t n) {
}
return m;
}
+
+__weak_reference(wcsxfrm, wcsxfrm_l);
diff --git a/libc/str/wcsxfrm_l.c b/libc/str/wcsxfrm_l.c
deleted file mode 100644
index 9c11f6869..000000000
--- a/libc/str/wcsxfrm_l.c
+++ /dev/null
@@ -1,24 +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/str/locale.h"
-#include "libc/str/str.h"
-
-size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t count, locale_t l) {
- return wcsxfrm(dest, src, count);
-}
diff --git a/libc/time/struct/tm.h b/libc/time/struct/tm.h
index c682aec01..945d5926f 100644
--- a/libc/time/struct/tm.h
+++ b/libc/time/struct/tm.h
@@ -19,8 +19,6 @@ struct tm {
char *asctime(const struct tm *);
char *asctime_r(const struct tm *, char[hasatleast 26]);
-char *iso8601(char[hasatleast 20], struct tm *);
-char *iso8601us(char[hasatleast 27], struct tm *, long);
char *strptime(const char *, const char *, struct tm *);
int64_t mktime(struct tm *);
int64_t timegm(struct tm *);
@@ -34,6 +32,13 @@ struct tm *gmtime_r(const int64_t *, struct tm *);
struct tm *localtime(const int64_t *);
struct tm *localtime_r(const int64_t *, struct tm *);
+#ifdef COSMO
+#define iso8601 __iso8601
+#define iso8601us __iso8601us
+char *iso8601(char[hasatleast 20], struct tm *);
+char *iso8601us(char[hasatleast 27], struct tm *, long);
+#endif /* COSMO */
+
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ */
diff --git a/libc/x/x.h b/libc/x/x.h
index ae4a07cab..0c5e4ed03 100644
--- a/libc/x/x.h
+++ b/libc/x/x.h
@@ -2,6 +2,44 @@
#define COSMOPOLITAN_LIBC_X_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
+#ifdef COSMO
+
+#define xwrite __xwrite
+#define xdie __xdie
+#define xdtoa __xdtoa
+#define xdtoaf __xdtoaf
+#define xdtoal __xdtoal
+#define xmalloc __xmalloc
+#define xrealloc __xrealloc
+#define xcalloc __xcalloc
+#define xvalloc __xvalloc
+#define xmemalign __xmemalign
+#define xmemalignzero __xmemalignzero
+#define xstrdup __xstrdup
+#define xstrndup __xstrndup
+#define xstrmul __xstrmul
+#define xinet_ntop __xinet_ntop
+#define xunbinga __xunbinga
+#define xunbing __xunbing
+#define utf8to16 __utf8to16
+#define utf16to8 __utf16to8
+#define utf8to32 __utf8to32
+#define utf16to32 __utf16to32
+#define utf32to8 __utf32to8
+#define xhomedir __xhomedir
+#define xstripext __xstripext
+#define xstripexts __xstripexts
+#define xload __xload
+#define xloadzd __xloadzd
+#define rmrf __rmrf
+#define xbasename __xbasename
+#define xdirname __xdirname
+#define xjoinpaths __xjoinpaths
+#define xreadlink __xreadlink
+#define xreadlinkat __xreadlinkat
+#define xfixpath __xfixpath
+#define xslurp __xslurp
+#define xbarf __xbarf
int xwrite(int, const void *, uint64_t);
void xdie(void) wontreturn;
@@ -68,6 +106,7 @@ void *xslurp(const char *, size_t *)
returnsaligned((PAGESIZE)) dontdiscard;
int xbarf(const char *, const void *, size_t);
+#endif /* COSMO */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_X_H_ */
diff --git a/libc/x/xbarf.c b/libc/x/xbarf.c
index 9041dca8d..e6c6d9ed6 100644
--- a/libc/x/xbarf.c
+++ b/libc/x/xbarf.c
@@ -21,6 +21,7 @@
#include "libc/str/str.h"
#include "libc/sysv/consts/madv.h"
#include "libc/sysv/consts/o.h"
+#include "libc/x/x.h"
/**
* Writes data to file.
diff --git a/libc/x/xslurp.c b/libc/x/xslurp.c
index b43cf2f87..1a1a85e6b 100644
--- a/libc/x/xslurp.c
+++ b/libc/x/xslurp.c
@@ -23,6 +23,7 @@
#include "libc/runtime/runtime.h"
#include "libc/sysv/consts/madv.h"
#include "libc/sysv/consts/o.h"
+#include "libc/x/x.h"
/**
* Reads entire file into memory.
diff --git a/test/libc/fmt/lengthuint64_test.c b/test/libc/fmt/lengthuint64_test.c
index fbc8b1605..bbfd93fba 100644
--- a/test/libc/fmt/lengthuint64_test.c
+++ b/test/libc/fmt/lengthuint64_test.c
@@ -95,10 +95,10 @@ TEST(LengthInt64Thousands, test) {
}
BENCH(LengthInt64, bench) {
- unsigned LengthInt64_(int64_t) asm("LengthInt64");
- unsigned LengthUint64_(uint64_t) asm("LengthUint64");
- unsigned LengthInt64Thousands_(int64_t) asm("LengthInt64Thousands");
- unsigned LengthUint64Thousands_(uint64_t) asm("LengthUint64Thousands");
+ unsigned LengthInt64_(int64_t) asm("__LengthInt64");
+ unsigned LengthUint64_(uint64_t) asm("__LengthUint64");
+ unsigned LengthInt64Thousands_(int64_t) asm("__LengthInt64Thousands");
+ unsigned LengthUint64Thousands_(uint64_t) asm("__LengthUint64Thousands");
EZBENCH2("LengthInt64", donothing, LengthInt64_(INT64_MIN));
EZBENCH2("LengthUint64", donothing, LengthUint64_(UINT64_MAX));
EZBENCH2("LengthInt64Thousands", donothing, LengthInt64Thousands_(INT64_MIN));
diff --git a/third_party/make/ar.c b/third_party/make/ar.c
index 9bf476220..696647305 100644
--- a/third_party/make/ar.c
+++ b/third_party/make/ar.c
@@ -193,7 +193,7 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
if (fnmatch (state->pattern, mem, FNM_PATHNAME|FNM_PERIOD) == 0)
{
/* We have a match. Add it to the chain. */
- struct nameseq *new = xcalloc (state->size);
+ struct nameseq *new = xcalloc (1, state->size);
new->name = strcache_add(concat(4, state->arname, "(", mem, ")"));
new->next = state->chain;
state->chain = new;
diff --git a/third_party/make/dep.h b/third_party/make/dep.h
index b816ff62c..a5237b550 100644
--- a/third_party/make/dep.h
+++ b/third_party/make/dep.h
@@ -15,6 +15,7 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see . */
+#include "libc/x/x.h"
/* Structure used in chains of names, for parsing and globbing. */
@@ -98,7 +99,7 @@ struct nameseq *ar_glob (const char *arname, const char *member_pattern, size_t
#define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)
-#define alloc_seq_elt(_t) xcalloc (sizeof (_t))
+#define alloc_seq_elt(_t) xcalloc (1, sizeof (_t))
void free_ns_chain (struct nameseq *n);
#if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__) && !defined(__STRICT_ANSI__)
diff --git a/third_party/make/dir.c b/third_party/make/dir.c
index 37e22820f..363e957de 100644
--- a/third_party/make/dir.c
+++ b/third_party/make/dir.c
@@ -17,6 +17,7 @@ this program. If not, see . */
#include "third_party/make/makeint.inc"
/**/
#include "libc/calls/struct/dirent.h"
+#include "libc/x/x.h"
#include "third_party/make/dep.h"
#include "third_party/make/filedef.h"
#include "third_party/make/hash.h"
@@ -584,7 +585,7 @@ void file_impossible(const char *filename) {
if (dir->contents == 0)
/* The directory could not be stat'd. We allocate a contents
structure for it, but leave it out of the contents hash table. */
- dir->contents = xcalloc(sizeof(struct directory_contents));
+ dir->contents = xcalloc(1, sizeof(struct directory_contents));
if (dir->contents->dirfiles.ht_vec == 0) {
hash_init(&dir->contents->dirfiles, DIRFILE_BUCKETS, dirfile_hash_1,
diff --git a/third_party/make/expand.c b/third_party/make/expand.c
index 713acd6a9..dec21e2fd 100644
--- a/third_party/make/expand.c
+++ b/third_party/make/expand.c
@@ -21,6 +21,7 @@ this program. If not, see . */
#include "third_party/make/job.h"
#include "third_party/make/commands.h"
#include "third_party/make/variable.h"
+#include "libc/x/x.h"
#include "third_party/make/rule.h"
/* Initially, any errors reported when expanding strings will be reported
diff --git a/third_party/make/file.c b/third_party/make/file.c
index 64c19216d..010ce1265 100644
--- a/third_party/make/file.c
+++ b/third_party/make/file.c
@@ -130,7 +130,7 @@ enter_file (const char *name)
return f;
}
- new = xcalloc (sizeof (struct file));
+ new = xcalloc (1, sizeof (struct file));
new->name = new->hname = name;
new->update_status = us_none;
diff --git a/third_party/make/hash.c b/third_party/make/hash.c
index 798edb5a6..d2e321418 100644
--- a/third_party/make/hash.c
+++ b/third_party/make/hash.c
@@ -21,10 +21,11 @@ this program. If not, see . */
#include "libc/intrin/bsr.h"
#include "libc/intrin/likely.h"
#include "libc/log/check.h"
+#include "libc/x/x.h"
#include "third_party/make/hash.h"
/* clang-format off */
-#define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
+#define CALLOC(t, n) ((t *) xcalloc (1, sizeof (t) * (n)))
#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
#define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
#define CLONE(o, t, n) ((t *) memcpy (MALLOC (t, (n)), (o), sizeof (t) * (n)))
diff --git a/third_party/make/job.c b/third_party/make/job.c
index e0bf03a19..29ae16217 100644
--- a/third_party/make/job.c
+++ b/third_party/make/job.c
@@ -1315,7 +1315,7 @@ new_job (struct file *file)
/* Start the command sequence, record it in a new
'struct child', and add that to the chain. */
- c = xcalloc (sizeof (struct child));
+ c = xcalloc (1, sizeof (struct child));
output_init (&c->output);
c->file = file;
diff --git a/third_party/make/makeint.inc b/third_party/make/makeint.inc
index 192e84fa4..3f5ca5f14 100644
--- a/third_party/make/makeint.inc
+++ b/third_party/make/makeint.inc
@@ -50,7 +50,6 @@ this program. If not, see . */
#include "libc/sysv/consts/w.h"
#include "libc/time/struct/tm.h"
#include "libc/time/time.h"
-#include "libc/x/x.h"
#include "third_party/gdtoa/gdtoa.h"
#include "third_party/musl/glob.h"
/* clang-format off */
@@ -395,8 +394,6 @@ void pfatal_with_name (const char *) NORETURN;
void perror_with_name (const char *, const char *);
#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
void *xmalloc (size_t);
-// void *xcalloc (size_t);
-#define xcalloc(size) ((xcalloc)(1, (size)))
void *xrealloc (void *, size_t);
char *xstrdup (const char *);
char *xstrndup (const char *, size_t);
diff --git a/third_party/make/read.c b/third_party/make/read.c
index ddf8da149..3e67ee375 100644
--- a/third_party/make/read.c
+++ b/third_party/make/read.c
@@ -3121,7 +3121,7 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
struct nameseq **newp = &new;
#define NEWELT(_n) do { \
const char *__n = (_n); \
- *newp = xcalloc (size); \
+ *newp = xcalloc (1, size); \
(*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \
newp = &(*newp)->next; \
} while(0)
diff --git a/third_party/make/variable.c b/third_party/make/variable.c
index 7f7582bad..1097a3abe 100644
--- a/third_party/make/variable.c
+++ b/third_party/make/variable.c
@@ -47,7 +47,7 @@ struct pattern_var *
create_pattern_var (const char *target, const char *suffix)
{
size_t len = strlen (target);
- struct pattern_var *p = xcalloc (sizeof (struct pattern_var));
+ struct pattern_var *p = xcalloc (1, sizeof (struct pattern_var));
if (pattern_vars != 0)
{
@@ -235,7 +235,7 @@ define_variable_in_set (const char *name, size_t length,
/* Create a new variable definition and add it to the hash table. */
- v = xcalloc (sizeof (struct variable));
+ v = xcalloc (1, sizeof (struct variable));
v->name = xstrndup (name, length);
v->length = (unsigned int) length;
hash_insert_at (&set->table, v, var_slot);
diff --git a/third_party/sed/compile.c b/third_party/sed/compile.c
index f50e8c20b..f610c309c 100644
--- a/third_party/sed/compile.c
+++ b/third_party/sed/compile.c
@@ -164,7 +164,7 @@ compile(void)
fixuplabel(prog, NULL);
uselabel();
if (appendnum > 0)
- appends = xmalloc(sizeof(struct s_appends) * appendnum);
+ appends_ = xmalloc(sizeof(struct s_appends) * appendnum);
g_match = xmalloc((maxnsub + 1) * sizeof(regmatch_t));
}
diff --git a/third_party/sed/extern.h b/third_party/sed/extern.h
index c39caa36d..8fcb5f414 100644
--- a/third_party/sed/extern.h
+++ b/third_party/sed/extern.h
@@ -9,7 +9,7 @@ COSMOPOLITAN_C_START_
// clang-format off
extern struct s_command *prog;
-extern struct s_appends *appends;
+extern struct s_appends *appends_;
extern regmatch_t *g_match;
extern size_t maxnsub;
extern u_long linenum;
diff --git a/third_party/zip/osdep.h b/third_party/zip/osdep.h
index 90c58457e..c2dfca459 100644
--- a/third_party/zip/osdep.h
+++ b/third_party/zip/osdep.h
@@ -33,7 +33,6 @@
#include "libc/thread/thread.h"
#include "libc/calls/typedef/u.h"
#include "libc/calls/weirdtypes.h"
-#include "libc/intrin/newbie.h"
#include "libc/sock/select.h"
#include "libc/sysv/consts/endian.h"
#include "libc/calls/calls.h"
diff --git a/third_party/zip/unix.c b/third_party/zip/unix.c
index aac0d93dc..b815c35c5 100644
--- a/third_party/zip/unix.c
+++ b/third_party/zip/unix.c
@@ -702,7 +702,6 @@ char *d; /* directory to delete */
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__386BSD__) || \
defined(__OpenBSD__) || defined(__bsdi__)
-#include "libc/intrin/newbie.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/rlimit.h"
#include "libc/calls/struct/rusage.h"
diff --git a/tool/build/calculator.c b/tool/build/calculator.c
index ba146fd50..f1871005e 100644
--- a/tool/build/calculator.c
+++ b/tool/build/calculator.c
@@ -155,6 +155,19 @@ struct History history;
struct Value stack[128];
int sp, comment, line, column, interactive;
+uint32_t gray(uint32_t x) {
+ return x ^ (x >> 1);
+}
+
+uint32_t ungray(uint32_t x) {
+ x ^= x >> 16;
+ x ^= x >> 8;
+ x ^= x >> 4;
+ x ^= x >> 2;
+ x ^= x >> 1;
+ return x;
+}
+
INT Popcnt(INT x) {
uint128_t word = x;
return popcnt(word >> 64) + popcnt(word);
diff --git a/tool/emacs/cosmo-asm-mode.el b/tool/emacs/cosmo-asm-mode.el
index 26ea86309..580fa0b01 100644
--- a/tool/emacs/cosmo-asm-mode.el
+++ b/tool/emacs/cosmo-asm-mode.el
@@ -57,6 +57,7 @@
"gottpoff"
"function"
"object"
+ "notype"
"got"
"size"
"gotoff"