mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Release Cosmopolitan v3.3
This change upgrades to GCC 12.3 and GNU binutils 2.42. The GNU linker appears to have changed things so that only a single de-duplicated str table is present in the binary, and it gets placed wherever the linker wants, regardless of what the linker script says. To cope with that we need to stop using .ident to embed licenses. As such, this change does significant work to revamp how third party licenses are defined in the codebase, using `.section .notice,"aR",@progbits`. This new GCC 12.3 toolchain has support for GNU indirect functions. It lets us support __target_clones__ for the first time. This is used for optimizing the performance of libc string functions such as strlen and friends so far on x86, by ensuring AVX systems favor a second codepath that uses VEX encoding. It shaves some latency off certain operations. It's a useful feature to have for scientific computing for the reasons explained by the test/libcxx/openmp_test.cc example which compiles for fifteen different microarchitectures. Thanks to the upgrades, it's now also possible to use newer instruction sets, such as AVX512FP16, VNNI. Cosmo now uses the %gs register on x86 by default for TLS. Doing it is helpful for any program that links `cosmo_dlopen()`. Such programs had to recompile their binaries at startup to change the TLS instructions. That's not great, since it means every page in the executable needs to be faulted. The work of rewriting TLS-related x86 opcodes, is moved to fixupobj.com instead. This is great news for MacOS x86 users, since we previously needed to morph the binary every time for that platform but now that's no longer necessary. The only platforms where we need fixup of TLS x86 opcodes at runtime are now Windows, OpenBSD, and NetBSD. On Windows we morph TLS to point deeper into the TIB, based on a TlsAlloc assignment, and on OpenBSD/NetBSD we morph %gs back into %fs since the kernels do not allow us to specify a value for the %gs register. OpenBSD users are now required to use APE Loader to run Cosmo binaries and assimilation is no longer possible. OpenBSD kernel needs to change to allow programs to specify a value for the %gs register, or it needs to stop marking executable pages loaded by the kernel as mimmutable(). This release fixes __constructor__, .ctor, .init_array, and lastly the .preinit_array so they behave the exact same way as glibc. We no longer use hex constants to define math.h symbols like M_PI.
This commit is contained in:
parent
d3ff48c63f
commit
957c61cbbf
736 changed files with 13726 additions and 9445 deletions
|
@ -73,12 +73,10 @@ $(LIBC_CALLS_A_OBJS): private \
|
|||
-Wframe-larger-than=4096 \
|
||||
-Walloca-larger-than=4096
|
||||
|
||||
ifneq ($(ARCH), aarch64)
|
||||
# we always want -O3 because:
|
||||
# it makes the code size smaller too
|
||||
# we need -mstringop-strategy=loop because:
|
||||
# privileged code might generate memcpy call
|
||||
o/$(MODE)/libc/calls/termios2host.o \
|
||||
o/$(MODE)/libc/calls/siginfo2cosmo.o \
|
||||
o/$(MODE)/libc/calls/sigenter-freebsd.o \
|
||||
o/$(MODE)/libc/calls/sigenter-netbsd.o \
|
||||
o/$(MODE)/libc/calls/sigenter-openbsd.o \
|
||||
|
@ -86,6 +84,19 @@ o/$(MODE)/libc/calls/sigenter-xnu.o \
|
|||
o/$(MODE)/libc/calls/ntcontext2linux.o: private \
|
||||
COPTS += \
|
||||
-O3 \
|
||||
-ffreestanding
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
# we need -mstringop-strategy=loop because:
|
||||
# privileged code might generate memcpy call
|
||||
o/$(MODE)/libc/calls/termios2host.o \
|
||||
o/$(MODE)/libc/calls/siginfo2cosmo.o \
|
||||
o/$(MODE)/libc/calls/sigenter-freebsd.o \
|
||||
o/$(MODE)/libc/calls/sigenter-netbsd.o \
|
||||
o/$(MODE)/libc/calls/sigenter-openbsd.o \
|
||||
o/$(MODE)/libc/calls/sigenter-xnu.o \
|
||||
o/$(MODE)/libc/calls/ntcontext2linux.o: private \
|
||||
COPTS += \
|
||||
-mstringop-strategy=loop
|
||||
endif
|
||||
|
||||
|
|
|
@ -87,13 +87,9 @@ textwindows int sys_clock_gettime_nt(int clock, struct timespec *ts) {
|
|||
}
|
||||
}
|
||||
|
||||
static textstartup void winclock_init() {
|
||||
__attribute__((__constructor__(40))) static textstartup void winclock_init() {
|
||||
if (IsWindows()) {
|
||||
QueryPerformanceCounter(&g_winclock.base);
|
||||
QueryPerformanceFrequency(&g_winclock.freq);
|
||||
}
|
||||
}
|
||||
|
||||
const void *const winclock_ctor[] initarray = {
|
||||
winclock_init,
|
||||
};
|
||||
|
|
|
@ -32,11 +32,8 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
static void __procfdname(char *buf, unsigned fd) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "libc/elf/tinyelf.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/directmap.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/nt/memory.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -59,7 +59,7 @@ textwindows int sys_getloadavg_nt(double *a, int n) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
static textstartup void sys_getloadavg_nt_init(void) {
|
||||
__attribute__((__constructor__(40))) static textstartup void ntinitload(void) {
|
||||
if (IsWindows()) {
|
||||
load = 1;
|
||||
cpus = __get_cpu_count() / 2;
|
||||
|
@ -67,7 +67,3 @@ static textstartup void sys_getloadavg_nt_init(void) {
|
|||
GetSystemTimes(&idle1, &kern1, &user1);
|
||||
}
|
||||
}
|
||||
|
||||
const void *const sys_getloadavg_nt_ctor[] initarray = {
|
||||
sys_getloadavg_nt_init,
|
||||
};
|
||||
|
|
|
@ -190,7 +190,8 @@ ssize_t getrandom(void *p, size_t n, unsigned f) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static textstartup void getrandom_init(void) {
|
||||
__attribute__((__constructor__(30))) static textstartup void getrandom_init(
|
||||
void) {
|
||||
int e, rc;
|
||||
if (IsWindows() || IsMetal()) return;
|
||||
BLOCK_CANCELATION;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
char *program_invocation_short_name;
|
||||
|
||||
__attribute__((__constructor__)) static void //
|
||||
__attribute__((__constructor__(10))) static textstartup void
|
||||
program_invocation_short_name_init(void) {
|
||||
char *p, *r;
|
||||
if (!__argc) return;
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "libc/nexgen32e/x86info.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
|
||||
textstartup void rdrand_init(int argc, char **argv, char **envp,
|
||||
intptr_t *auxv) {
|
||||
__attribute__((__constructor__(2))) textstartup void rdrand_init(
|
||||
int argc, char **argv, char **envp, intptr_t *auxv) {
|
||||
extern unsigned kMutableCpuids[KCPUIDS_LEN][4] asm("kCpuids");
|
||||
/*
|
||||
* Clear RDRAND on AMD models before Zen and then some
|
||||
|
@ -39,5 +39,3 @@ textstartup void rdrand_init(int argc, char **argv, char **envp,
|
|||
kMutableCpuids[KCPUIDS_7H][KCPUIDS_EBX] &= ~(1u << 18);
|
||||
}
|
||||
}
|
||||
|
||||
const void *const g_rdrand_init[] initarray = {rdrand_init};
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "libc/intrin/bsf.h"
|
||||
#include "libc/intrin/describebacktrace.internal.h"
|
||||
#include "libc/intrin/dll.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/nt/console.h"
|
||||
|
@ -517,6 +518,15 @@ static int __sig_crash_sig(struct NtExceptionPointers *ep, int *code) {
|
|||
}
|
||||
}
|
||||
|
||||
static char *__sig_stpcpy(char *d, const char *s) {
|
||||
size_t i;
|
||||
for (i = 0;; ++i) {
|
||||
if (!(d[i] = s[i])) {
|
||||
return d + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void __sig_unmaskable(struct NtExceptionPointers *ep, int code, int sig,
|
||||
struct CosmoTib *tib) {
|
||||
|
||||
|
@ -540,9 +550,10 @@ static void __sig_unmaskable(struct NtExceptionPointers *ep, int code, int sig,
|
|||
intptr_t hStderr;
|
||||
char sigbuf[21], s[128], *p;
|
||||
hStderr = GetStdHandle(kNtStdErrorHandle);
|
||||
p = stpcpy(s, "Terminating on uncaught ");
|
||||
p = stpcpy(p, strsignal_r(sig, sigbuf));
|
||||
p = stpcpy(p, ". Pass --strace and/or ShowCrashReports() for details.\n");
|
||||
p = __sig_stpcpy(s, "Terminating on uncaught ");
|
||||
p = __sig_stpcpy(p, strsignal_r(sig, sigbuf));
|
||||
p = __sig_stpcpy(
|
||||
p, ". Pass --strace and/or ShowCrashReports() for details.\n");
|
||||
WriteFile(hStderr, s, p - s, 0, 0);
|
||||
#endif
|
||||
__sig_terminate(sig);
|
||||
|
@ -656,12 +667,10 @@ textwindows int __sig_check(void) {
|
|||
}
|
||||
}
|
||||
|
||||
textstartup void __sig_init(void) {
|
||||
__attribute__((__constructor__(10))) textstartup void __sig_init(void) {
|
||||
if (!IsWindows()) return;
|
||||
AddVectoredExceptionHandler(true, (void *)__sig_crash);
|
||||
SetConsoleCtrlHandler((void *)__sig_console, true);
|
||||
}
|
||||
|
||||
const void *const __sig_ctor[] initarray = {__sig_init};
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -100,7 +100,7 @@ static const struct sock_filter kUnveilBlacklistLatestAbi[] = {
|
|||
static int landlock_abi_version;
|
||||
static int landlock_abi_errno;
|
||||
|
||||
__attribute__((__constructor__)) void init_landlock_version() {
|
||||
__attribute__((__constructor__(40))) textstartup void init_landlock_version() {
|
||||
int e = errno;
|
||||
landlock_abi_version =
|
||||
landlock_create_ruleset(0, 0, LANDLOCK_CREATE_RULESET_VERSION);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
.section .start,"ax",@progbits
|
||||
|
||||
#if SupportsXnu() && defined(__x86_64__)
|
||||
|
|
|
@ -920,17 +920,3 @@ char *cosmo_dlerror(void) {
|
|||
STRACE("dlerror() → %#s", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
static textstartup void dlopen_init() {
|
||||
if (IsLinux() || IsFreebsd()) {
|
||||
// switch from %fs to %gs for tls
|
||||
struct CosmoTib *tib = __get_tls();
|
||||
__morph_tls();
|
||||
__set_tls(tib);
|
||||
}
|
||||
}
|
||||
const void *const dlopen_ctor[] initarray = {
|
||||
dlopen_init,
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,7 @@ foreign_tramp:
|
|||
mov %rax,-0xc0(%rbp)
|
||||
|
||||
// switch to foreign tls
|
||||
mov %fs:0,%rax
|
||||
mov %gs:0x30,%rax
|
||||
mov %rax,-0xc8(%rbp)
|
||||
mov __foreign+8(%rip),%rdi
|
||||
call __set_tls
|
||||
|
|
|
@ -639,12 +639,6 @@ void abort(void) wontreturn;
|
|||
#define _Section(s) __attribute__((__section__(s)))
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) && !defined(__llvm__)
|
||||
#define initarray _Section(".init_array,\"a\",@init_array #")
|
||||
#else
|
||||
#define initarray _Section(".init_array")
|
||||
#endif
|
||||
|
||||
#ifndef __llvm__
|
||||
#pragma GCC diagnostic ignored "-Wformat=0" /* todo: patch gcc */
|
||||
#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
|
||||
|
@ -758,17 +752,21 @@ void abort(void) wontreturn;
|
|||
#endif
|
||||
|
||||
#if defined(__x86_64__) && (defined(__GNUC__) || defined(__llvm__)) && \
|
||||
!defined(__chibicc__) && 0 /* TODO: enable with toolchain upgrade */
|
||||
!defined(__chibicc__) && defined(__OPTIMIZE__)
|
||||
#define __target_clones(x) __attribute__((__target_clones__(x ",default")))
|
||||
#else
|
||||
#define __target_clones(x)
|
||||
#endif
|
||||
|
||||
#if !defined(TINY) && !defined(__AVX__) && 0
|
||||
#if !defined(TINY) && !defined(__AVX__)
|
||||
#define __vex __target_clones("avx")
|
||||
#else
|
||||
#define __vex
|
||||
#endif
|
||||
|
||||
#define __notice(sym, str) \
|
||||
__attribute__((__section__(".notice"), __aligned__(1))) const char sym[] = \
|
||||
"\n\n" str
|
||||
|
||||
#define MACHINE_CODE_ANALYSIS_BEGIN_
|
||||
#define MACHINE_CODE_ANALYSIS_END_
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#endif
|
||||
|
||||
#define __COSMOPOLITAN_MAJOR__ 3
|
||||
#define __COSMOPOLITAN_MINOR__ 2
|
||||
#define __COSMOPOLITAN_PATCH__ 4
|
||||
#define __COSMOPOLITAN_MINOR__ 3
|
||||
#define __COSMOPOLITAN_PATCH__ 0
|
||||
#define __COSMOPOLITAN__ \
|
||||
(100000000 * __COSMOPOLITAN_MAJOR__ + 1000000 * __COSMOPOLITAN_MINOR__ + \
|
||||
__COSMOPOLITAN_PATCH__)
|
||||
|
|
|
@ -74,11 +74,15 @@ o//libc/intrin/memmove.o: private \
|
|||
-fno-toplevel-reorder
|
||||
|
||||
o//libc/intrin/bzero.o \
|
||||
o//libc/intrin/strlen.o \
|
||||
o//libc/intrin/strchr.o \
|
||||
o//libc/intrin/memchr.o \
|
||||
o//libc/intrin/memrchr.o \
|
||||
o//libc/intrin/memcmp.o \
|
||||
o//libc/intrin/memset.o \
|
||||
o//libc/intrin/memmove.o: private \
|
||||
CFLAGS += \
|
||||
-O2 -finline
|
||||
-O2 -finline -foptimize-sibling-calls
|
||||
|
||||
o/$(MODE)/libc/intrin/bzero.o \
|
||||
o/$(MODE)/libc/intrin/memcmp.o \
|
||||
|
@ -89,7 +93,9 @@ o/$(MODE)/libc/intrin/memmove.o: private \
|
|||
o/$(MODE)/libc/intrin/x86.o: private \
|
||||
CFLAGS += \
|
||||
-ffreestanding \
|
||||
-fno-jump-tables
|
||||
-fno-jump-tables \
|
||||
-fpatchable-function-entry=0 \
|
||||
-Os
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/libc/intrin/aarch64/%.o: libc/intrin/aarch64/%.S
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __memchr_aarch64 memchr
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64
|
||||
|
|
|
@ -26,15 +26,11 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __memcpy_aarch64_simd memcpy
|
||||
#define __memmove_aarch64_simd memmove
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __memrchr_aarch64 memrchr
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __memset_aarch64 memset
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __stpcpy_aarch64 stpcpy
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD.
|
||||
|
|
|
@ -26,15 +26,11 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strchr_aarch64 strchr
|
||||
#define __index_aarch64 index
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strchrnul_aarch64 strchrnul
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strcmp_aarch64 strcmp
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strcpy_aarch64 strcpy
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strlen_aarch64 strlen
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strncmp_aarch64 strncmp
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64.
|
||||
|
|
|
@ -26,14 +26,10 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strnlen_aarch64 strnlen
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64, Advanced SIMD.
|
||||
|
|
|
@ -26,15 +26,11 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/aarch64/asmdefs.internal.h"
|
||||
.yoink arm_optimized_routines_notice
|
||||
|
||||
#define __strrchr_aarch64 strrchr
|
||||
#define __rindex_aarch64 rindex
|
||||
|
||||
.ident "\n\n\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
|
||||
/* Assumptions:
|
||||
*
|
||||
* ARMv8-a, AArch64
|
||||
|
|
3
libc/intrin/armopt.c
Normal file
3
libc/intrin/armopt.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
__notice(arm_optimized_routines_notice, "\
|
||||
Optimized Routines (MIT License)\n\
|
||||
Copyright 2022 ARM Limited");
|
3
libc/intrin/chromium.c
Normal file
3
libc/intrin/chromium.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
__notice(chromium_notice, "\
|
||||
Chromium (BSD-3 License)\n\
|
||||
Copyright 2017 The Chromium Authors");
|
|
@ -33,10 +33,6 @@ void __cxa_unlock(void) {
|
|||
pthread_mutex_unlock(&__cxa_lock_obj);
|
||||
}
|
||||
|
||||
static textstartup void __cxa_init() {
|
||||
__attribute__((__constructor__(60))) static textstartup void __cxa_init() {
|
||||
pthread_atfork(__cxa_lock, __cxa_unlock, __cxa_wipe);
|
||||
}
|
||||
|
||||
const void *const __cxa_ctor[] initarray = {
|
||||
__cxa_init,
|
||||
};
|
||||
|
|
4
libc/intrin/fblibm.c
Normal file
4
libc/intrin/fblibm.c
Normal file
|
@ -0,0 +1,4 @@
|
|||
__notice(freebsd_libm_notice, "FreeBSD libm (BSD-2 License)\n\
|
||||
Copyright (c) 1992-2024 The FreeBSD Project.\n\
|
||||
Copyright (c) 2005-2011 Bruce D. Evans, Steven G. Kargl, David Schultz\n\
|
||||
Copyright (c) 2009-2013 Steven G. Kargl");
|
2
libc/intrin/fdlibm.c
Normal file
2
libc/intrin/fdlibm.c
Normal file
|
@ -0,0 +1,2 @@
|
|||
__notice(fdlibm_notice, "fdlibm (fdlibm license)\n\
|
||||
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.");
|
2
libc/intrin/folibm.c
Normal file
2
libc/intrin/folibm.c
Normal file
|
@ -0,0 +1,2 @@
|
|||
__notice(openbsd_libm_notice, "OpenBSD libm (ISC License)\n\
|
||||
Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>");
|
|
@ -30,10 +30,6 @@ bool32 IsRunningUnderMake(void) {
|
|||
return g_isrunningundermake;
|
||||
}
|
||||
|
||||
textstartup void g_isrunningundermake_init(void) {
|
||||
__attribute__((__constructor__(30))) textstartup void onmake_init(void) {
|
||||
g_isrunningundermake = !!getenv("MAKEFLAGS");
|
||||
}
|
||||
|
||||
const void *const g_isrunningundermake_ctor[] initarray = {
|
||||
g_isrunningundermake_init,
|
||||
};
|
||||
|
|
|
@ -36,8 +36,8 @@ static inline const unsigned char *memchr_pure(const unsigned char *s,
|
|||
}
|
||||
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
static inline const unsigned char *memchr_sse(const unsigned char *s,
|
||||
unsigned char c, size_t n) {
|
||||
static __vex const unsigned char *memchr_sse(const unsigned char *s,
|
||||
unsigned char c, size_t n) {
|
||||
size_t i;
|
||||
unsigned m;
|
||||
xmm_t v, t = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
|
||||
|
@ -67,11 +67,9 @@ static inline const unsigned char *memchr_sse(const unsigned char *s,
|
|||
* @return is pointer to first instance of c or NULL if not found
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
__vex void *memchr(const void *s, int c, size_t n) {
|
||||
void *memchr(const void *s, int c, size_t n) {
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const void *r;
|
||||
r = memchr_sse(s, c, n);
|
||||
return (void *)r;
|
||||
return (void *)memchr_sse(s, c, n);
|
||||
#else
|
||||
return (void *)memchr_pure(s, c, n);
|
||||
#endif
|
||||
|
|
|
@ -27,66 +27,7 @@
|
|||
typedef long long xmm_t __attribute__((__vector_size__(16), __aligned__(1)));
|
||||
typedef long long xmm_a __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
|
||||
/**
|
||||
* Copies memory.
|
||||
*
|
||||
* memmove n=0 661 picoseconds
|
||||
* memmove n=1 661 ps/byte 1,476 mb/s
|
||||
* memmove n=2 330 ps/byte 2,952 mb/s
|
||||
* memmove n=3 330 ps/byte 2,952 mb/s
|
||||
* memmove n=4 165 ps/byte 5,904 mb/s
|
||||
* memmove n=7 141 ps/byte 6,888 mb/s
|
||||
* memmove n=8 82 ps/byte 11 GB/s
|
||||
* memmove n=15 44 ps/byte 21 GB/s
|
||||
* memmove n=16 41 ps/byte 23 GB/s
|
||||
* memmove n=31 32 ps/byte 29 GB/s
|
||||
* memmove n=32 31 ps/byte 30 GB/s
|
||||
* memmove n=63 21 ps/byte 45 GB/s
|
||||
* memmove n=64 15 ps/byte 61 GB/s
|
||||
* memmove n=127 13 ps/byte 73 GB/s
|
||||
* memmove n=128 31 ps/byte 30 GB/s
|
||||
* memmove n=255 20 ps/byte 45 GB/s
|
||||
* memmove n=256 19 ps/byte 49 GB/s
|
||||
* memmove n=511 16 ps/byte 56 GB/s
|
||||
* memmove n=512 17 ps/byte 54 GB/s
|
||||
* memmove n=1023 18 ps/byte 52 GB/s
|
||||
* memmove n=1024 13 ps/byte 72 GB/s
|
||||
* memmove n=2047 9 ps/byte 96 GB/s
|
||||
* memmove n=2048 9 ps/byte 98 GB/s
|
||||
* memmove n=4095 8 ps/byte 112 GB/s
|
||||
* memmove n=4096 8 ps/byte 109 GB/s
|
||||
* memmove n=8191 7 ps/byte 124 GB/s
|
||||
* memmove n=8192 7 ps/byte 125 GB/s
|
||||
* memmove n=16383 7 ps/byte 134 GB/s
|
||||
* memmove n=16384 7 ps/byte 134 GB/s
|
||||
* memmove n=32767 13 ps/byte 72 GB/s
|
||||
* memmove n=32768 13 ps/byte 72 GB/s
|
||||
* memmove n=65535 13 ps/byte 68 GB/s
|
||||
* memmove n=65536 14 ps/byte 67 GB/s
|
||||
* memmove n=131071 14 ps/byte 65 GB/s
|
||||
* memmove n=131072 14 ps/byte 64 GB/s
|
||||
* memmove n=262143 15 ps/byte 63 GB/s
|
||||
* memmove n=262144 15 ps/byte 63 GB/s
|
||||
* memmove n=524287 15 ps/byte 61 GB/s
|
||||
* memmove n=524288 15 ps/byte 61 GB/s
|
||||
* memmove n=1048575 15 ps/byte 61 GB/s
|
||||
* memmove n=1048576 15 ps/byte 61 GB/s
|
||||
* memmove n=2097151 19 ps/byte 48 GB/s
|
||||
* memmove n=2097152 27 ps/byte 35 GB/s
|
||||
* memmove n=4194303 28 ps/byte 33 GB/s
|
||||
* memmove n=4194304 28 ps/byte 33 GB/s
|
||||
* memmove n=8388607 28 ps/byte 33 GB/s
|
||||
* memmove n=8388608 28 ps/byte 33 GB/s
|
||||
*
|
||||
* DST and SRC may overlap.
|
||||
*
|
||||
* @param dst is destination
|
||||
* @param src is memory to copy
|
||||
* @param n is number of bytes to copy
|
||||
* @return dst
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
__vex void *memmove(void *dst, const void *src, size_t n) {
|
||||
static __vex void *__memmove(void *dst, const void *src, size_t n) {
|
||||
char *d;
|
||||
size_t i;
|
||||
const char *s;
|
||||
|
@ -338,6 +279,69 @@ __vex void *memmove(void *dst, const void *src, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies memory.
|
||||
*
|
||||
* memmove n=0 661 picoseconds
|
||||
* memmove n=1 661 ps/byte 1,476 mb/s
|
||||
* memmove n=2 330 ps/byte 2,952 mb/s
|
||||
* memmove n=3 330 ps/byte 2,952 mb/s
|
||||
* memmove n=4 165 ps/byte 5,904 mb/s
|
||||
* memmove n=7 141 ps/byte 6,888 mb/s
|
||||
* memmove n=8 82 ps/byte 11 GB/s
|
||||
* memmove n=15 44 ps/byte 21 GB/s
|
||||
* memmove n=16 41 ps/byte 23 GB/s
|
||||
* memmove n=31 32 ps/byte 29 GB/s
|
||||
* memmove n=32 31 ps/byte 30 GB/s
|
||||
* memmove n=63 21 ps/byte 45 GB/s
|
||||
* memmove n=64 15 ps/byte 61 GB/s
|
||||
* memmove n=127 13 ps/byte 73 GB/s
|
||||
* memmove n=128 31 ps/byte 30 GB/s
|
||||
* memmove n=255 20 ps/byte 45 GB/s
|
||||
* memmove n=256 19 ps/byte 49 GB/s
|
||||
* memmove n=511 16 ps/byte 56 GB/s
|
||||
* memmove n=512 17 ps/byte 54 GB/s
|
||||
* memmove n=1023 18 ps/byte 52 GB/s
|
||||
* memmove n=1024 13 ps/byte 72 GB/s
|
||||
* memmove n=2047 9 ps/byte 96 GB/s
|
||||
* memmove n=2048 9 ps/byte 98 GB/s
|
||||
* memmove n=4095 8 ps/byte 112 GB/s
|
||||
* memmove n=4096 8 ps/byte 109 GB/s
|
||||
* memmove n=8191 7 ps/byte 124 GB/s
|
||||
* memmove n=8192 7 ps/byte 125 GB/s
|
||||
* memmove n=16383 7 ps/byte 134 GB/s
|
||||
* memmove n=16384 7 ps/byte 134 GB/s
|
||||
* memmove n=32767 13 ps/byte 72 GB/s
|
||||
* memmove n=32768 13 ps/byte 72 GB/s
|
||||
* memmove n=65535 13 ps/byte 68 GB/s
|
||||
* memmove n=65536 14 ps/byte 67 GB/s
|
||||
* memmove n=131071 14 ps/byte 65 GB/s
|
||||
* memmove n=131072 14 ps/byte 64 GB/s
|
||||
* memmove n=262143 15 ps/byte 63 GB/s
|
||||
* memmove n=262144 15 ps/byte 63 GB/s
|
||||
* memmove n=524287 15 ps/byte 61 GB/s
|
||||
* memmove n=524288 15 ps/byte 61 GB/s
|
||||
* memmove n=1048575 15 ps/byte 61 GB/s
|
||||
* memmove n=1048576 15 ps/byte 61 GB/s
|
||||
* memmove n=2097151 19 ps/byte 48 GB/s
|
||||
* memmove n=2097152 27 ps/byte 35 GB/s
|
||||
* memmove n=4194303 28 ps/byte 33 GB/s
|
||||
* memmove n=4194304 28 ps/byte 33 GB/s
|
||||
* memmove n=8388607 28 ps/byte 33 GB/s
|
||||
* memmove n=8388608 28 ps/byte 33 GB/s
|
||||
*
|
||||
* DST and SRC may overlap.
|
||||
*
|
||||
* @param dst is destination
|
||||
* @param src is memory to copy
|
||||
* @param n is number of bytes to copy
|
||||
* @return dst
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
void *memmove(void *dst, const void *src, size_t n) {
|
||||
return __memmove(dst, src, n);
|
||||
}
|
||||
|
||||
__weak_reference(memmove, memcpy);
|
||||
|
||||
#endif /* __aarch64__ */
|
||||
|
|
|
@ -36,8 +36,8 @@ static inline const unsigned char *memrchr_pure(const unsigned char *s,
|
|||
}
|
||||
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
static inline const unsigned char *memrchr_sse(const unsigned char *s,
|
||||
unsigned char c, size_t n) {
|
||||
static __vex const unsigned char *memrchr_sse(const unsigned char *s,
|
||||
unsigned char c, size_t n) {
|
||||
size_t i;
|
||||
unsigned m;
|
||||
xmm_t v, t = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
|
||||
|
@ -67,11 +67,9 @@ static inline const unsigned char *memrchr_sse(const unsigned char *s,
|
|||
* @return is pointer to first instance of c or NULL if not found
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
__vex void *memrchr(const void *s, int c, size_t n) {
|
||||
void *memrchr(const void *s, int c, size_t n) {
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const void *r;
|
||||
r = memrchr_sse(s, c, n);
|
||||
return (void *)r;
|
||||
return (void *)memrchr_sse(s, c, n);
|
||||
#else
|
||||
return (void *)memrchr_pure(s, c, n);
|
||||
#endif
|
||||
|
|
3
libc/intrin/musl.c
Normal file
3
libc/intrin/musl.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
__notice(musl_libc_notice, "\
|
||||
Musl libc (MIT License)\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.");
|
|
@ -48,13 +48,9 @@
|
|||
*/
|
||||
bool __nocolor;
|
||||
|
||||
optimizesize textstartup void __nocolor_init(int argc, char **argv, char **envp,
|
||||
intptr_t *auxv) {
|
||||
__attribute__((__constructor__(20))) optimizesize textstartup void
|
||||
__nocolor_init(int argc, char **argv, char **envp, intptr_t *auxv) {
|
||||
char *s;
|
||||
__nocolor = (IsWindows() && !IsAtLeastWindows10()) ||
|
||||
((s = getenv("TERM")) && IsDumb(s));
|
||||
}
|
||||
|
||||
const void *const __nocolor_ctor[] initarray = {
|
||||
__nocolor_init,
|
||||
};
|
||||
|
|
|
@ -28,11 +28,8 @@
|
|||
#include "libc/limits.h"
|
||||
#include "libc/math.h"
|
||||
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
long double scalblnl(long double x, long n) {
|
||||
|
|
|
@ -26,11 +26,8 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,11 +26,8 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,11 +28,8 @@
|
|||
#include "libc/math.h"
|
||||
#include "libc/tinymath/ldshape.internal.h"
|
||||
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
// Canary for -fstack-protector.
|
||||
//
|
||||
|
|
|
@ -31,7 +31,7 @@ static inline const char *strchr_pure(const char *s, int c) {
|
|||
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
static inline const char *strchr_sse(const char *s, unsigned char c) {
|
||||
static __vex const char *strchr_sse(const char *s, unsigned char c) {
|
||||
unsigned k;
|
||||
unsigned m;
|
||||
const xmm_t *p;
|
||||
|
@ -94,7 +94,7 @@ static inline const char *strchr_x64(const char *p, uint64_t c) {
|
|||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
__vex char *strchr(const char *s, int c) {
|
||||
char *strchr(const char *s, int c) {
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
const char *r;
|
||||
if (X86_HAVE(SSE)) {
|
||||
|
@ -102,7 +102,6 @@ __vex char *strchr(const char *s, int c) {
|
|||
} else {
|
||||
r = strchr_pure(s, c);
|
||||
}
|
||||
unassert(!r || *r || !(c & 255));
|
||||
return (char *)r;
|
||||
#else
|
||||
const char *r;
|
||||
|
@ -110,9 +109,7 @@ __vex char *strchr(const char *s, int c) {
|
|||
if ((*s & 255) == c) return (char *)s;
|
||||
if (!*s) return NULL;
|
||||
}
|
||||
r = strchr_x64(s, c);
|
||||
unassert(!r || *r || !c);
|
||||
return (char *)r;
|
||||
return (char *)strchr_x64(s, c);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#ifndef __aarch64__
|
||||
|
||||
/**
|
||||
* Returns length of NUL-terminated string.
|
||||
*
|
||||
* @param s is non-null NUL-terminated string pointer
|
||||
* @return number of bytes (excluding NUL)
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
size_t strlen(const char *s) {
|
||||
static __vex size_t __strlen(const char *s) {
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
xmm_t z = {0};
|
||||
|
@ -56,4 +49,16 @@ size_t strlen(const char *s) {
|
|||
return (const char *)p + (__builtin_ctzl(w) >> 3) - s;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns length of NUL-terminated string.
|
||||
*
|
||||
* @param s is non-null NUL-terminated string pointer
|
||||
* @return number of bytes (excluding NUL)
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
size_t strlen(const char *s) {
|
||||
return __strlen(s);
|
||||
}
|
||||
|
||||
#endif /* __aarch64__ */
|
||||
|
|
|
@ -627,7 +627,7 @@ void *__ubsan_get_current_report_data(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static textstartup void ubsan_init() {
|
||||
__attribute__((__constructor__(90))) static textstartup void ubsan_init() {
|
||||
STRACE(" _ _ ____ ____ _ _ _");
|
||||
STRACE("| | | | __ ) ___| / \\ | \\ | |");
|
||||
STRACE("| | | | _ \\___ \\ / _ \\ | \\| |");
|
||||
|
@ -635,7 +635,3 @@ static textstartup void ubsan_init() {
|
|||
STRACE(" \\___/|____/____/_/ \\_\\_| \\_|");
|
||||
STRACE("cosmopolitan behavior module initialized");
|
||||
}
|
||||
|
||||
const void *const ubsan_ctor[] initarray = {
|
||||
ubsan_init,
|
||||
};
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if defined(__x86_64__) && (defined(__GNUC__) || defined(__clang__))
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "third_party/compiler_rt/cpu_model.h"
|
||||
|
||||
enum VendorSignatures {
|
||||
SIG_INTEL = 0x756e6547, // Genu
|
||||
|
@ -740,8 +738,6 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
|
|||
#undef setFeature
|
||||
}
|
||||
|
||||
int __cpu_indicator_init(void) CONSTRUCTOR_ATTRIBUTE;
|
||||
|
||||
struct __processor_model {
|
||||
unsigned int __cpu_vendor;
|
||||
unsigned int __cpu_type;
|
||||
|
@ -757,7 +753,7 @@ unsigned __cpu_features2[(CPU_FEATURE_MAX - 1) / 32];
|
|||
// the priority set. However, it still runs after ifunc initializers and
|
||||
// needs to be called explicitly there.
|
||||
|
||||
int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
|
||||
__attribute__((__constructor__(1))) textstartup int __cpu_indicator_init(void) {
|
||||
unsigned EAX, EBX, ECX, EDX;
|
||||
unsigned MaxLeaf = 5;
|
||||
unsigned Vendor;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_
|
||||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_SYSCALL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_SYSCALL_H_
|
||||
#include "libc/stdio/syscall.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_ */
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_SYSCALL_H_ */
|
||||
|
|
4
libc/isystem/syscall.h
Normal file
4
libc/isystem/syscall.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_
|
||||
#include "libc/stdio/syscall.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYSCALL_H_ */
|
|
@ -96,12 +96,9 @@ void countbranch_report(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static textstartup void countbranch_init() {
|
||||
__attribute__((__constructor__(90))) static textstartup void
|
||||
countbranch_init() {
|
||||
atexit(countbranch_report);
|
||||
}
|
||||
|
||||
const void *const countbranch_ctor[] initarray = {
|
||||
countbranch_init,
|
||||
};
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.yoink countexpr_report
|
||||
|
||||
|
|
|
@ -76,12 +76,8 @@ void countexpr_report(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static textstartup void countexpr_init() {
|
||||
__attribute__((__constructor__(90))) static textstartup void countexpr_init() {
|
||||
atexit(countexpr_report);
|
||||
}
|
||||
|
||||
const void *const countexpr_ctor[] initarray = {
|
||||
countexpr_init,
|
||||
};
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -36,12 +36,9 @@
|
|||
#include "libc/str/str.h"
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
FreeBSD Err (BSD-3 License)\\n\
|
||||
Copyright (c) 1993\\n\
|
||||
\tThe Regents of the University of California.\\n\
|
||||
\tAll rights reserved.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
__notice(freebsd_err_notice, "\
|
||||
FreeBSD Error Library (BSD-3 License)\n\
|
||||
Copyright 1993 The Regents of the University of California");
|
||||
|
||||
static FILE *err_file; /* file to use for error output */
|
||||
static void (*err_exit)(int);
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
FILE *__log_file;
|
||||
|
||||
__attribute__((__constructor__)) static void init(void) {
|
||||
__attribute__((__constructor__(60))) static void loginit(void) {
|
||||
__log_file = stderr;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ static struct Memlog {
|
|||
struct Alloc {
|
||||
void *addr;
|
||||
long size;
|
||||
} * p;
|
||||
} *p;
|
||||
} allocs;
|
||||
atomic_long usage;
|
||||
} __memlog;
|
||||
|
@ -270,7 +270,9 @@ static textexit void __memlog_destroy(void) {
|
|||
__memlog_unlock();
|
||||
}
|
||||
|
||||
static textstartup void __memlog_init(void) {
|
||||
__attribute__((__constructor__(90))) //
|
||||
static textstartup void
|
||||
__memlog_init(void) {
|
||||
GetSymbolTable();
|
||||
__memlog_lock();
|
||||
__memlog.free = hook_free;
|
||||
|
@ -290,7 +292,3 @@ static textstartup void __memlog_init(void) {
|
|||
atexit(__memlog_destroy);
|
||||
__memlog_unlock();
|
||||
}
|
||||
|
||||
const void *const enable_memory_log[] initarray = {
|
||||
__memlog_init,
|
||||
};
|
||||
|
|
114
libc/math.h
114
libc/math.h
|
@ -4,59 +4,69 @@
|
|||
│ cosmopolitan § mathematics │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
#define M_E 2.7182818284590452354 /* 𝑒 */
|
||||
#define M_LOG2_10 0xd.49a784bcd1b8afep-2 /* log₂10 ≈ 3.3219280948873623478 */
|
||||
#define M_LOG2E 0xb.8aa3b295c17f0bcp-3 /* log₂𝑒 ≈ 1.4426950408889634074 */
|
||||
#define M_LOG10E 0.43429448190325182765 /* log₁₀𝑒 */
|
||||
#define M_LN2 0xb.17217f7d1cf79acp-4 /* logₑ2 ≈ */
|
||||
#define M_LN10 2.30258509299404568402 /* logₑ10 */
|
||||
#define M_TAU 0x1.921fb54442d1846ap+2 /* τ = 2π */
|
||||
#define M_PI 0x1.921fb54442d1846ap+1 /* π ≈ 3.14159265358979323846 */
|
||||
#define M_PI_2 1.57079632679489661923 /* π/2 */
|
||||
#define M_PI_4 0.78539816339744830962 /* π/4 */
|
||||
#define M_1_PI 0.31830988618379067154 /* 1/π */
|
||||
#define M_2_PI 0.63661977236758134308 /* 2/π */
|
||||
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrtπ */
|
||||
#define M_SQRT2 1.41421356237309504880 /* sqrt2 */
|
||||
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt2 */
|
||||
#define M_E 2.7182818284590452354 /* 𝑒 */
|
||||
#define M_LOG2E 1.4426950408889634074 /* log₂𝑒 */
|
||||
#define M_LOG10E 0.43429448190325182765 /* log₁₀𝑒 */
|
||||
#define M_LN2 0.69314718055994530942 /* logₑ2 */
|
||||
#define M_LN10 2.30258509299404568402 /* logₑ10 */
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#define M_PI_4 0.78539816339744830962 /* pi/4 */
|
||||
#define M_1_PI 0.31830988618379067154 /* 1/pi */
|
||||
#define M_2_PI 0.63661977236758134308 /* 2/pi */
|
||||
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
|
||||
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
||||
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
|
||||
|
||||
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
|
||||
#define DBL_DIG __DBL_DIG__
|
||||
#define DBL_EPSILON __DBL_EPSILON__
|
||||
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||
#define DBL_MAX __DBL_MAX__
|
||||
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
|
||||
#define DBL_MAX_EXP __DBL_MAX_EXP__
|
||||
#define DBL_MIN __DBL_MIN__ /* 2.23e–308 ↔ 1.79e308 */
|
||||
#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
|
||||
#define DBL_MIN_EXP __DBL_MIN_EXP__
|
||||
#define DECIMAL_DIG __LDBL_DECIMAL_DIG__
|
||||
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
|
||||
#define FLT_RADIX __FLT_RADIX__
|
||||
#define FLT_DIG __FLT_DIG__
|
||||
#define FLT_EPSILON __FLT_EPSILON__
|
||||
#define FLT_MANT_DIG __FLT_MANT_DIG__
|
||||
#define FLT_MANT_DIG __FLT_MANT_DIG__
|
||||
#define FLT_MAX __FLT_MAX__
|
||||
#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
|
||||
#define FLT_MAX_EXP __FLT_MAX_EXP__
|
||||
#define FLT_MIN __FLT_MIN__ /* 1.18e–38 ↔ 3.40e38 */
|
||||
#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
|
||||
#define FLT_MIN_EXP __FLT_MIN_EXP__
|
||||
#define HLF_MAX 6.50e4f
|
||||
#define HLF_MIN 3.10e-5f
|
||||
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
|
||||
#define LDBL_DIG __LDBL_DIG__
|
||||
#define LDBL_EPSILON __LDBL_EPSILON__
|
||||
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
|
||||
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
|
||||
#define LDBL_MAX __LDBL_MAX__
|
||||
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
|
||||
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
|
||||
#define LDBL_MIN __LDBL_MIN__ /* 3.37e–4932 ↔ 1.18e4932 */
|
||||
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
|
||||
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
|
||||
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
|
||||
#define DBL_DIG __DBL_DIG__
|
||||
#define DBL_EPSILON __DBL_EPSILON__
|
||||
#define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
|
||||
#define DBL_IS_IEC_60559 __DBL_IS_IEC_60559__
|
||||
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||
#define DBL_MAX __DBL_MAX__
|
||||
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
|
||||
#define DBL_MAX_EXP __DBL_MAX_EXP__
|
||||
#define DBL_MIN __DBL_MIN__ /* 2.23e–308 ↔ 1.79e308 */
|
||||
#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
|
||||
#define DBL_MIN_EXP __DBL_MIN_EXP__
|
||||
#define DBL_NORM_MAX __DBL_NORM_MAX__
|
||||
#define DBL_TRUE_MIN __DBL_DENORM_MIN__
|
||||
#define DECIMAL_DIG __LDBL_DECIMAL_DIG__
|
||||
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
|
||||
#define FLT_DIG __FLT_DIG__
|
||||
#define FLT_EPSILON __FLT_EPSILON__
|
||||
#define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
|
||||
#define FLT_IS_IEC_60559 __FLT_IS_IEC_60559__
|
||||
#define FLT_MANT_DIG __FLT_MANT_DIG__
|
||||
#define FLT_MANT_DIG __FLT_MANT_DIG__
|
||||
#define FLT_MAX __FLT_MAX__
|
||||
#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
|
||||
#define FLT_MAX_EXP __FLT_MAX_EXP__
|
||||
#define FLT_MIN __FLT_MIN__ /* 1.18e–38 ↔ 3.40e38 */
|
||||
#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
|
||||
#define FLT_MIN_EXP __FLT_MIN_EXP__
|
||||
#define FLT_NORM_MAX __FLT_NORM_MAX__
|
||||
#define FLT_RADIX __FLT_RADIX__
|
||||
#define FLT_TRUE_MIN __FLT_DENORM_MIN__
|
||||
#define HLF_MAX 6.50e4f
|
||||
#define HLF_MIN 3.10e-5f
|
||||
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
|
||||
#define LDBL_DIG __LDBL_DIG__
|
||||
#define LDBL_EPSILON __LDBL_EPSILON__
|
||||
#define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
|
||||
#define LDBL_IS_IEC_60559 __LDBL_IS_IEC_60559__
|
||||
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
|
||||
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
|
||||
#define LDBL_MAX __LDBL_MAX__
|
||||
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
|
||||
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
|
||||
#define LDBL_MIN __LDBL_MIN__ /* 3.37e–4932 ↔ 1.18e4932 */
|
||||
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
|
||||
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
|
||||
#define LDBL_NORM_MAX __LDBL_NORM_MAX__
|
||||
#define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
|
||||
|
||||
#define FP_NAN 0
|
||||
#define FP_INFINITE 1
|
||||
|
|
|
@ -51,7 +51,7 @@ static void TeardownGc(void) {
|
|||
}
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void InitializeGc(void) {
|
||||
__attribute__((__constructor__(51))) static textstartup void InitGc(void) {
|
||||
atexit(TeardownGc);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
__static_yoink("openbsd_sorting_notice");
|
||||
// clang-format off
|
||||
|
||||
/*
|
||||
|
|
|
@ -33,13 +33,9 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
__static_yoink("openbsd_sorting_notice");
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
OpenBSD Sorting (BSD-3)\\n\
|
||||
Copyright 1993 The Regents of the University of California\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
/*
|
||||
* Hybrid exponential search/linear search merge sort with hybrid
|
||||
* natural/pairwise first pass. Requires about .3% more comparisons
|
||||
|
|
2
libc/mem/opensort.c
Normal file
2
libc/mem/opensort.c
Normal file
|
@ -0,0 +1,2 @@
|
|||
__notice(openbsd_sorting_notice, "OpenBSD Sorting (BSD-3)\n\
|
||||
Copyright 1993 The Regents of the University of California");
|
|
@ -31,13 +31,9 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/str/str.h"
|
||||
__static_yoink("openbsd_sorting_notice");
|
||||
// clang-format off
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
OpenBSD Sorting (BSD-3)\\n\
|
||||
Copyright 1993 The Regents of the University of California\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
#define SWAPTYPE_BYTEV 1
|
||||
#define SWAPTYPE_INTV 2
|
||||
#define SWAPTYPE_LONGV 3
|
||||
|
|
|
@ -28,20 +28,17 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/serialize.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/backtrace.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/serialize.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
#define SYMLOOP_MAX 40
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
static size_t GetSlashLen(const char *s)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.initbss 300,_init_argc
|
||||
// Global variable holding _start(argc) parameter.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.initbss 300,_init_argv
|
||||
// Global variable holding _start(argv) parameter.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.initbss 300,_init_auxv
|
||||
// Global variable holding _start(auxv) parameter.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
// Environment variable pointer list.
|
||||
.bss
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
nop
|
||||
|
||||
|
@ -37,7 +36,7 @@ __gc: .ftrace2
|
|||
|
||||
#ifdef __x86_64__
|
||||
|
||||
mov %fs:0,%rcx // __get_tls()
|
||||
mov %gs:0x30,%rcx // __get_tls()
|
||||
mov 0x18(%rcx),%rcx // tls::garbages
|
||||
decl (%rcx) // --g->i
|
||||
mov (%rcx),%r8d // r8 = g->i
|
||||
|
|
|
@ -35,7 +35,7 @@ gclongjmp:
|
|||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov %fs:0,%r12 // __get_tls()
|
||||
mov %gs:0x30,%r12 // __get_tls()
|
||||
mov 0x18(%r12),%r12 // Tls::garbages
|
||||
test %r12,%r12
|
||||
jz 0f
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
// The identity() function.
|
||||
// @return first argument
|
||||
|
|
|
@ -33,10 +33,11 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.ident "\n\
|
||||
AVX2 SHA-1 (BSD-3 License)\n\
|
||||
Copyright 2014 Intel Corporation\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
.section .notice,"aR",@progbits
|
||||
.asciz "\n\n\
|
||||
AVX2 SHA-1 (BSD-3 License)n\
|
||||
Copyright 2014 Intel Corporation"
|
||||
.previous
|
||||
|
||||
#define CTX %rdi /* arg1 */
|
||||
#define BUF %rsi /* arg2 */
|
||||
|
|
|
@ -33,14 +33,15 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.text
|
||||
.balign 32
|
||||
.ident "\n\
|
||||
.section .notice,"aR",@progbits
|
||||
.asciz "\n\n\
|
||||
Intel SHA-NI (BSD-3 License)\n\
|
||||
Copyright 2015 Intel Corporation\n\
|
||||
Sean Gulley <sean.m.gulley@intel.com>\n\
|
||||
Tim Chen <tim.c.chen@linux.intel.com>\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
Tim Chen <tim.c.chen@linux.intel.com>"
|
||||
|
||||
.text
|
||||
.balign 32
|
||||
|
||||
#define FRAME_SIZE 32
|
||||
#define DIGEST_PTR %rdi
|
||||
|
|
|
@ -49,10 +49,11 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.ident "\n\
|
||||
.section .notice,"aR",@progbits
|
||||
.asciz "\n\n\
|
||||
AVX2 SHA2 (BSD-2 License)\n\
|
||||
Copyright 2013 Intel Corporation\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
Copyright 2013 Intel Corporation"
|
||||
.previous
|
||||
|
||||
## assume buffers not aligned
|
||||
#define VMOVDQ vmovdqu
|
||||
|
|
|
@ -33,14 +33,15 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.text
|
||||
.balign 32
|
||||
.ident "\n\
|
||||
.section .notice,"aR",@progbits
|
||||
.asciz "\n\n\
|
||||
Intel SHA-NI (BSD-3 License)\n\
|
||||
Copyright 2015 Intel Corporation\n\
|
||||
Sean Gulley <sean.m.gulley@intel.com>\n\
|
||||
Tim Chen <tim.c.chen@linux.intel.com>\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
Tim Chen <tim.c.chen@linux.intel.com>"
|
||||
|
||||
.text
|
||||
.balign 32
|
||||
|
||||
#define DIGEST_PTR %rdi /* 1st arg */
|
||||
#define DATA_PTR %rsi /* 2nd arg */
|
||||
|
|
|
@ -50,10 +50,11 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.ident "\n\
|
||||
AVX2 SHA2 (BSD-2 License)\n\
|
||||
Copyright 2013 Intel Corporation\n"
|
||||
.include "libc/disclaimer.inc"
|
||||
.section .notice,"aR",@progbits
|
||||
.asciz "\n\n\
|
||||
AVX2 SHA512 (BSD-2 License)\n\
|
||||
Copyright 2013 Intel Corporation"
|
||||
.previous
|
||||
|
||||
# Virtual Registers
|
||||
Y_0 = %ymm4
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
.ident "\n\
|
||||
Cosmopolitan\n\
|
||||
Copyright 2020 Justine Alexandra Roberts Tunney\n\
|
||||
\n\
|
||||
Permission to use, copy, modify, and/or distribute this software for\n\
|
||||
any purpose with or without fee is hereby granted, provided that the\n\
|
||||
above copyright notice and this permission notice appear in all copies.\n\
|
||||
\n\
|
||||
THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL\n\
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED\n\
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE\n\
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\n\
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR\n\
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n\
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n\
|
||||
PERFORMANCE OF THIS SOFTWARE.\
|
||||
"
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTERNAL_NOTICE_H_
|
||||
#define COSMOPOLITAN_LIBC_INTERNAL_NOTICE_H_
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifdef __ASSEMBLER__
|
||||
.include "libc/notice.inc"
|
||||
#else
|
||||
asm(".include \"libc/notice.inc\"");
|
||||
#endif
|
||||
|
||||
#endif /* !ANSI */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTERNAL_NOTICE_H_ */
|
|
@ -46,5 +46,8 @@ bool32 AdjustTokenPrivileges(int64_t TokenHandle, bool32 DisableAllPrivileges,
|
|||
bool32 ImpersonateSelf(int kNtSecurityImpersonationLevel);
|
||||
bool32 RevertToSelf(void);
|
||||
|
||||
bool32 OpenThreadToken(intptr_t ThreadHandle, uint32_t DesiredAccess,
|
||||
bool32 OpenAsSelf, intptr_t *TokenHandle);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_PRIVILEGE_H_ */
|
||||
|
|
|
@ -98,7 +98,7 @@ static void SetupExecve(void) {
|
|||
g_execve.tmpdir = getenv("TMPDIR");
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void InitExecve(void) {
|
||||
__attribute__((__constructor__(10))) static textstartup void InitExecve(void) {
|
||||
cosmo_once(&g_execve.once, SetupExecve);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ vfork:
|
|||
#endif
|
||||
pop %rbp
|
||||
#endif
|
||||
mov %fs:0,%r9 // get thread information block
|
||||
mov %gs:0x30,%r9 // get thread information block
|
||||
mov 0x3c(%r9),%r8d // avoid question of @vforksafe errno
|
||||
pop %rsi // saves return address in a register
|
||||
mov __NR_vfork(%rip),%eax
|
||||
|
|
|
@ -400,9 +400,7 @@ static wontreturn void FreebsdThreadMain(void *p) {
|
|||
#ifdef __aarch64__
|
||||
asm volatile("mov\tx28,%0" : /* no outputs */ : "r"(wt->tls));
|
||||
#elif defined(__x86_64__)
|
||||
if (__tls_morphed) {
|
||||
sys_set_tls(AMD64_SET_GSBASE, wt->tls);
|
||||
}
|
||||
sys_set_tls(AMD64_SET_GSBASE, wt->tls);
|
||||
#endif
|
||||
*wt->ctid = wt->tid;
|
||||
wt->func(wt->arg, wt->tid);
|
||||
|
@ -575,7 +573,7 @@ static int CloneLinux(int (*func)(void *arg, int rc), char *stk, size_t stksz,
|
|||
#endif
|
||||
wt = (struct LinuxCloneArgs *)sp;
|
||||
#ifdef __x86_64__
|
||||
if ((flags & CLONE_SETTLS) && __tls_morphed) {
|
||||
if (flags & CLONE_SETTLS) {
|
||||
flags &= ~CLONE_SETTLS;
|
||||
wt->arg = arg;
|
||||
wt->tls = tls;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
@ -85,19 +84,18 @@ cosmo: push %rbp
|
|||
call _init
|
||||
|
||||
// call constructors
|
||||
ezlea __init_array_end,ax // static ctors in forward order
|
||||
.weak __init_array_end // could be called multiple times
|
||||
ezlea __init_array_start,cx // idempotency recommended
|
||||
.weak __init_array_start // @see ape/ape.lds
|
||||
1: cmp %rax,%rcx
|
||||
.weak __init_array_end
|
||||
.weak __init_array_start
|
||||
mov $__init_array_start,%eax
|
||||
1: cmp $__init_array_end,%eax
|
||||
je 2f
|
||||
sub $8,%rax
|
||||
push %rax
|
||||
push %rcx
|
||||
push %rax
|
||||
call .Largs
|
||||
call *(%rax)
|
||||
pop %rcx
|
||||
pop %rax
|
||||
pop %rax
|
||||
add $8,%eax
|
||||
jmp 1b
|
||||
|
||||
// call main()
|
||||
|
|
|
@ -59,8 +59,6 @@ extern char syscon_openbsd[];
|
|||
extern char syscon_netbsd[];
|
||||
extern char syscon_windows[];
|
||||
extern init_f __strace_init;
|
||||
extern init_f *__preinit_array_start[] __attribute__((__weak__));
|
||||
extern init_f *__preinit_array_end[] __attribute__((__weak__));
|
||||
extern init_f *__init_array_start[] __attribute__((__weak__));
|
||||
extern init_f *__init_array_end[] __attribute__((__weak__));
|
||||
extern char ape_stack_prot[] __attribute__((__weak__));
|
||||
|
@ -189,7 +187,7 @@ wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
|||
#if SYSDEBUG
|
||||
argc = __strace_init(argc, argv, envp, auxv);
|
||||
#endif
|
||||
for (init_f **fp = __init_array_end; fp-- > __init_array_start;) {
|
||||
for (init_f **fp = __init_array_start; fp < __init_array_end; ++fp) {
|
||||
(*fp)(argc, argv, envp, auxv);
|
||||
}
|
||||
#ifdef FTRACE
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.underrun
|
||||
// Uniquely identifies each artifact linked in an address space.
|
||||
|
|
|
@ -251,7 +251,7 @@ textstartup void __enable_tls(void) {
|
|||
|
||||
#ifdef __x86_64__
|
||||
// rewrite the executable tls opcodes in memory
|
||||
if (IsWindows() || IsXnu()) {
|
||||
if (IsWindows() || IsOpenbsd() || IsNetbsd()) {
|
||||
__morph_tls();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -59,7 +59,9 @@ typedef double fenv_t;
|
|||
|
||||
#endif /* __x86_64__ */
|
||||
|
||||
#ifdef __FLT_EVAL_METHOD__
|
||||
#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD_TS_18661_3__
|
||||
#elif defined(__FLT_EVAL_METHOD__)
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
#else
|
||||
#define FLT_EVAL_METHOD 0
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/serialize.h"
|
||||
|
@ -49,68 +50,105 @@ privileged void __morph_tls(void) {
|
|||
unsigned char *p;
|
||||
__morph_begin();
|
||||
|
||||
if (IsXnu()) {
|
||||
// Apple is quite straightforward to patch. We basically
|
||||
// just change the segment register, and the linear slot
|
||||
// address 0x30 was promised to us, according to Go team
|
||||
// https://github.com/golang/go/issues/23617
|
||||
dis = 0x30;
|
||||
} else if (IsWindows()) {
|
||||
if (IsWindows()) {
|
||||
// MSVC __declspec(thread) generates binary code for this
|
||||
// %gs:0x1480 abi. So long as TlsAlloc() isn't called >64
|
||||
// times we should be good.
|
||||
dis = 0x1480 + __tls_index * 8;
|
||||
} else {
|
||||
dis = 0;
|
||||
}
|
||||
|
||||
// iterate over modifiable code looking for 9 byte instruction
|
||||
// this used to take 30ms with xed to enable tls on python.com
|
||||
for (p = _ereal; p + 9 <= __privileged_start; p += n) {
|
||||
// iterate over modifiable code looking for 9 byte instruction
|
||||
// this used to take 30ms with xed to enable tls on python.com
|
||||
for (p = _ereal; p + 9 <= __privileged_start; p += n) {
|
||||
|
||||
// use sse to zoom zoom to fs register prefixes
|
||||
// that way it'll take 1 ms to morph python.com
|
||||
// we recompiled a 13mb binary in 1 millisecond
|
||||
while (p + 9 + 16 <= __privileged_start) {
|
||||
if ((m = __builtin_ia32_pmovmskb128(
|
||||
*(xmm_t *)p == (xmm_t){0144, 0144, 0144, 0144, 0144, 0144, 0144,
|
||||
0144, 0144, 0144, 0144, 0144, 0144, 0144,
|
||||
0144, 0144}))) {
|
||||
m = __builtin_ctzll(m);
|
||||
p += m;
|
||||
break;
|
||||
// use sse to zoom zoom to fs register prefixes
|
||||
// that way it'll take 1 ms to morph python.com
|
||||
// we recompiled a 13mb binary in 1 millisecond
|
||||
while (p + 9 + 16 <= __privileged_start) {
|
||||
if ((m = __builtin_ia32_pmovmskb128(
|
||||
*(xmm_t *)p == (xmm_t){0145, 0145, 0145, 0145, 0145, 0145,
|
||||
0145, 0145, 0145, 0145, 0145, 0145,
|
||||
0145, 0145, 0145, 0145}))) {
|
||||
m = __builtin_ctzll(m);
|
||||
p += m;
|
||||
break;
|
||||
} else {
|
||||
p += 16;
|
||||
}
|
||||
}
|
||||
|
||||
// we're checking for the following expression:
|
||||
// 0145 == p[0] && // %gs
|
||||
// 0110 == (p[1] & 0373) && // rex.w (and ignore rex.r)
|
||||
// (0213 == p[2] || // mov reg/mem → reg (word-sized)
|
||||
// 0003 == p[2]) && // add reg/mem → reg (word-sized)
|
||||
// 0004 == (p[3] & 0307) && // mod/rm (4,reg,0) means sib → reg
|
||||
// 0x30 == p[4] && // sib (5,4,0) → (rbp,rsp,0) → disp32
|
||||
// 0000 == p[5] && // displacement (von Neumann endian)
|
||||
// 0000 == p[6] && // displacement
|
||||
// 0000 == p[7] && // displacement
|
||||
// 0000 == p[8] // displacement
|
||||
w = READ64LE(p) & READ64LE("\377\373\377\307\377\377\377\377");
|
||||
if ((w == READ64LE("\145\110\213\004\045\060\000\000") ||
|
||||
w == READ64LE("\145\110\003\004\045\060\000\000")) &&
|
||||
!p[8]) {
|
||||
|
||||
// now change the code
|
||||
p[5] = (dis & 0x000000ff) >> 000; // displacement
|
||||
p[6] = (dis & 0x0000ff00) >> 010; // displacement
|
||||
p[7] = (dis & 0x00ff0000) >> 020; // displacement
|
||||
p[8] = (dis & 0xff000000) >> 030; // displacement
|
||||
|
||||
// advance to the next instruction
|
||||
n = 9;
|
||||
} else {
|
||||
p += 16;
|
||||
n = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// iterate over modifiable code looking for 9 byte instruction
|
||||
// this used to take 30ms with xed to enable tls on python.com
|
||||
for (p = _ereal; p + 9 <= __privileged_start; p += n) {
|
||||
|
||||
// we're checking for the following expression:
|
||||
// 0144 == p[0] && // %fs
|
||||
// 0110 == (p[1] & 0373) && // rex.w (and ignore rex.r)
|
||||
// (0213 == p[2] || // mov reg/mem → reg (word-sized)
|
||||
// 0003 == p[2]) && // add reg/mem → reg (word-sized)
|
||||
// 0004 == (p[3] & 0307) && // mod/rm (4,reg,0) means sib → reg
|
||||
// 0045 == p[4] && // sib (5,4,0) → (rbp,rsp,0) → disp32
|
||||
// 0000 == p[5] && // displacement (von Neumann endian)
|
||||
// 0000 == p[6] && // displacement
|
||||
// 0000 == p[7] && // displacement
|
||||
// 0000 == p[8] // displacement
|
||||
w = READ64LE(p) & READ64LE("\377\373\377\307\377\377\377\377");
|
||||
if ((w == READ64LE("\144\110\213\004\045\000\000\000") ||
|
||||
w == READ64LE("\144\110\003\004\045\000\000\000")) &&
|
||||
!p[8]) {
|
||||
// use sse to zoom zoom to fs register prefixes
|
||||
// that way it'll take 1 ms to morph python.com
|
||||
// we recompiled a 13mb binary in 1 millisecond
|
||||
while (p + 9 + 16 <= __privileged_start) {
|
||||
if ((m = __builtin_ia32_pmovmskb128(
|
||||
*(xmm_t *)p == (xmm_t){0145, 0145, 0145, 0145, 0145, 0145,
|
||||
0145, 0145, 0145, 0145, 0145, 0145,
|
||||
0145, 0145, 0145, 0145}))) {
|
||||
m = __builtin_ctzll(m);
|
||||
p += m;
|
||||
break;
|
||||
} else {
|
||||
p += 16;
|
||||
}
|
||||
}
|
||||
|
||||
// now change the code
|
||||
p[0] = 0145; // change %fs to %gs
|
||||
p[5] = (dis & 0x000000ff) >> 000; // displacement
|
||||
p[6] = (dis & 0x0000ff00) >> 010; // displacement
|
||||
p[7] = (dis & 0x00ff0000) >> 020; // displacement
|
||||
p[8] = (dis & 0xff000000) >> 030; // displacement
|
||||
// we're checking for the following expression:
|
||||
// 0145 == p[0] && // %gs
|
||||
// 0110 == (p[1] & 0373) && // rex.w (and ignore rex.r)
|
||||
// (0213 == p[2] || // mov reg/mem → reg (word-sized)
|
||||
// 0003 == p[2]) && // add reg/mem → reg (word-sized)
|
||||
// 0004 == (p[3] & 0307) && // mod/rm (4,reg,0) means sib → reg
|
||||
// 0x30 == p[4] && // sib (5,4,0) → (rbp,rsp,0) → disp32
|
||||
// 0000 == p[5] && // displacement (von Neumann endian)
|
||||
// 0000 == p[6] && // displacement
|
||||
// 0000 == p[7] && // displacement
|
||||
// 0000 == p[8] // displacement
|
||||
w = READ64LE(p) & READ64LE("\377\373\377\307\377\377\377\377");
|
||||
if ((w == READ64LE("\145\110\213\004\045\060\000\000") ||
|
||||
w == READ64LE("\145\110\003\004\045\060\000\000")) &&
|
||||
!p[8]) {
|
||||
|
||||
// advance to the next instruction
|
||||
n = 9;
|
||||
} else {
|
||||
n = 1;
|
||||
// now change the code
|
||||
p[0] = 0144; // change %gs to %fs
|
||||
|
||||
// advance to the next instruction
|
||||
n = 9;
|
||||
} else {
|
||||
n = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,10 +39,10 @@ dontinstrument textstartup void __set_tls(struct CosmoTib *tib) {
|
|||
// ask the operating system to change the x86 segment register
|
||||
if (IsWindows()) {
|
||||
asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tib));
|
||||
} else if (IsFreebsd()) {
|
||||
sys_set_tls(__tls_morphed ? AMD64_SET_GSBASE : AMD64_SET_FSBASE, tib);
|
||||
} else if (IsLinux()) {
|
||||
sys_set_tls(__tls_morphed ? ARCH_SET_GS : ARCH_SET_FS, tib);
|
||||
sys_set_tls(ARCH_SET_GS, tib);
|
||||
} else if (IsFreebsd()) {
|
||||
sys_set_tls(AMD64_SET_GSBASE, tib);
|
||||
} else if (IsNetbsd()) {
|
||||
// netbsd has sysarch(X86_SET_FSBASE) but we can't use that because
|
||||
// signal handlers will cause it to be reset due to not setting the
|
||||
|
|
|
@ -302,7 +302,7 @@ int __zipos_open(struct ZiposUri *name, int flags) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void __zipos_ctor(void) {
|
||||
__attribute__((__constructor__(60))) static textstartup void zipos_ctor(void) {
|
||||
__zipos_wipe();
|
||||
pthread_atfork(__zipos_lock, __zipos_unlock, __zipos_wipe);
|
||||
}
|
||||
|
|
|
@ -91,11 +91,10 @@
|
|||
* TODO(jart): Polyfill kqueue for XNU/FreeBSD/OpenBSD.
|
||||
*/
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
wepoll (BSD-2)\\n\
|
||||
Copyright 2012-2020 Bert Belder\\n\
|
||||
https://github.com/piscisaureus/wepoll\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
__notice(wepoll_notice, "\
|
||||
wepoll (BSD-2)\n\
|
||||
Copyright 2012-2020 Bert Belder\n\
|
||||
https://github.com/piscisaureus/wepoll");
|
||||
|
||||
#define MAX_GROUP_SIZE 32
|
||||
|
||||
|
@ -128,7 +127,7 @@ asm(".include \"libc/disclaimer.inc\"");
|
|||
} while (0)
|
||||
|
||||
#define CONTAINOF(ptr, type, member) \
|
||||
((type *)((uintptr_t)(ptr)-offsetof(type, member)))
|
||||
((type *)((uintptr_t)(ptr) - offsetof(type, member)))
|
||||
|
||||
#define TREE__ROTATE(cis, trans) \
|
||||
struct TreeNode *p = node; \
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
/**
|
||||
* Converts dotted IPv4 address string to network order binary.
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
C++ Demangle (BSD-2)\\n\
|
||||
Copyright (c) 2007 Hyogeol Lee <hyogeollee@gmail.com>\\n\
|
||||
Copyright (c) 2015-2017 Kai Wang <kaiwang27@gmail.com>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
__notice(demangle_notice, "\
|
||||
FreeBSD C++ Demangle (BSD-2)\n\
|
||||
Copyright (c) 2007 Hyogeol Lee <hyogeollee@gmail.com>\n\
|
||||
Copyright (c) 2015-2017 Kai Wang <kaiwang27@gmail.com>");
|
||||
// https://github.com/freebsd/freebsd-src/blob/2176c9ab71c85efd90a6c7af4a9e04fe8e3d49ca/contrib/libcxxrt/libelftc_dem_gnu3.c
|
||||
// clang-format off
|
||||
|
||||
|
|
|
@ -27,10 +27,9 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
OpenBSD ecvt/gcvt (MIT)\\n\
|
||||
Copyright (c) 2002, 2006, 2010 Todd C. Miller <millert@openbsd.org>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
__notice(ecvt_notice, "\
|
||||
OpenBSD ecvt (MIT)\n\
|
||||
Copyright (c) 2002, 2006, 2010 Todd C. Miller <millert@openbsd.org>");
|
||||
// clang-format off
|
||||
|
||||
static char *s;
|
||||
|
@ -42,7 +41,7 @@ __cvt_atexit(void)
|
|||
s = 0;
|
||||
}
|
||||
|
||||
static void __attribute__((__constructor__))
|
||||
static __attribute__((__constructor__(60))) textstartup void
|
||||
__cvt_init(void)
|
||||
{
|
||||
atexit(__cvt_atexit);
|
||||
|
|
|
@ -69,7 +69,7 @@ static void __stdio_fork_child(void) {
|
|||
pthread_mutex_init(&__fflush_lock_obj, 0);
|
||||
}
|
||||
|
||||
__attribute__((__constructor__)) static void __stdio_init(void) {
|
||||
__attribute__((__constructor__(60))) static textstartup void stdioinit(void) {
|
||||
pthread_atfork(__stdio_fork_prepare, __stdio_fork_parent, __stdio_fork_child);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,8 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/ftw.h"
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,10 +28,9 @@
|
|||
#include "libc/str/unicode.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
OpenBSD ecvt/gcvt (MIT)\\n\
|
||||
Copyright (c) 2002, 2006, 2010 Todd C. Miller <millert@openbsd.org>\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
__notice(gcvt_notice, "\
|
||||
OpenBSD gcvt (MIT)\n\
|
||||
Copyright (c) 2002, 2006, 2010 Todd C. Miller <millert@openbsd.org>");
|
||||
// clang-format off
|
||||
|
||||
#define DEFPREC 6
|
||||
|
|
|
@ -32,11 +32,8 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/thread/tls.h"
|
||||
// clang-format off
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
Musl libc (MIT License)\\n\
|
||||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
#define UTF_32BE 0300
|
||||
#define UTF_16LE 0301
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue