boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

commit 83862134a46c7b25f610169af3823afb617537af
parent 481cee79fd06c2cb076c4e5fe3d74e297081af68
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Mon,  4 May 2026 11:47:42 -0700

boot4: build musl with boot3 tcc, link a static hello

amd64 verified end-to-end: 1258/1269 musl sources compile, libc.a
2.4 MB, hello runs in scratch+busybox container. 11 long-double math
files skipped — tcc 0.9.26 can't fold long-double constant initializers
(documented in docs/MUSL.md, the musltcc demo upgrades to tcc-mob to
get past this).

aarch64/riscv64 dispatch wired (per-arch case for PLATFORM, TCC_TARGET,
MUSL_ARCH, libtcc1 source list, va_list shim, CRT fallback) but neither
runs yet: the musl patch's syscall_arch.h replacement is x86_64-only
and the non-amd64 va_list shims are placeholders.

Two tcc 0.9.26 traps surfaced and worked around:
- -include silently corrupts .s/.S inputs (emits a 620-byte ELF with
  no symbols, no error). CFLAGS split into _C and _ASM forms.
- musl wants __builtin_va_list; tcc spells the same shape
  __va_list_struct[1]. Pre-included shim per arch bridges the names
  and routes __builtin_va_* macros to tcc's intrinsics.

Files:
- scripts/boot4.sh                                  pipeline driver
- scripts/boot4-musl-shim-{amd64,aarch64,riscv64}.h va_list shims
- vendor/upstream/musl-1.2.5.tar.gz                 pristine source
- vendor/upstream/musl-1.2.5-tcc.patch              tcc-compat diff
- docs/MUSL.md                                      walkthrough

Diffstat:
Adocs/MUSL.md | 160+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ascripts/boot4-musl-shim-aarch64.h | 25+++++++++++++++++++++++++
Ascripts/boot4-musl-shim-amd64.h | 43+++++++++++++++++++++++++++++++++++++++++++
Ascripts/boot4-musl-shim-riscv64.h | 18++++++++++++++++++
Ascripts/boot4.sh | 321+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avendor/upstream/musl-1.2.5-tcc.patch | 3145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avendor/upstream/musl-1.2.5.tar.gz | 0
7 files changed, 3712 insertions(+), 0 deletions(-)

diff --git a/docs/MUSL.md b/docs/MUSL.md @@ -0,0 +1,160 @@ +# boot4 — building musl with the boot3 tcc + +Working doc. boot3 produces a self-host fixed-point tcc (`tcc2 == tcc3`). +boot4 takes that compiler and uses it to build [musl +1.2.5](https://musl.libc.org/) from upstream source plus a small set of +tcc-compatibility patches, then links and runs a static hello world. +The harness is wired for amd64, aarch64, and riscv64; only **amd64** is +verified end-to-end today. Modeled on the in-image build in +[/Users/ryan/tmp/musltcc](file:///Users/ryan/tmp/musltcc) but driven +from this repo's bootstrap and constrained to scratch+busybox. + +## Pipeline + +``` +build/$ARCH/boot3/tcc3 (verified by boot3) + │ + │ scripts/boot4.sh amd64 + │ • libtcc1.a: tcc compiles libtcc1.c, alloca86_64.{S,bt.S}, + │ va_list.c into a tcc -ar archive + │ • patch: apply musl-1.2.5-tcc.patch + scrub deleted + │ src/complex/, src/{fenv,signal}/x86_64/, + │ src/math/x86_64/*.c + │ • configure: CC=tcc AR=true sh ./configure + │ --target=x86_64-linux-musl --disable-shared + │ • headers: sed mkalltypes.sed; build syscall.h, version.h + │ • compile: tcc -c every src/<dir>/*.{c,s,S}, skip-on-fail + │ • crt: Scrt1.o, crt1.o, rcrt1.o, crti.o, crtn.o + │ • libc.a: tcc -ar rcs all .o files + │ • hello: tcc -static crt1.o hello.c -lc -ltcc1 -lc + │ + ▼ +build/$ARCH/boot4/{libtcc1.a, libc.a, crt1.o, crti.o, crtn.o, hello} +``` + +The container is the same `boot2-scratch:$ARCH` boot3 uses (FROM scratch ++ busybox, no libc, no /etc). + +## Multi-arch status + +| arch | dispatch | musl patch | va_list shim | end-to-end | +|---------|:--:|:--:|:--:|:--:| +| amd64 | ✓ | ✓ | ✓ | ✓ verified | +| aarch64 | ✓ | partial — shared hunks (features.h, syscall.h, lookup\*) apply; `arch/x86_64/syscall_arch.h` replacement does NOT translate. aarch64's `syscall_arch.h` keeps its inline-asm syscalls and tcc will reject them. | placeholder ([scripts/boot4-musl-shim-aarch64.h](../scripts/boot4-musl-shim-aarch64.h)) — mirrors tcc 0.9.26's AAPCS register-save struct, untested | not yet | +| riscv64 | ✓ | partial — same shared-hunk caveat | placeholder ([scripts/boot4-musl-shim-riscv64.h](../scripts/boot4-musl-shim-riscv64.h)) — `typedef char *__builtin_va_list;`, may conflict with tcc's builtin keyword recognition | not yet | + +In-tcc assembler coverage is no longer a blocker: arm64-asm.c +(`scripts/simple-patches/tcc-0.9.26/files/arm64-asm.c`, +[docs/TCC-ARM64-ASM.md](TCC-ARM64-ASM.md)) makes `.S` inputs work for +all four targets in-container, no host cross-asm. + +The first concrete tasks for non-amd64 enablement: + +1. Per-arch syscall_arch.h replacement + asm trampoline (mirroring + what `arch/x86_64/syscall_arch.h` + `src/internal/x86_64/syscall.s` + do in the current patch). Needed because tcc has no + register-asm-variable extension. +2. Validate the va_list shim against the first compile failure and + adjust to the actual arch va_list ABI. +3. Survey arch-specific overrides under `src/{math,fenv,signal}/$ARCH/` + that use inline asm tcc rejects (the x86_64 patch deletes a similar + set; aarch64/riscv64 will need their own audit). + +## Inputs + +| Path | Contents | +|------|----------| +| `build/amd64/boot3/tcc3` | boot3's verified self-host tcc | +| `build/tcc/X86_64/tcc-0.9.26-1147-gee75a10c/{lib,include}` | tcc lib + headers, staged by `stage1-flatten.sh` | +| `vendor/upstream/musl-1.2.5.tar.gz` | pristine upstream musl tarball | +| `vendor/upstream/musl-1.2.5-tcc.patch` | tcc-compat patch (3145 lines, 93 files) | +| `scripts/boot4-musl-shim.h` | `__builtin_va_list` shim (see below) | + +## The musl patch + +The patch is the unified diff between upstream musl-1.2.5 and the +pre-modified tree under `/Users/ryan/tmp/musltcc/musl-1.2.5/`. Most of +it is deletions; the meaningful additions/modifications are: + +| File | Change | +|------|--------| +| `arch/x86_64/syscall_arch.h` | replace inline-asm syscalls with calls to a pure-asm trampoline (tcc lacks GCC's register-asm-variable extension) | +| `src/internal/x86_64/syscall.s` | new SysV-ABI → kernel-ABI shim called by the new syscall_arch.h | +| `src/include/features.h` | redefine `weak_alias()` as `.weak`/`.set` directives + an extern decl, since tcc ignores `__attribute__((alias(...)))` | +| `src/internal/syscall.h`, `src/network/lookup*.{h,c}` | drop C99 `[static N]` array-parameter qualifiers (tcc 0.9.26 doesn't parse them) | +| `include/complex.h` | stub out — tcc has no `_Complex` | +| `src/complex/*` (deleted) | empty header makes them irrelevant | +| `src/{fenv,signal}/x86_64/*.s`, `src/math/x86_64/*.c` (deleted) | drop x86_64 inline-asm overrides — tcc rejects SSE/x87 constraints, `stmxcsr`, x87 tbyte ops; the portable C fallbacks take over | + +## boot4-musl-shim.h + +Pre-included on every musl `.c` translation unit. musl's `stdarg.h` and +generated `bits/alltypes.h` spell varargs the GCC way: + +```c +typedef __builtin_va_list va_list; +#define va_start(v,l) __builtin_va_start(v,l) +``` + +tcc 0.9.26 has no `__builtin_va_list` typename; its own `<stdarg.h>` +spells the same shape `__va_list_struct[1]`. The shim aliases +`__builtin_va_list` to that array type and routes the four +`__builtin_va_*` macros to tcc's intrinsics (`__va_start`, `__va_arg`, +`__builtin_frame_address`, `__builtin_va_arg_types`). libtcc1's +`va_list.c` provides `__va_start` and `__va_arg` at link time. + +## Two tcc 0.9.26 traps + +1. **`-include` corrupts assembler input.** tcc 0.9.26 prepends the + contents of `-include` files to `.s`/`.S` inputs as well as `.c` + inputs, choking the assembler. It still emits a 620-byte ELF with + no defined symbols and no error — the build looks green and the link + fails with "undefined symbol memset". boot4 splits CFLAGS into + `CFLAGS_C` (with `-include`) and `CFLAGS_ASM` (without). +2. **No `__builtin_va_list`.** Solved by the shim above. Without it, + the first musl source to pull in `<stdio.h>` errors with `';' + expected (got "va_list")`. + +## Skipped sources + +11 files are skipped (compile-on-fail in the loop, never reached at +link time by hello). All of them lean on long-double constant folding +that tcc 0.9.26 can't do — e.g. `static const long double toint = +1.5/LDBL_EPSILON;` in `__rem_pio2l.c`: + +``` +src/math/__rem_pio2l.c src/math/__sinl.c src/math/__tanl.c +src/math/erfl.c src/math/lgammal.c src/math/modfl.c +src/math/pow_data.c src/math/powl.c src/math/rintl.c +src/math/roundl.c src/math/tgammal.c +``` + +Anything that calls `sinl`, `cosl`, `tanl`, `erfl`, `lgammal`, `powl`, +or other long-double trig/special functions will fail to link. hello.c +doesn't use any of them. The musltcc demo (which uses tcc-mob 0.9.28rc) +does not skip these. + +## Outputs + +``` +libtcc1.a ~7 KB tcc runtime: libtcc1.o + alloca86_64.{o,bt.o} + va_list.o +libc.a ~2.4 MB static musl libc, 1258 .o members +crt1.o ~1.2 KB static-link entry stub +crti.o ~830 B _init/_fini head +crtn.o ~770 B _init/_fini tail +hello ~55 KB static ELF, runs in container, prints argc + strdup demo +``` + +## Caveats / not done + +- musl is built **static-only**: `ldso/` is excluded from libc.a — it's + for the dynamic linker and defines `__init_array_start` which collides + with what tcc's internal linker synthesizes for `-static` binaries. +- `compat/time32` skipped — 32-bit time_t aliases, irrelevant on + x86_64 and produces duplicate-symbol errors. +- aarch64 / riscv64: not yet. Patches are x86_64-specific (syscall + trampoline, dropped overrides) and aarch64 also has no in-tcc + assembler in 0.9.26 (see `docs/TCC-ARM64-ASM.md`). +- No `make`, `busybox`, or further userland — boot4 stops at hello. + The musltcc demo continues to GNU make 4.4.1 and busybox 1.36.1; that + pipeline could plug in here once the libc is solid. diff --git a/scripts/boot4-musl-shim-aarch64.h b/scripts/boot4-musl-shim-aarch64.h @@ -0,0 +1,25 @@ +/* boot4 va_list shim for compiling musl with tcc 0.9.26 on aarch64. + * + * Mirrors tcc 0.9.26's <stdarg.h> aarch64 block: __va_list_struct is + * the AAPCS register-save area (stack ptr, GR/VR tops, GR/VR offsets); + * va_list is an array-of-1 of that struct so it decays to pointer at + * use sites. tcc routes va_start/va_arg through the __va_start / + * __va_arg frontend intrinsics directly (no decomposition into + * size/align/type-tag like the x86_64 path). + * + * Untested — see docs/MUSL.md "multi-arch status". */ + +typedef struct { + void *__stack; + void *__gr_top; + void *__vr_top; + int __gr_offs; + int __vr_offs; +} __va_list_struct; + +typedef __va_list_struct __builtin_va_list[1]; + +#define __builtin_va_start(ap, last) __va_start(ap, last) +#define __builtin_va_arg(ap, type) __va_arg(ap, type) +#define __builtin_va_copy(dest, src) ((dest)[0] = (src)[0]) +#define __builtin_va_end(ap) diff --git a/scripts/boot4-musl-shim-amd64.h b/scripts/boot4-musl-shim-amd64.h @@ -0,0 +1,43 @@ +/* boot4 va_list shim for compiling musl with tcc 0.9.26. + * + * musl's stdarg.h and bits/alltypes.h spell varargs the GCC way: + * + * typedef __builtin_va_list va_list; + * #define va_start(v,l) __builtin_va_start(v,l) + * ... + * + * tcc 0.9.26 has no `__builtin_va_list` typename; its own stdarg.h + * names the same shape `__va_list_struct[1]` and routes va_start/va_arg + * through tcc intrinsics __va_start, __va_arg, __builtin_frame_address, + * and __builtin_va_arg_types. musl is compiled with -nostdinc so tcc's + * stdarg.h is unreachable on its own; this header is `-include`d on + * every musl translation unit to bridge the two notations. + * + * Layout matches tcc/lib/va_list.c — those four fields are the SysV + * x86_64 ABI register-save struct that __va_start initializes and + * __va_arg walks. libtcc1.a (built earlier in this script from + * tcc/lib/va_list.c) provides __va_start and __va_arg at link time. */ + +typedef struct { + unsigned int gp_offset; + unsigned int fp_offset; + union { + unsigned int overflow_offset; + char *overflow_arg_area; + }; + char *reg_save_area; +} __va_list_struct; + +typedef __va_list_struct __builtin_va_list[1]; + +void __va_start(__va_list_struct *ap, void *fp); +void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align); + +#define __builtin_va_start(ap, last) __va_start(ap, __builtin_frame_address(0)) +#define __builtin_va_arg(ap, type) \ + (*(type *)(__va_arg(ap, \ + __builtin_va_arg_types(type), \ + sizeof(type), \ + __alignof__(type)))) +#define __builtin_va_copy(dest, src) (*(dest) = *(src)) +#define __builtin_va_end(ap) diff --git a/scripts/boot4-musl-shim-riscv64.h b/scripts/boot4-musl-shim-riscv64.h @@ -0,0 +1,18 @@ +/* boot4 va_list shim for compiling musl with tcc 0.9.26 on riscv64. + * + * On riscv64, tcc 0.9.26's <stdarg.h> spells va_list as `char *` and + * relies on `__builtin_va_start` / `_arg` / `_copy` / `_end` being + * compiler-recognized intrinsics — there is no per-arg-type + * decomposition macro to provide here. The shim only needs to make + * `__builtin_va_list` resolvable so musl's bits/alltypes.h + * + * typedef __builtin_va_list va_list; + * + * succeeds; tcc handles the va_* operations internally. + * + * Untested — see docs/MUSL.md "multi-arch status". May conflict with + * tcc's own builtin keyword recognition (tcc 0.9.26 may treat + * __builtin_va_list as a reserved name on riscv64); revisit when first + * exercising this arch. */ + +typedef char *__builtin_va_list; diff --git a/scripts/boot4.sh b/scripts/boot4.sh @@ -0,0 +1,321 @@ +#!/bin/sh +## boot4.sh — build musl-1.2.5 with the boot3 tcc and link a hello world. +## +## Builds on top of boot3's verified-fixed-point tcc (tcc2 == tcc3) and +## demonstrates that the same compiler can produce a working static libc +## from upstream musl source — patched only as far as needed to work +## around tcc's missing GCC extensions (register-asm-variable syscalls, +## attribute(alias) weak refs, _Complex, x86_64 SSE/x87 inline asm). +## +## ─── Inputs ────────────────────────────────────────────────────────── +## build/$ARCH/boot3/tcc3 +## — boot3's verified self-host tcc +## build/tcc/$TCC_TARGET/tcc-0.9.26-1147-gee75a10c/{lib,include} +## — staged by stage1-flatten.sh during boot3 +## vendor/upstream/musl-1.2.5.tar.gz +## — pristine musl source +## vendor/upstream/musl-1.2.5-tcc.patch +## — tcc-compat patch (currently x86_64-only; +## see docs/MUSL.md "multi-arch status") +## scripts/boot4-musl-shim-$ARCH.h +## — per-arch __builtin_va_list bridge +## +## ─── Outputs ───────────────────────────────────────────────────────── +## build/$ARCH/boot4/libtcc1.a +## build/$ARCH/boot4/libc.a +## build/$ARCH/boot4/{crt1.o, crti.o, crtn.o} +## build/$ARCH/boot4/hello — static, runs in the container +## +## Usage: scripts/boot4.sh <arch> +## <arch> ∈ {amd64, aarch64, riscv64} +## Only amd64 is verified end-to-end; aarch64/riscv64 are wired up +## but expected to fail until per-arch musl patches and shims land. + +set -eu + +usage() { echo "usage: $0 <amd64|aarch64|riscv64>" >&2; exit 2; } +[ "$#" -eq 1 ] || usage +ARCH=$1 + +case "$ARCH" in + amd64) + PLATFORM=linux/amd64 + TCC_TARGET=X86_64 + MUSL_ARCH=x86_64 + # libtcc1: libtcc1.c (with TCC_TARGET_X86_64) + alloca .S helpers + va_list.c + LIBTCC1_C_SRCS="libtcc1.c va_list.c" + LIBTCC1_C_DEFS="-D TCC_TARGET_X86_64=1" + LIBTCC1_ASM_SRCS="alloca86_64.S alloca86_64-bt.S" + ;; + aarch64) + PLATFORM=linux/arm64 + TCC_TARGET=ARM64 + MUSL_ARCH=aarch64 + # libtcc1: lib-arm64.c only (TFmode soft-float). Upstream tcc + # 0.9.26's OBJ-arm64 list has no .S helpers; the in-tree + # arm64-asm.c (docs/TCC-ARM64-ASM.md) makes any musl .S file + # assemblable in-container, no host cross-asm needed. + LIBTCC1_C_SRCS="lib-arm64.c" + LIBTCC1_C_DEFS="-D HAVE_CONFIG_H=1 -D TCC_TARGET_ARM64=1 -D TCC_TARGET_ARM=1" + LIBTCC1_ASM_SRCS="" + ;; + riscv64) + PLATFORM=linux/riscv64 + TCC_TARGET=RISCV64 + MUSL_ARCH=riscv64 + # libtcc1: lib-arm64.c (the same TFmode helper covers riscv64). + LIBTCC1_C_SRCS="lib-arm64.c" + LIBTCC1_C_DEFS="-D HAVE_CONFIG_H=1 -D TCC_TARGET_RISCV64=1" + LIBTCC1_ASM_SRCS="" + ;; + *) + usage + ;; +esac + +ROOT=$(cd "$(dirname "$0")/.." && pwd) +cd "$ROOT" + +IMAGE=boot2-scratch:$ARCH +BOOT3=build/$ARCH/boot3 +OUT=build/$ARCH/boot4 +STAGE=build/$ARCH/.boot4-stage +TCC_DIR=build/tcc/$TCC_TARGET/tcc-0.9.26-1147-gee75a10c +MUSL_TARBALL=vendor/upstream/musl-1.2.5.tar.gz +MUSL_PATCH=vendor/upstream/musl-1.2.5-tcc.patch +SHIM_FILE=scripts/boot4-musl-shim-$ARCH.h + +# ── prerequisites ───────────────────────────────────────────────────── +[ -x "$BOOT3/tcc3" ] || { echo "[boot4 $ARCH] missing $BOOT3/tcc3 (run scripts/boot3.sh $ARCH)" >&2; exit 1; } +[ -d "$TCC_DIR/include" ] || { echo "[boot4 $ARCH] missing $TCC_DIR/include (run scripts/boot3.sh $ARCH first)" >&2; exit 1; } +[ -e "$MUSL_TARBALL" ] || { echo "[boot4 $ARCH] missing $MUSL_TARBALL" >&2; exit 1; } +[ -e "$MUSL_PATCH" ] || { echo "[boot4 $ARCH] missing $MUSL_PATCH" >&2; exit 1; } +[ -e "$SHIM_FILE" ] || { echo "[boot4 $ARCH] missing $SHIM_FILE" >&2; exit 1; } + +# Sanity-check the per-arch tcc helper sources exist before we spin up +# the container. +for f in $LIBTCC1_C_SRCS $LIBTCC1_ASM_SRCS; do + [ -e "$TCC_DIR/lib/$f" ] || { echo "[boot4 $ARCH] missing $TCC_DIR/lib/$f" >&2; exit 1; } +done + +if ! podman image exists "$IMAGE"; then + echo "[boot4 $ARCH] building $IMAGE" + podman build --platform "$PLATFORM" -t "$IMAGE" \ + -f scripts/Containerfile.scratch scripts/ +fi + +# ── stage inputs ────────────────────────────────────────────────────── +rm -rf "$STAGE" +mkdir -p "$STAGE/in/tcc-include" "$STAGE/in/tcc-lib" "$STAGE/out" "$OUT" + +cp "$BOOT3/tcc3" "$STAGE/in/tcc" +cp -R "$TCC_DIR/include/." "$STAGE/in/tcc-include/" +for f in $LIBTCC1_C_SRCS $LIBTCC1_ASM_SRCS; do + cp "$TCC_DIR/lib/$f" "$STAGE/in/tcc-lib/$f" +done + +cp "$MUSL_TARBALL" "$STAGE/in/musl.tar.gz" +cp "$MUSL_PATCH" "$STAGE/in/musl.patch" +cp "$SHIM_FILE" "$STAGE/in/musl-shim.h" + +cat > "$STAGE/in/hello.c" <<'EOF' +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +int main(int argc, char **argv) { + printf("hello from boot4 (tcc-built musl); argc=%d\n", argc); + char *s = strdup("works"); + printf("strdup: %s, strlen: %zu\n", s, strlen(s)); + free(s); + return 0; +} +EOF + +# ── run pipeline in scratch+busybox container ───────────────────────── +echo "[boot4 $ARCH] libtcc1.a -> musl libc.a + crt -> hello" +podman run --rm -i --pull=never --platform "$PLATFORM" \ + --tmpfs /tmp:size=1024M \ + -e ARCH="$ARCH" \ + -e MUSL_ARCH="$MUSL_ARCH" \ + -e LIBTCC1_C_SRCS="$LIBTCC1_C_SRCS" \ + -e LIBTCC1_C_DEFS="$LIBTCC1_C_DEFS" \ + -e LIBTCC1_ASM_SRCS="$LIBTCC1_ASM_SRCS" \ + -v "$ROOT/$STAGE:/work" -w /work "$IMAGE" \ + sh -eu -s <<'CONTAINER' +IN=/work/in +OUT=/work/out +TCC=$IN/tcc +TCC_INC=$IN/tcc-include + +# ── Stage A: libtcc1.a (tcc compiles its own runtime) ───────────────── +mkdir -p /tmp/lib1 +cd /tmp/lib1 +LIBTCC1_OBJS="" +# shellcheck disable=SC2086 +for src in $LIBTCC1_C_SRCS; do + obj="${src%.c}.o" + # shellcheck disable=SC2086 + $TCC -nostdlib -I "$TCC_INC" $LIBTCC1_C_DEFS -c "$IN/tcc-lib/$src" -o "$obj" + LIBTCC1_OBJS="$LIBTCC1_OBJS $obj" +done +# shellcheck disable=SC2086 +for src in $LIBTCC1_ASM_SRCS; do + obj="${src%.S}.o" + $TCC -nostdlib -c "$IN/tcc-lib/$src" -o "$obj" + LIBTCC1_OBJS="$LIBTCC1_OBJS $obj" +done +# shellcheck disable=SC2086 +$TCC -ar rcs "$OUT/libtcc1.a" $LIBTCC1_OBJS +echo "libtcc1.a: $(wc -c <"$OUT/libtcc1.a") bytes" + +# ── Stage B: extract + patch musl ───────────────────────────────────── +cd /tmp +tar xzf "$IN/musl.tar.gz" +patch -p1 < "$IN/musl.patch" +# Belt-and-braces: ensure files marked "deleted file mode" really vanish +# (busybox patch leaves 0-byte stubs for delete-mode hunks). The deleted +# files are all x86_64-only overrides — harmless to remove on any arch +# build since they only matter when MUSL_ARCH=x86_64. +rm -rf musl-1.2.5/src/complex +rm -f musl-1.2.5/src/fenv/x86_64/fenv.s +rm -f musl-1.2.5/src/math/x86_64/*.c +rm -f musl-1.2.5/src/signal/x86_64/sigsetjmp.s + +# ── Stage C: configure + generate musl headers ──────────────────────── +cd /tmp/musl-1.2.5 +CC=$TCC AR=true RANLIB=true sh ./configure \ + --target=$MUSL_ARCH-linux-musl --disable-shared --disable-wrapper \ + --prefix=/tmp/musl-install >/tmp/cfg.log 2>&1 \ + || { echo "configure failed:"; tail -n 40 /tmp/cfg.log; exit 1; } +echo "configure: ok ($(wc -l </tmp/cfg.log) lines)" + +mkdir -p obj/include/bits obj/src/internal +sed -f tools/mkalltypes.sed \ + arch/$MUSL_ARCH/bits/alltypes.h.in include/alltypes.h.in \ + > obj/include/bits/alltypes.h +cp arch/$MUSL_ARCH/bits/syscall.h.in obj/include/bits/syscall.h +sed -n -e 's/__NR_/SYS_/p' < arch/$MUSL_ARCH/bits/syscall.h.in \ + >> obj/include/bits/syscall.h +echo '#define VERSION "1.2.5-tcc-boot4"' > obj/src/internal/version.h + +# ── Stage D: compile every musl source ──────────────────────────────── +# NB: -include is applied only to .c sources. tcc 0.9.26 also prepends +# -include content to .s/.S inputs, silently producing a 620-byte ELF +# with no symbols (the C content corrupts the assembler stream). +CFLAGS_BASE="-std=c99 -nostdinc -ffreestanding -fno-strict-aliasing + -D_XOPEN_SOURCE=700 + -I./arch/$MUSL_ARCH -I./arch/generic -Iobj/src/internal + -I./src/include -I./src/internal -Iobj/include -I./include + -O2 -fomit-frame-pointer + -Werror=implicit-function-declaration -Werror=implicit-int + -Werror=pointer-sign -Werror=pointer-arith" +CFLAGS_C="$CFLAGS_BASE -include $IN/musl-shim.h" +CFLAGS_ASM="$CFLAGS_BASE" +CRTFLAGS_C="$CFLAGS_C -fno-stack-protector -DCRT" +CRTFLAGS_ASM="$CFLAGS_ASM -fno-stack-protector -DCRT" +PIC="-fPIC" + +# (ldso/ excluded — that's the dynamic linker, defines __init_array_start +# which collides with what tcc's internal linker synthesizes.) +SRC_TOP="src/aio src/conf src/crypt src/ctype src/dirent + src/env src/errno src/exit src/fcntl src/fenv src/internal + src/ipc src/legacy src/linux src/locale src/malloc + src/malloc/mallocng src/math src/misc src/mman src/mq + src/multibyte src/network src/passwd src/prng src/process + src/regex src/sched src/search src/select src/setjmp src/signal + src/stat src/stdio src/stdlib src/string src/temp src/termios + src/thread src/time src/unistd" + +# Enumerate sources musl-Makefile-style: per-arch override replaces +# same-stem base file (REPLACED set). +BASE_SRCS=""; ARCH_SRCS="" +for d in $SRC_TOP; do + [ -d "$d" ] || continue + for f in $d/*.c; do [ -f "$f" ] && BASE_SRCS="$BASE_SRCS $f"; done + for f in $d/$MUSL_ARCH/*.c $d/$MUSL_ARCH/*.s $d/$MUSL_ARCH/*.S; do + [ -f "$f" ] && ARCH_SRCS="$ARCH_SRCS $f" + done +done +REPLACED="" +for a in $ARCH_SRCS; do + p=${a%.*} + head=${p%%/${MUSL_ARCH}/*} + tail=${p#*/${MUSL_ARCH}/} + REPLACED="$REPLACED $head/$tail" +done +KEEP="" +for b in $BASE_SRCS; do + stem=${b%.c}; skip=0 + for r in $REPLACED; do [ "$stem" = "$r" ] && { skip=1; break; }; done + [ $skip -eq 0 ] && KEEP="$KEEP $b" +done +KEEP="$KEEP $ARCH_SRCS" + +n_total=$(echo $KEEP | wc -w) +echo "compiling musl ($n_total sources; skip-on-fail mode)" +mkdir -p obj/lib +OBJS=""; n=0; n_ok=0; n_skip=0 +: >/tmp/skipped.txt +for src in $KEEP; do + obj="obj/${src%.*}.o" + mkdir -p "$(dirname $obj)" + case "$src" in + *.c) flags="$CFLAGS_C" ;; + *.s | *.S) flags="$CFLAGS_ASM" ;; + *) flags="$CFLAGS_C" ;; + esac + if $TCC $flags -c "$src" -o "$obj" >/tmp/compile.log 2>&1; then + OBJS="$OBJS $obj" + n_ok=$((n_ok+1)) + else + n_skip=$((n_skip+1)) + echo "$src" >>/tmp/skipped.txt + fi + n=$((n+1)) + [ $((n % 200)) -eq 0 ] && echo " $n/$n_total (ok=$n_ok skip=$n_skip)" +done +echo " compiled=$n_ok skipped=$n_skip / $n_total" +echo "--- first 30 skipped ---" +head -30 /tmp/skipped.txt + +# ── Stage E: CRT + libc.a ───────────────────────────────────────────── +# musl's per-arch crti.s/crtn.s wins over the top-level crt/crti.c if +# present; riscv64 has no crt/$MUSL_ARCH/ at all, so it falls back. +mkdir -p lib obj/crt +$TCC $CRTFLAGS_C $PIC -c crt/Scrt1.c -o obj/crt/Scrt1.o +$TCC $CRTFLAGS_C -c crt/crt1.c -o obj/crt/crt1.o +$TCC $CRTFLAGS_C $PIC -c crt/rcrt1.c -o obj/crt/rcrt1.o +if [ -f "crt/$MUSL_ARCH/crti.s" ]; then + $TCC $CRTFLAGS_ASM -c crt/$MUSL_ARCH/crti.s -o obj/crt/crti.o + $TCC $CRTFLAGS_ASM -c crt/$MUSL_ARCH/crtn.s -o obj/crt/crtn.o +else + $TCC $CRTFLAGS_C -c crt/crti.c -o obj/crt/crti.o + $TCC $CRTFLAGS_C -c crt/crtn.c -o obj/crt/crtn.o +fi +cp obj/crt/Scrt1.o obj/crt/crt1.o obj/crt/rcrt1.o obj/crt/crti.o obj/crt/crtn.o lib/ + +echo "archiving libc.a" +$TCC -ar rcs lib/libc.a $OBJS + +cp lib/libc.a lib/crt1.o lib/crti.o lib/crtn.o "$OUT/" +echo "libc.a: $(wc -c <"$OUT/libc.a") bytes" + +# ── Stage F: smoke test — link + run hello ──────────────────────────── +$TCC -static -nostdinc -nostdlib \ + -include "$IN/musl-shim.h" \ + -I./include -I./arch/$MUSL_ARCH -I./arch/generic -Iobj/include \ + lib/crt1.o "$IN/hello.c" \ + -L./lib -lc -L"$OUT" -ltcc1 -L./lib -lc \ + -o "$OUT/hello" + +echo "hello: $(wc -c <"$OUT/hello") bytes" +echo "--- run ---" +"$OUT/hello" a b c +CONTAINER + +# ── copy outputs to final destination ──────────────────────────────── +for f in libtcc1.a libc.a crt1.o crti.o crtn.o hello; do + cp "$STAGE/out/$f" "$OUT/$f" +done + +echo "[boot4 $ARCH] OK -> $OUT/{libtcc1.a, libc.a, crt1.o, crti.o, crtn.o, hello}" diff --git a/vendor/upstream/musl-1.2.5-tcc.patch b/vendor/upstream/musl-1.2.5-tcc.patch @@ -0,0 +1,3145 @@ +diff -urN orig_musl/musl-1.2.5/arch/x86_64/syscall_arch.h /tmp/clean_musltcc/arch/x86_64/syscall_arch.h +--- a/musl-1.2.5/arch/x86_64/syscall_arch.h 2024-02-29 18:07:33 ++++ b/musl-1.2.5/arch/x86_64/syscall_arch.h 2026-04-28 20:23:48 +@@ -1,64 +1,44 @@ + #define __SYSCALL_LL_E(x) (x) + #define __SYSCALL_LL_O(x) (x) + ++/* tcc-friendly: avoid GCC register-asm-variable extension and ++ x86 inline-asm constraints by routing every syscall through a ++ pure-asm trampoline (src/internal/x86_64/syscall.s). */ ++extern long __syscall(long, ...); ++ + static __inline long __syscall0(long n) + { +- unsigned long ret; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n) : "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n); + } + + static __inline long __syscall1(long n, long a1) + { +- unsigned long ret; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1) : "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n, a1); + } + + static __inline long __syscall2(long n, long a1, long a2) + { +- unsigned long ret; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2) +- : "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n, a1, a2); + } + + static __inline long __syscall3(long n, long a1, long a2, long a3) + { +- unsigned long ret; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), +- "d"(a3) : "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n, a1, a2, a3); + } + + static __inline long __syscall4(long n, long a1, long a2, long a3, long a4) + { +- unsigned long ret; +- register long r10 __asm__("r10") = a4; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), +- "d"(a3), "r"(r10): "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n, a1, a2, a3, a4); + } + + static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5) + { +- unsigned long ret; +- register long r10 __asm__("r10") = a4; +- register long r8 __asm__("r8") = a5; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), +- "d"(a3), "r"(r10), "r"(r8) : "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n, a1, a2, a3, a4, a5); + } + + static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6) + { +- unsigned long ret; +- register long r10 __asm__("r10") = a4; +- register long r8 __asm__("r8") = a5; +- register long r9 __asm__("r9") = a6; +- __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), +- "d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory"); +- return ret; ++ return __syscall(n, a1, a2, a3, a4, a5, a6); + } + + #define VDSO_USEFUL +diff -urN orig_musl/musl-1.2.5/include/complex.h /tmp/clean_musltcc/include/complex.h +--- a/musl-1.2.5/include/complex.h 2024-02-29 18:07:33 ++++ b/musl-1.2.5/include/complex.h 2026-04-28 20:24:12 +@@ -1,133 +1,10 @@ + #ifndef _COMPLEX_H + #define _COMPLEX_H + +-#ifdef __cplusplus +-extern "C" { +-#endif ++/* tcc-build stub: tcc does not implement C99 _Complex. ++ This libc was built with complex disabled; the header is empty so ++ non-complex code can still transitively include it (e.g. <tgmath.h>). ++ Any direct use of complex types or functions will fail at compile or ++ link time. */ + +-#define complex _Complex +-#ifdef __GNUC__ +-#define _Complex_I (__extension__ (0.0f+1.0fi)) +-#else +-#define _Complex_I (0.0f+1.0fi) +-#endif +-#define I _Complex_I +- +-double complex cacos(double complex); +-float complex cacosf(float complex); +-long double complex cacosl(long double complex); +- +-double complex casin(double complex); +-float complex casinf(float complex); +-long double complex casinl(long double complex); +- +-double complex catan(double complex); +-float complex catanf(float complex); +-long double complex catanl(long double complex); +- +-double complex ccos(double complex); +-float complex ccosf(float complex); +-long double complex ccosl(long double complex); +- +-double complex csin(double complex); +-float complex csinf(float complex); +-long double complex csinl(long double complex); +- +-double complex ctan(double complex); +-float complex ctanf(float complex); +-long double complex ctanl(long double complex); +- +-double complex cacosh(double complex); +-float complex cacoshf(float complex); +-long double complex cacoshl(long double complex); +- +-double complex casinh(double complex); +-float complex casinhf(float complex); +-long double complex casinhl(long double complex); +- +-double complex catanh(double complex); +-float complex catanhf(float complex); +-long double complex catanhl(long double complex); +- +-double complex ccosh(double complex); +-float complex ccoshf(float complex); +-long double complex ccoshl(long double complex); +- +-double complex csinh(double complex); +-float complex csinhf(float complex); +-long double complex csinhl(long double complex); +- +-double complex ctanh(double complex); +-float complex ctanhf(float complex); +-long double complex ctanhl(long double complex); +- +-double complex cexp(double complex); +-float complex cexpf(float complex); +-long double complex cexpl(long double complex); +- +-double complex clog(double complex); +-float complex clogf(float complex); +-long double complex clogl(long double complex); +- +-double cabs(double complex); +-float cabsf(float complex); +-long double cabsl(long double complex); +- +-double complex cpow(double complex, double complex); +-float complex cpowf(float complex, float complex); +-long double complex cpowl(long double complex, long double complex); +- +-double complex csqrt(double complex); +-float complex csqrtf(float complex); +-long double complex csqrtl(long double complex); +- +-double carg(double complex); +-float cargf(float complex); +-long double cargl(long double complex); +- +-double cimag(double complex); +-float cimagf(float complex); +-long double cimagl(long double complex); +- +-double complex conj(double complex); +-float complex conjf(float complex); +-long double complex conjl(long double complex); +- +-double complex cproj(double complex); +-float complex cprojf(float complex); +-long double complex cprojl(long double complex); +- +-double creal(double complex); +-float crealf(float complex); +-long double creall(long double complex); +- +-#ifndef __cplusplus +-#define __CIMAG(x, t) \ +- (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1]) +- +-#define creal(x) ((double)(x)) +-#define crealf(x) ((float)(x)) +-#define creall(x) ((long double)(x)) +- +-#define cimag(x) __CIMAG(x, double) +-#define cimagf(x) __CIMAG(x, float) +-#define cimagl(x) __CIMAG(x, long double) +-#endif +- +-#if __STDC_VERSION__ >= 201112L +-#if defined(_Imaginary_I) +-#define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I*(t)(y)) +-#elif defined(__clang__) +-#define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) }) +-#else +-#define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y))) +-#endif +-#define CMPLX(x, y) __CMPLX(x, y, double) +-#define CMPLXF(x, y) __CMPLX(x, y, float) +-#define CMPLXL(x, y) __CMPLX(x, y, long double) +-#endif +- +-#ifdef __cplusplus +-} +-#endif + #endif +diff -urN orig_musl/musl-1.2.5/src/complex/__cexp.c /tmp/clean_musltcc/src/complex/__cexp.c +--- a/musl-1.2.5/src/complex/__cexp.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/__cexp.c 1969-12-31 16:00:00 +@@ -1,87 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/k_exp.c */ +-/*- +- * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG> +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +- * SUCH DAMAGE. +- */ +- +-#include "complex_impl.h" +- +-static const uint32_t k = 1799; /* constant for reduction */ +-static const double kln2 = 1246.97177782734161156; /* k * ln2 */ +- +-/* +- * Compute exp(x), scaled to avoid spurious overflow. An exponent is +- * returned separately in 'expt'. +- * +- * Input: ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91 +- * Output: 2**1023 <= y < 2**1024 +- */ +-static double __frexp_exp(double x, int *expt) +-{ +- double exp_x; +- uint32_t hx; +- +- /* +- * We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to +- * minimize |exp(kln2) - 2**k|. We also scale the exponent of +- * exp_x to MAX_EXP so that the result can be multiplied by +- * a tiny number without losing accuracy due to denormalization. +- */ +- exp_x = exp(x - kln2); +- GET_HIGH_WORD(hx, exp_x); +- *expt = (hx >> 20) - (0x3ff + 1023) + k; +- SET_HIGH_WORD(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20)); +- return exp_x; +-} +- +-/* +- * __ldexp_cexp(x, expt) compute exp(x) * 2**expt. +- * It is intended for large arguments (real part >= ln(DBL_MAX)) +- * where care is needed to avoid overflow. +- * +- * The present implementation is narrowly tailored for our hyperbolic and +- * exponential functions. We assume expt is small (0 or -1), and the caller +- * has filtered out very large x, for which overflow would be inevitable. +- */ +-double complex __ldexp_cexp(double complex z, int expt) +-{ +- double x, y, exp_x, scale1, scale2; +- int ex_expt, half_expt; +- +- x = creal(z); +- y = cimag(z); +- exp_x = __frexp_exp(x, &ex_expt); +- expt += ex_expt; +- +- /* +- * Arrange so that scale1 * scale2 == 2**expt. We use this to +- * compensate for scalbn being horrendously slow. +- */ +- half_expt = expt / 2; +- INSERT_WORDS(scale1, (0x3ff + half_expt) << 20, 0); +- half_expt = expt - half_expt; +- INSERT_WORDS(scale2, (0x3ff + half_expt) << 20, 0); +- +- return CMPLX(cos(y) * exp_x * scale1 * scale2, sin(y) * exp_x * scale1 * scale2); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/__cexpf.c /tmp/clean_musltcc/src/complex/__cexpf.c +--- a/musl-1.2.5/src/complex/__cexpf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/__cexpf.c 1969-12-31 16:00:00 +@@ -1,68 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/k_expf.c */ +-/*- +- * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG> +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +- * SUCH DAMAGE. +- */ +- +-#include "complex_impl.h" +- +-static const uint32_t k = 235; /* constant for reduction */ +-static const float kln2 = 162.88958740F; /* k * ln2 */ +- +-/* +- * See __cexp.c for details. +- * +- * Input: ln(FLT_MAX) <= x < ln(2 * FLT_MAX / FLT_MIN_DENORM) ~= 192.7 +- * Output: 2**127 <= y < 2**128 +- */ +-static float __frexp_expf(float x, int *expt) +-{ +- float exp_x; +- uint32_t hx; +- +- exp_x = expf(x - kln2); +- GET_FLOAT_WORD(hx, exp_x); +- *expt = (hx >> 23) - (0x7f + 127) + k; +- SET_FLOAT_WORD(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23)); +- return exp_x; +-} +- +-float complex __ldexp_cexpf(float complex z, int expt) +-{ +- float x, y, exp_x, scale1, scale2; +- int ex_expt, half_expt; +- +- x = crealf(z); +- y = cimagf(z); +- exp_x = __frexp_expf(x, &ex_expt); +- expt += ex_expt; +- +- half_expt = expt / 2; +- SET_FLOAT_WORD(scale1, (0x7f + half_expt) << 23); +- half_expt = expt - half_expt; +- SET_FLOAT_WORD(scale2, (0x7f + half_expt) << 23); +- +- return CMPLXF(cosf(y) * exp_x * scale1 * scale2, +- sinf(y) * exp_x * scale1 * scale2); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cabs.c /tmp/clean_musltcc/src/complex/cabs.c +--- a/musl-1.2.5/src/complex/cabs.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cabs.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-double cabs(double complex z) +-{ +- return hypot(creal(z), cimag(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cabsf.c /tmp/clean_musltcc/src/complex/cabsf.c +--- a/musl-1.2.5/src/complex/cabsf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cabsf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-float cabsf(float complex z) +-{ +- return hypotf(crealf(z), cimagf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cabsl.c /tmp/clean_musltcc/src/complex/cabsl.c +--- a/musl-1.2.5/src/complex/cabsl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cabsl.c 1969-12-31 16:00:00 +@@ -1,13 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double cabsl(long double complex z) +-{ +- return cabs(z); +-} +-#else +-long double cabsl(long double complex z) +-{ +- return hypotl(creall(z), cimagl(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/cacos.c /tmp/clean_musltcc/src/complex/cacos.c +--- a/musl-1.2.5/src/complex/cacos.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cacos.c 1969-12-31 16:00:00 +@@ -1,11 +0,0 @@ +-#include "complex_impl.h" +- +-// FIXME: Hull et al. "Implementing the complex arcsine and arccosine functions using exception handling" 1997 +- +-/* acos(z) = pi/2 - asin(z) */ +- +-double complex cacos(double complex z) +-{ +- z = casin(z); +- return CMPLX(M_PI_2 - creal(z), -cimag(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cacosf.c /tmp/clean_musltcc/src/complex/cacosf.c +--- a/musl-1.2.5/src/complex/cacosf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cacosf.c 1969-12-31 16:00:00 +@@ -1,11 +0,0 @@ +-#include "complex_impl.h" +- +-// FIXME +- +-static const float float_pi_2 = M_PI_2; +- +-float complex cacosf(float complex z) +-{ +- z = casinf(z); +- return CMPLXF(float_pi_2 - crealf(z), -cimagf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cacosh.c /tmp/clean_musltcc/src/complex/cacosh.c +--- a/musl-1.2.5/src/complex/cacosh.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cacosh.c 1969-12-31 16:00:00 +@@ -1,12 +0,0 @@ +-#include "complex_impl.h" +- +-/* acosh(z) = i acos(z) */ +- +-double complex cacosh(double complex z) +-{ +- int zineg = signbit(cimag(z)); +- +- z = cacos(z); +- if (zineg) return CMPLX(cimag(z), -creal(z)); +- else return CMPLX(-cimag(z), creal(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cacoshf.c /tmp/clean_musltcc/src/complex/cacoshf.c +--- a/musl-1.2.5/src/complex/cacoshf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cacoshf.c 1969-12-31 16:00:00 +@@ -1,10 +0,0 @@ +-#include "complex_impl.h" +- +-float complex cacoshf(float complex z) +-{ +- int zineg = signbit(cimagf(z)); +- +- z = cacosf(z); +- if (zineg) return CMPLXF(cimagf(z), -crealf(z)); +- else return CMPLXF(-cimagf(z), crealf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cacoshl.c /tmp/clean_musltcc/src/complex/cacoshl.c +--- a/musl-1.2.5/src/complex/cacoshl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cacoshl.c 1969-12-31 16:00:00 +@@ -1,17 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex cacoshl(long double complex z) +-{ +- return cacosh(z); +-} +-#else +-long double complex cacoshl(long double complex z) +-{ +- int zineg = signbit(cimagl(z)); +- +- z = cacosl(z); +- if (zineg) return CMPLXL(cimagl(z), -creall(z)); +- else return CMPLXL(-cimagl(z), creall(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/cacosl.c /tmp/clean_musltcc/src/complex/cacosl.c +--- a/musl-1.2.5/src/complex/cacosl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cacosl.c 1969-12-31 16:00:00 +@@ -1,16 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex cacosl(long double complex z) +-{ +- return cacos(z); +-} +-#else +-// FIXME +-#define PI_2 1.57079632679489661923132169163975144L +-long double complex cacosl(long double complex z) +-{ +- z = casinl(z); +- return CMPLXL(PI_2 - creall(z), -cimagl(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/carg.c /tmp/clean_musltcc/src/complex/carg.c +--- a/musl-1.2.5/src/complex/carg.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/carg.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-double carg(double complex z) +-{ +- return atan2(cimag(z), creal(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cargf.c /tmp/clean_musltcc/src/complex/cargf.c +--- a/musl-1.2.5/src/complex/cargf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cargf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-float cargf(float complex z) +-{ +- return atan2f(cimagf(z), crealf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cargl.c /tmp/clean_musltcc/src/complex/cargl.c +--- a/musl-1.2.5/src/complex/cargl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cargl.c 1969-12-31 16:00:00 +@@ -1,13 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double cargl(long double complex z) +-{ +- return carg(z); +-} +-#else +-long double cargl(long double complex z) +-{ +- return atan2l(cimagl(z), creall(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/casin.c /tmp/clean_musltcc/src/complex/casin.c +--- a/musl-1.2.5/src/complex/casin.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/casin.c 1969-12-31 16:00:00 +@@ -1,17 +0,0 @@ +-#include "complex_impl.h" +- +-// FIXME +- +-/* asin(z) = -i log(i z + sqrt(1 - z*z)) */ +- +-double complex casin(double complex z) +-{ +- double complex w; +- double x, y; +- +- x = creal(z); +- y = cimag(z); +- w = CMPLX(1.0 - (x - y)*(x + y), -2.0*x*y); +- double complex r = clog(CMPLX(-y, x) + csqrt(w)); +- return CMPLX(cimag(r), -creal(r)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/casinf.c /tmp/clean_musltcc/src/complex/casinf.c +--- a/musl-1.2.5/src/complex/casinf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/casinf.c 1969-12-31 16:00:00 +@@ -1,15 +0,0 @@ +-#include "complex_impl.h" +- +-// FIXME +- +-float complex casinf(float complex z) +-{ +- float complex w; +- float x, y; +- +- x = crealf(z); +- y = cimagf(z); +- w = CMPLXF(1.0 - (x - y)*(x + y), -2.0*x*y); +- float complex r = clogf(CMPLXF(-y, x) + csqrtf(w)); +- return CMPLXF(cimagf(r), -crealf(r)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/casinh.c /tmp/clean_musltcc/src/complex/casinh.c +--- a/musl-1.2.5/src/complex/casinh.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/casinh.c 1969-12-31 16:00:00 +@@ -1,9 +0,0 @@ +-#include "complex_impl.h" +- +-/* asinh(z) = -i asin(i z) */ +- +-double complex casinh(double complex z) +-{ +- z = casin(CMPLX(-cimag(z), creal(z))); +- return CMPLX(cimag(z), -creal(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/casinhf.c /tmp/clean_musltcc/src/complex/casinhf.c +--- a/musl-1.2.5/src/complex/casinhf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/casinhf.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-float complex casinhf(float complex z) +-{ +- z = casinf(CMPLXF(-cimagf(z), crealf(z))); +- return CMPLXF(cimagf(z), -crealf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/casinhl.c /tmp/clean_musltcc/src/complex/casinhl.c +--- a/musl-1.2.5/src/complex/casinhl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/casinhl.c 1969-12-31 16:00:00 +@@ -1,14 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex casinhl(long double complex z) +-{ +- return casinh(z); +-} +-#else +-long double complex casinhl(long double complex z) +-{ +- z = casinl(CMPLXL(-cimagl(z), creall(z))); +- return CMPLXL(cimagl(z), -creall(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/casinl.c /tmp/clean_musltcc/src/complex/casinl.c +--- a/musl-1.2.5/src/complex/casinl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/casinl.c 1969-12-31 16:00:00 +@@ -1,21 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex casinl(long double complex z) +-{ +- return casin(z); +-} +-#else +-// FIXME +-long double complex casinl(long double complex z) +-{ +- long double complex w; +- long double x, y; +- +- x = creall(z); +- y = cimagl(z); +- w = CMPLXL(1.0 - (x - y)*(x + y), -2.0*x*y); +- long double complex r = clogl(CMPLXL(-y, x) + csqrtl(w)); +- return CMPLXL(cimagl(r), -creall(r)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/catan.c /tmp/clean_musltcc/src/complex/catan.c +--- a/musl-1.2.5/src/complex/catan.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/catan.c 1969-12-31 16:00:00 +@@ -1,107 +0,0 @@ +-/* origin: OpenBSD /usr/src/lib/libm/src/s_catan.c */ +-/* +- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> +- * +- * Permission to use, copy, modify, and 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. +- */ +-/* +- * Complex circular arc tangent +- * +- * +- * SYNOPSIS: +- * +- * double complex catan(); +- * double complex z, w; +- * +- * w = catan (z); +- * +- * +- * DESCRIPTION: +- * +- * If +- * z = x + iy, +- * +- * then +- * 1 ( 2x ) +- * Re w = - arctan(-----------) + k PI +- * 2 ( 2 2) +- * (1 - x - y ) +- * +- * ( 2 2) +- * 1 (x + (y+1) ) +- * Im w = - log(------------) +- * 4 ( 2 2) +- * (x + (y-1) ) +- * +- * Where k is an arbitrary integer. +- * +- * catan(z) = -i catanh(iz). +- * +- * ACCURACY: +- * +- * Relative error: +- * arithmetic domain # trials peak rms +- * DEC -10,+10 5900 1.3e-16 7.8e-18 +- * IEEE -10,+10 30000 2.3e-15 8.5e-17 +- * The check catan( ctan(z) ) = z, with |x| and |y| < PI/2, +- * had peak relative error 1.5e-16, rms relative error +- * 2.9e-17. See also clog(). +- */ +- +-#include "complex_impl.h" +- +-#define MAXNUM 1.0e308 +- +-static const double DP1 = 3.14159265160560607910E0; +-static const double DP2 = 1.98418714791870343106E-9; +-static const double DP3 = 1.14423774522196636802E-17; +- +-static double _redupi(double x) +-{ +- double t; +- long i; +- +- t = x/M_PI; +- if (t >= 0.0) +- t += 0.5; +- else +- t -= 0.5; +- +- i = t; /* the multiple */ +- t = i; +- t = ((x - t * DP1) - t * DP2) - t * DP3; +- return t; +-} +- +-double complex catan(double complex z) +-{ +- double complex w; +- double a, t, x, x2, y; +- +- x = creal(z); +- y = cimag(z); +- +- x2 = x * x; +- a = 1.0 - x2 - (y * y); +- +- t = 0.5 * atan2(2.0 * x, a); +- w = _redupi(t); +- +- t = y - 1.0; +- a = x2 + (t * t); +- +- t = y + 1.0; +- a = (x2 + t * t)/a; +- w = CMPLX(w, 0.25 * log(a)); +- return w; +-} +diff -urN orig_musl/musl-1.2.5/src/complex/catanf.c /tmp/clean_musltcc/src/complex/catanf.c +--- a/musl-1.2.5/src/complex/catanf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/catanf.c 1969-12-31 16:00:00 +@@ -1,105 +0,0 @@ +-/* origin: OpenBSD /usr/src/lib/libm/src/s_catanf.c */ +-/* +- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> +- * +- * Permission to use, copy, modify, and 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. +- */ +-/* +- * Complex circular arc tangent +- * +- * +- * SYNOPSIS: +- * +- * float complex catanf(); +- * float complex z, w; +- * +- * w = catanf( z ); +- * +- * +- * DESCRIPTION: +- * +- * If +- * z = x + iy, +- * +- * then +- * 1 ( 2x ) +- * Re w = - arctan(-----------) + k PI +- * 2 ( 2 2) +- * (1 - x - y ) +- * +- * ( 2 2) +- * 1 (x + (y+1) ) +- * Im w = - log(------------) +- * 4 ( 2 2) +- * (x + (y-1) ) +- * +- * Where k is an arbitrary integer. +- * +- * +- * ACCURACY: +- * +- * Relative error: +- * arithmetic domain # trials peak rms +- * IEEE -10,+10 30000 2.3e-6 5.2e-8 +- */ +- +-#include "complex_impl.h" +- +-#define MAXNUMF 1.0e38F +- +-static const double DP1 = 3.140625; +-static const double DP2 = 9.67502593994140625E-4; +-static const double DP3 = 1.509957990978376432E-7; +- +-static const float float_pi = M_PI; +- +-static float _redupif(float xx) +-{ +- float x, t; +- long i; +- +- x = xx; +- t = x/float_pi; +- if (t >= 0.0f) +- t += 0.5f; +- else +- t -= 0.5f; +- +- i = t; /* the multiple */ +- t = i; +- t = ((x - t * DP1) - t * DP2) - t * DP3; +- return t; +-} +- +-float complex catanf(float complex z) +-{ +- float complex w; +- float a, t, x, x2, y; +- +- x = crealf(z); +- y = cimagf(z); +- +- x2 = x * x; +- a = 1.0f - x2 - (y * y); +- +- t = 0.5f * atan2f(2.0f * x, a); +- w = _redupif(t); +- +- t = y - 1.0f; +- a = x2 + (t * t); +- +- t = y + 1.0f; +- a = (x2 + (t * t))/a; +- w = CMPLXF(w, 0.25f * logf(a)); +- return w; +-} +diff -urN orig_musl/musl-1.2.5/src/complex/catanh.c /tmp/clean_musltcc/src/complex/catanh.c +--- a/musl-1.2.5/src/complex/catanh.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/catanh.c 1969-12-31 16:00:00 +@@ -1,9 +0,0 @@ +-#include "complex_impl.h" +- +-/* atanh = -i atan(i z) */ +- +-double complex catanh(double complex z) +-{ +- z = catan(CMPLX(-cimag(z), creal(z))); +- return CMPLX(cimag(z), -creal(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/catanhf.c /tmp/clean_musltcc/src/complex/catanhf.c +--- a/musl-1.2.5/src/complex/catanhf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/catanhf.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-float complex catanhf(float complex z) +-{ +- z = catanf(CMPLXF(-cimagf(z), crealf(z))); +- return CMPLXF(cimagf(z), -crealf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/catanhl.c /tmp/clean_musltcc/src/complex/catanhl.c +--- a/musl-1.2.5/src/complex/catanhl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/catanhl.c 1969-12-31 16:00:00 +@@ -1,14 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex catanhl(long double complex z) +-{ +- return catanh(z); +-} +-#else +-long double complex catanhl(long double complex z) +-{ +- z = catanl(CMPLXL(-cimagl(z), creall(z))); +- return CMPLXL(cimagl(z), -creall(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/catanl.c /tmp/clean_musltcc/src/complex/catanl.c +--- a/musl-1.2.5/src/complex/catanl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/catanl.c 1969-12-31 16:00:00 +@@ -1,114 +0,0 @@ +-/* origin: OpenBSD /usr/src/lib/libm/src/s_catanl.c */ +-/* +- * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> +- * +- * Permission to use, copy, modify, and 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. +- */ +-/* +- * Complex circular arc tangent +- * +- * +- * SYNOPSIS: +- * +- * long double complex catanl(); +- * long double complex z, w; +- * +- * w = catanl( z ); +- * +- * +- * DESCRIPTION: +- * +- * If +- * z = x + iy, +- * +- * then +- * 1 ( 2x ) +- * Re w = - arctan(-----------) + k PI +- * 2 ( 2 2) +- * (1 - x - y ) +- * +- * ( 2 2) +- * 1 (x + (y+1) ) +- * Im w = - log(------------) +- * 4 ( 2 2) +- * (x + (y-1) ) +- * +- * Where k is an arbitrary integer. +- * +- * +- * ACCURACY: +- * +- * Relative error: +- * arithmetic domain # trials peak rms +- * DEC -10,+10 5900 1.3e-16 7.8e-18 +- * IEEE -10,+10 30000 2.3e-15 8.5e-17 +- * The check catan( ctan(z) ) = z, with |x| and |y| < PI/2, +- * had peak relative error 1.5e-16, rms relative error +- * 2.9e-17. See also clog(). +- */ +- +-#include <complex.h> +-#include <float.h> +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex catanl(long double complex z) +-{ +- return catan(z); +-} +-#else +-static const long double PIL = 3.141592653589793238462643383279502884197169L; +-static const long double DP1 = 3.14159265358979323829596852490908531763125L; +-static const long double DP2 = 1.6667485837041756656403424829301998703007e-19L; +-static const long double DP3 = 1.8830410776607851167459095484560349402753e-39L; +- +-static long double redupil(long double x) +-{ +- long double t; +- long i; +- +- t = x / PIL; +- if (t >= 0.0L) +- t += 0.5L; +- else +- t -= 0.5L; +- +- i = t; /* the multiple */ +- t = i; +- t = ((x - t * DP1) - t * DP2) - t * DP3; +- return t; +-} +- +-long double complex catanl(long double complex z) +-{ +- long double complex w; +- long double a, t, x, x2, y; +- +- x = creall(z); +- y = cimagl(z); +- +- x2 = x * x; +- a = 1.0L - x2 - (y * y); +- +- t = atan2l(2.0L * x, a) * 0.5L; +- w = redupil(t); +- +- t = y - 1.0L; +- a = x2 + (t * t); +- +- t = y + 1.0L; +- a = (x2 + (t * t)) / a; +- w = CMPLXF(w, 0.25L * logl(a)); +- return w; +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/ccos.c /tmp/clean_musltcc/src/complex/ccos.c +--- a/musl-1.2.5/src/complex/ccos.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ccos.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include "complex_impl.h" +- +-/* cos(z) = cosh(i z) */ +- +-double complex ccos(double complex z) +-{ +- return ccosh(CMPLX(-cimag(z), creal(z))); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ccosf.c /tmp/clean_musltcc/src/complex/ccosf.c +--- a/musl-1.2.5/src/complex/ccosf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ccosf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-float complex ccosf(float complex z) +-{ +- return ccoshf(CMPLXF(-cimagf(z), crealf(z))); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ccosh.c /tmp/clean_musltcc/src/complex/ccosh.c +--- a/musl-1.2.5/src/complex/ccosh.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ccosh.c 1969-12-31 16:00:00 +@@ -1,140 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_ccosh.c */ +-/*- +- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice unmodified, this list of conditions, and the following +- * disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- */ +-/* +- * Hyperbolic cosine of a complex argument z = x + i y. +- * +- * cosh(z) = cosh(x+iy) +- * = cosh(x) cos(y) + i sinh(x) sin(y). +- * +- * Exceptional values are noted in the comments within the source code. +- * These values and the return value were taken from n1124.pdf. +- */ +- +-#include "complex_impl.h" +- +-static const double huge = 0x1p1023; +- +-double complex ccosh(double complex z) +-{ +- double x, y, h; +- int32_t hx, hy, ix, iy, lx, ly; +- +- x = creal(z); +- y = cimag(z); +- +- EXTRACT_WORDS(hx, lx, x); +- EXTRACT_WORDS(hy, ly, y); +- +- ix = 0x7fffffff & hx; +- iy = 0x7fffffff & hy; +- +- /* Handle the nearly-non-exceptional cases where x and y are finite. */ +- if (ix < 0x7ff00000 && iy < 0x7ff00000) { +- if ((iy | ly) == 0) +- return CMPLX(cosh(x), x * y); +- if (ix < 0x40360000) /* small x: normal case */ +- return CMPLX(cosh(x) * cos(y), sinh(x) * sin(y)); +- +- /* |x| >= 22, so cosh(x) ~= exp(|x|) */ +- if (ix < 0x40862e42) { +- /* x < 710: exp(|x|) won't overflow */ +- h = exp(fabs(x)) * 0.5; +- return CMPLX(h * cos(y), copysign(h, x) * sin(y)); +- } else if (ix < 0x4096bbaa) { +- /* x < 1455: scale to avoid overflow */ +- z = __ldexp_cexp(CMPLX(fabs(x), y), -1); +- return CMPLX(creal(z), cimag(z) * copysign(1, x)); +- } else { +- /* x >= 1455: the result always overflows */ +- h = huge * x; +- return CMPLX(h * h * cos(y), h * sin(y)); +- } +- } +- +- /* +- * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0. +- * The sign of 0 in the result is unspecified. Choice = normally +- * the same as dNaN. Raise the invalid floating-point exception. +- * +- * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0. +- * The sign of 0 in the result is unspecified. Choice = normally +- * the same as d(NaN). +- */ +- if ((ix | lx) == 0 && iy >= 0x7ff00000) +- return CMPLX(y - y, copysign(0, x * (y - y))); +- +- /* +- * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0. +- * +- * cosh(NaN +- I 0) = d(NaN) + I sign(d(NaN, +-0))0. +- * The sign of 0 in the result is unspecified. +- */ +- if ((iy | ly) == 0 && ix >= 0x7ff00000) { +- if (((hx & 0xfffff) | lx) == 0) +- return CMPLX(x * x, copysign(0, x) * y); +- return CMPLX(x * x, copysign(0, (x + x) * y)); +- } +- +- /* +- * cosh(x +- I Inf) = dNaN + I dNaN. +- * Raise the invalid floating-point exception for finite nonzero x. +- * +- * cosh(x + I NaN) = d(NaN) + I d(NaN). +- * Optionally raises the invalid floating-point exception for finite +- * nonzero x. Choice = don't raise (except for signaling NaNs). +- */ +- if (ix < 0x7ff00000 && iy >= 0x7ff00000) +- return CMPLX(y - y, x * (y - y)); +- +- /* +- * cosh(+-Inf + I NaN) = +Inf + I d(NaN). +- * +- * cosh(+-Inf +- I Inf) = +Inf + I dNaN. +- * The sign of Inf in the result is unspecified. Choice = always +. +- * Raise the invalid floating-point exception. +- * +- * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y) +- */ +- if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) { +- if (iy >= 0x7ff00000) +- return CMPLX(x * x, x * (y - y)); +- return CMPLX((x * x) * cos(y), x * sin(y)); +- } +- +- /* +- * cosh(NaN + I NaN) = d(NaN) + I d(NaN). +- * +- * cosh(NaN +- I Inf) = d(NaN) + I d(NaN). +- * Optionally raises the invalid floating-point exception. +- * Choice = raise. +- * +- * cosh(NaN + I y) = d(NaN) + I d(NaN). +- * Optionally raises the invalid floating-point exception for finite +- * nonzero y. Choice = don't raise (except for signaling NaNs). +- */ +- return CMPLX((x * x) * (y - y), (x + x) * (y - y)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ccoshf.c /tmp/clean_musltcc/src/complex/ccoshf.c +--- a/musl-1.2.5/src/complex/ccoshf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ccoshf.c 1969-12-31 16:00:00 +@@ -1,90 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_ccoshf.c */ +-/*- +- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice unmodified, this list of conditions, and the following +- * disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- */ +-/* +- * Hyperbolic cosine of a complex argument. See s_ccosh.c for details. +- */ +- +-#include "complex_impl.h" +- +-static const float huge = 0x1p127; +- +-float complex ccoshf(float complex z) +-{ +- float x, y, h; +- int32_t hx, hy, ix, iy; +- +- x = crealf(z); +- y = cimagf(z); +- +- GET_FLOAT_WORD(hx, x); +- GET_FLOAT_WORD(hy, y); +- +- ix = 0x7fffffff & hx; +- iy = 0x7fffffff & hy; +- +- if (ix < 0x7f800000 && iy < 0x7f800000) { +- if (iy == 0) +- return CMPLXF(coshf(x), x * y); +- if (ix < 0x41100000) /* small x: normal case */ +- return CMPLXF(coshf(x) * cosf(y), sinhf(x) * sinf(y)); +- +- /* |x| >= 9, so cosh(x) ~= exp(|x|) */ +- if (ix < 0x42b17218) { +- /* x < 88.7: expf(|x|) won't overflow */ +- h = expf(fabsf(x)) * 0.5f; +- return CMPLXF(h * cosf(y), copysignf(h, x) * sinf(y)); +- } else if (ix < 0x4340b1e7) { +- /* x < 192.7: scale to avoid overflow */ +- z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); +- return CMPLXF(crealf(z), cimagf(z) * copysignf(1, x)); +- } else { +- /* x >= 192.7: the result always overflows */ +- h = huge * x; +- return CMPLXF(h * h * cosf(y), h * sinf(y)); +- } +- } +- +- if (ix == 0 && iy >= 0x7f800000) +- return CMPLXF(y - y, copysignf(0, x * (y - y))); +- +- if (iy == 0 && ix >= 0x7f800000) { +- if ((hx & 0x7fffff) == 0) +- return CMPLXF(x * x, copysignf(0, x) * y); +- return CMPLXF(x * x, copysignf(0, (x + x) * y)); +- } +- +- if (ix < 0x7f800000 && iy >= 0x7f800000) +- return CMPLXF(y - y, x * (y - y)); +- +- if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { +- if (iy >= 0x7f800000) +- return CMPLXF(x * x, x * (y - y)); +- return CMPLXF((x * x) * cosf(y), x * sinf(y)); +- } +- +- return CMPLXF((x * x) * (y - y), (x + x) * (y - y)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ccoshl.c /tmp/clean_musltcc/src/complex/ccoshl.c +--- a/musl-1.2.5/src/complex/ccoshl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ccoshl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-//FIXME +-long double complex ccoshl(long double complex z) +-{ +- return ccosh(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ccosl.c /tmp/clean_musltcc/src/complex/ccosl.c +--- a/musl-1.2.5/src/complex/ccosl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ccosl.c 1969-12-31 16:00:00 +@@ -1,13 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex ccosl(long double complex z) +-{ +- return ccos(z); +-} +-#else +-long double complex ccosl(long double complex z) +-{ +- return ccoshl(CMPLXL(-cimagl(z), creall(z))); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/cexp.c /tmp/clean_musltcc/src/complex/cexp.c +--- a/musl-1.2.5/src/complex/cexp.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cexp.c 1969-12-31 16:00:00 +@@ -1,83 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_cexp.c */ +-/*- +- * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG> +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +- * SUCH DAMAGE. +- */ +- +-#include "complex_impl.h" +- +-static const uint32_t +-exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */ +-cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ +- +-double complex cexp(double complex z) +-{ +- double x, y, exp_x; +- uint32_t hx, hy, lx, ly; +- +- x = creal(z); +- y = cimag(z); +- +- EXTRACT_WORDS(hy, ly, y); +- hy &= 0x7fffffff; +- +- /* cexp(x + I 0) = exp(x) + I 0 */ +- if ((hy | ly) == 0) +- return CMPLX(exp(x), y); +- EXTRACT_WORDS(hx, lx, x); +- /* cexp(0 + I y) = cos(y) + I sin(y) */ +- if (((hx & 0x7fffffff) | lx) == 0) +- return CMPLX(cos(y), sin(y)); +- +- if (hy >= 0x7ff00000) { +- if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) { +- /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ +- return CMPLX(y - y, y - y); +- } else if (hx & 0x80000000) { +- /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ +- return CMPLX(0.0, 0.0); +- } else { +- /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ +- return CMPLX(x, y - y); +- } +- } +- +- if (hx >= exp_ovfl && hx <= cexp_ovfl) { +- /* +- * x is between 709.7 and 1454.3, so we must scale to avoid +- * overflow in exp(x). +- */ +- return __ldexp_cexp(z, 0); +- } else { +- /* +- * Cases covered here: +- * - x < exp_ovfl and exp(x) won't overflow (common case) +- * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 +- * - x = +-Inf (generated by exp()) +- * - x = NaN (spurious inexact exception from y) +- */ +- exp_x = exp(x); +- return CMPLX(exp_x * cos(y), exp_x * sin(y)); +- } +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cexpf.c /tmp/clean_musltcc/src/complex/cexpf.c +--- a/musl-1.2.5/src/complex/cexpf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cexpf.c 1969-12-31 16:00:00 +@@ -1,83 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_cexpf.c */ +-/*- +- * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG> +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +- * SUCH DAMAGE. +- */ +- +-#include "complex_impl.h" +- +-static const uint32_t +-exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */ +-cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ +- +-float complex cexpf(float complex z) +-{ +- float x, y, exp_x; +- uint32_t hx, hy; +- +- x = crealf(z); +- y = cimagf(z); +- +- GET_FLOAT_WORD(hy, y); +- hy &= 0x7fffffff; +- +- /* cexp(x + I 0) = exp(x) + I 0 */ +- if (hy == 0) +- return CMPLXF(expf(x), y); +- GET_FLOAT_WORD(hx, x); +- /* cexp(0 + I y) = cos(y) + I sin(y) */ +- if ((hx & 0x7fffffff) == 0) +- return CMPLXF(cosf(y), sinf(y)); +- +- if (hy >= 0x7f800000) { +- if ((hx & 0x7fffffff) != 0x7f800000) { +- /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ +- return CMPLXF(y - y, y - y); +- } else if (hx & 0x80000000) { +- /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ +- return CMPLXF(0.0, 0.0); +- } else { +- /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ +- return CMPLXF(x, y - y); +- } +- } +- +- if (hx >= exp_ovfl && hx <= cexp_ovfl) { +- /* +- * x is between 88.7 and 192, so we must scale to avoid +- * overflow in expf(x). +- */ +- return __ldexp_cexpf(z, 0); +- } else { +- /* +- * Cases covered here: +- * - x < exp_ovfl and exp(x) won't overflow (common case) +- * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 +- * - x = +-Inf (generated by exp()) +- * - x = NaN (spurious inexact exception from y) +- */ +- exp_x = expf(x); +- return CMPLXF(exp_x * cosf(y), exp_x * sinf(y)); +- } +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cexpl.c /tmp/clean_musltcc/src/complex/cexpl.c +--- a/musl-1.2.5/src/complex/cexpl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cexpl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-//FIXME +-long double complex cexpl(long double complex z) +-{ +- return cexp(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cimag.c /tmp/clean_musltcc/src/complex/cimag.c +--- a/musl-1.2.5/src/complex/cimag.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cimag.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-double (cimag)(double complex z) +-{ +- return cimag(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cimagf.c /tmp/clean_musltcc/src/complex/cimagf.c +--- a/musl-1.2.5/src/complex/cimagf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cimagf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-float (cimagf)(float complex z) +-{ +- return cimagf(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cimagl.c /tmp/clean_musltcc/src/complex/cimagl.c +--- a/musl-1.2.5/src/complex/cimagl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cimagl.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-long double (cimagl)(long double complex z) +-{ +- return cimagl(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/clog.c /tmp/clean_musltcc/src/complex/clog.c +--- a/musl-1.2.5/src/complex/clog.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/clog.c 1969-12-31 16:00:00 +@@ -1,14 +0,0 @@ +-#include "complex_impl.h" +- +-// FIXME +- +-/* log(z) = log(|z|) + i arg(z) */ +- +-double complex clog(double complex z) +-{ +- double r, phi; +- +- r = cabs(z); +- phi = carg(z); +- return CMPLX(log(r), phi); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/clogf.c /tmp/clean_musltcc/src/complex/clogf.c +--- a/musl-1.2.5/src/complex/clogf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/clogf.c 1969-12-31 16:00:00 +@@ -1,12 +0,0 @@ +-#include "complex_impl.h" +- +-// FIXME +- +-float complex clogf(float complex z) +-{ +- float r, phi; +- +- r = cabsf(z); +- phi = cargf(z); +- return CMPLXF(logf(r), phi); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/clogl.c /tmp/clean_musltcc/src/complex/clogl.c +--- a/musl-1.2.5/src/complex/clogl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/clogl.c 1969-12-31 16:00:00 +@@ -1,18 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex clogl(long double complex z) +-{ +- return clog(z); +-} +-#else +-// FIXME +-long double complex clogl(long double complex z) +-{ +- long double r, phi; +- +- r = cabsl(z); +- phi = cargl(z); +- return CMPLXL(logl(r), phi); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/conj.c /tmp/clean_musltcc/src/complex/conj.c +--- a/musl-1.2.5/src/complex/conj.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/conj.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-double complex conj(double complex z) +-{ +- return CMPLX(creal(z), -cimag(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/conjf.c /tmp/clean_musltcc/src/complex/conjf.c +--- a/musl-1.2.5/src/complex/conjf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/conjf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-float complex conjf(float complex z) +-{ +- return CMPLXF(crealf(z), -cimagf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/conjl.c /tmp/clean_musltcc/src/complex/conjl.c +--- a/musl-1.2.5/src/complex/conjl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/conjl.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-long double complex conjl(long double complex z) +-{ +- return CMPLXL(creall(z), -cimagl(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cpow.c /tmp/clean_musltcc/src/complex/cpow.c +--- a/musl-1.2.5/src/complex/cpow.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cpow.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include "complex_impl.h" +- +-/* pow(z, c) = exp(c log(z)), See C99 G.6.4.1 */ +- +-double complex cpow(double complex z, double complex c) +-{ +- return cexp(c * clog(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cpowf.c /tmp/clean_musltcc/src/complex/cpowf.c +--- a/musl-1.2.5/src/complex/cpowf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cpowf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include "complex_impl.h" +- +-float complex cpowf(float complex z, float complex c) +-{ +- return cexpf(c * clogf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cpowl.c /tmp/clean_musltcc/src/complex/cpowl.c +--- a/musl-1.2.5/src/complex/cpowl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cpowl.c 1969-12-31 16:00:00 +@@ -1,13 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex cpowl(long double complex z, long double complex c) +-{ +- return cpow(z, c); +-} +-#else +-long double complex cpowl(long double complex z, long double complex c) +-{ +- return cexpl(c * clogl(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/cproj.c /tmp/clean_musltcc/src/complex/cproj.c +--- a/musl-1.2.5/src/complex/cproj.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cproj.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include "complex_impl.h" +- +-double complex cproj(double complex z) +-{ +- if (isinf(creal(z)) || isinf(cimag(z))) +- return CMPLX(INFINITY, copysign(0.0, cimag(z))); +- return z; +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cprojf.c /tmp/clean_musltcc/src/complex/cprojf.c +--- a/musl-1.2.5/src/complex/cprojf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cprojf.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include "complex_impl.h" +- +-float complex cprojf(float complex z) +-{ +- if (isinf(crealf(z)) || isinf(cimagf(z))) +- return CMPLXF(INFINITY, copysignf(0.0, cimagf(z))); +- return z; +-} +diff -urN orig_musl/musl-1.2.5/src/complex/cprojl.c /tmp/clean_musltcc/src/complex/cprojl.c +--- a/musl-1.2.5/src/complex/cprojl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/cprojl.c 1969-12-31 16:00:00 +@@ -1,15 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex cprojl(long double complex z) +-{ +- return cproj(z); +-} +-#else +-long double complex cprojl(long double complex z) +-{ +- if (isinf(creall(z)) || isinf(cimagl(z))) +- return CMPLXL(INFINITY, copysignl(0.0, cimagl(z))); +- return z; +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/creal.c /tmp/clean_musltcc/src/complex/creal.c +--- a/musl-1.2.5/src/complex/creal.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/creal.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include <complex.h> +- +-double (creal)(double complex z) +-{ +- return creal(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/crealf.c /tmp/clean_musltcc/src/complex/crealf.c +--- a/musl-1.2.5/src/complex/crealf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/crealf.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include <complex.h> +- +-float (crealf)(float complex z) +-{ +- return crealf(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/creall.c /tmp/clean_musltcc/src/complex/creall.c +--- a/musl-1.2.5/src/complex/creall.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/creall.c 1969-12-31 16:00:00 +@@ -1,6 +0,0 @@ +-#include <complex.h> +- +-long double (creall)(long double complex z) +-{ +- return creall(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csin.c /tmp/clean_musltcc/src/complex/csin.c +--- a/musl-1.2.5/src/complex/csin.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csin.c 1969-12-31 16:00:00 +@@ -1,9 +0,0 @@ +-#include "complex_impl.h" +- +-/* sin(z) = -i sinh(i z) */ +- +-double complex csin(double complex z) +-{ +- z = csinh(CMPLX(-cimag(z), creal(z))); +- return CMPLX(cimag(z), -creal(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csinf.c /tmp/clean_musltcc/src/complex/csinf.c +--- a/musl-1.2.5/src/complex/csinf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csinf.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-float complex csinf(float complex z) +-{ +- z = csinhf(CMPLXF(-cimagf(z), crealf(z))); +- return CMPLXF(cimagf(z), -crealf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csinh.c /tmp/clean_musltcc/src/complex/csinh.c +--- a/musl-1.2.5/src/complex/csinh.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csinh.c 1969-12-31 16:00:00 +@@ -1,141 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_csinh.c */ +-/*- +- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice unmodified, this list of conditions, and the following +- * disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- */ +-/* +- * Hyperbolic sine of a complex argument z = x + i y. +- * +- * sinh(z) = sinh(x+iy) +- * = sinh(x) cos(y) + i cosh(x) sin(y). +- * +- * Exceptional values are noted in the comments within the source code. +- * These values and the return value were taken from n1124.pdf. +- */ +- +-#include "complex_impl.h" +- +-static const double huge = 0x1p1023; +- +-double complex csinh(double complex z) +-{ +- double x, y, h; +- int32_t hx, hy, ix, iy, lx, ly; +- +- x = creal(z); +- y = cimag(z); +- +- EXTRACT_WORDS(hx, lx, x); +- EXTRACT_WORDS(hy, ly, y); +- +- ix = 0x7fffffff & hx; +- iy = 0x7fffffff & hy; +- +- /* Handle the nearly-non-exceptional cases where x and y are finite. */ +- if (ix < 0x7ff00000 && iy < 0x7ff00000) { +- if ((iy | ly) == 0) +- return CMPLX(sinh(x), y); +- if (ix < 0x40360000) /* small x: normal case */ +- return CMPLX(sinh(x) * cos(y), cosh(x) * sin(y)); +- +- /* |x| >= 22, so cosh(x) ~= exp(|x|) */ +- if (ix < 0x40862e42) { +- /* x < 710: exp(|x|) won't overflow */ +- h = exp(fabs(x)) * 0.5; +- return CMPLX(copysign(h, x) * cos(y), h * sin(y)); +- } else if (ix < 0x4096bbaa) { +- /* x < 1455: scale to avoid overflow */ +- z = __ldexp_cexp(CMPLX(fabs(x), y), -1); +- return CMPLX(creal(z) * copysign(1, x), cimag(z)); +- } else { +- /* x >= 1455: the result always overflows */ +- h = huge * x; +- return CMPLX(h * cos(y), h * h * sin(y)); +- } +- } +- +- /* +- * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN. +- * The sign of 0 in the result is unspecified. Choice = normally +- * the same as dNaN. Raise the invalid floating-point exception. +- * +- * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN). +- * The sign of 0 in the result is unspecified. Choice = normally +- * the same as d(NaN). +- */ +- if ((ix | lx) == 0 && iy >= 0x7ff00000) +- return CMPLX(copysign(0, x * (y - y)), y - y); +- +- /* +- * sinh(+-Inf +- I 0) = +-Inf + I +-0. +- * +- * sinh(NaN +- I 0) = d(NaN) + I +-0. +- */ +- if ((iy | ly) == 0 && ix >= 0x7ff00000) { +- if (((hx & 0xfffff) | lx) == 0) +- return CMPLX(x, y); +- return CMPLX(x, copysign(0, y)); +- } +- +- /* +- * sinh(x +- I Inf) = dNaN + I dNaN. +- * Raise the invalid floating-point exception for finite nonzero x. +- * +- * sinh(x + I NaN) = d(NaN) + I d(NaN). +- * Optionally raises the invalid floating-point exception for finite +- * nonzero x. Choice = don't raise (except for signaling NaNs). +- */ +- if (ix < 0x7ff00000 && iy >= 0x7ff00000) +- return CMPLX(y - y, x * (y - y)); +- +- /* +- * sinh(+-Inf + I NaN) = +-Inf + I d(NaN). +- * The sign of Inf in the result is unspecified. Choice = normally +- * the same as d(NaN). +- * +- * sinh(+-Inf +- I Inf) = +Inf + I dNaN. +- * The sign of Inf in the result is unspecified. Choice = always +. +- * Raise the invalid floating-point exception. +- * +- * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y) +- */ +- if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) { +- if (iy >= 0x7ff00000) +- return CMPLX(x * x, x * (y - y)); +- return CMPLX(x * cos(y), INFINITY * sin(y)); +- } +- +- /* +- * sinh(NaN + I NaN) = d(NaN) + I d(NaN). +- * +- * sinh(NaN +- I Inf) = d(NaN) + I d(NaN). +- * Optionally raises the invalid floating-point exception. +- * Choice = raise. +- * +- * sinh(NaN + I y) = d(NaN) + I d(NaN). +- * Optionally raises the invalid floating-point exception for finite +- * nonzero y. Choice = don't raise (except for signaling NaNs). +- */ +- return CMPLX((x * x) * (y - y), (x + x) * (y - y)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csinhf.c /tmp/clean_musltcc/src/complex/csinhf.c +--- a/musl-1.2.5/src/complex/csinhf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csinhf.c 1969-12-31 16:00:00 +@@ -1,90 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_csinhf.c */ +-/*- +- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice unmodified, this list of conditions, and the following +- * disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- */ +-/* +- * Hyperbolic sine of a complex argument z. See s_csinh.c for details. +- */ +- +-#include "complex_impl.h" +- +-static const float huge = 0x1p127; +- +-float complex csinhf(float complex z) +-{ +- float x, y, h; +- int32_t hx, hy, ix, iy; +- +- x = crealf(z); +- y = cimagf(z); +- +- GET_FLOAT_WORD(hx, x); +- GET_FLOAT_WORD(hy, y); +- +- ix = 0x7fffffff & hx; +- iy = 0x7fffffff & hy; +- +- if (ix < 0x7f800000 && iy < 0x7f800000) { +- if (iy == 0) +- return CMPLXF(sinhf(x), y); +- if (ix < 0x41100000) /* small x: normal case */ +- return CMPLXF(sinhf(x) * cosf(y), coshf(x) * sinf(y)); +- +- /* |x| >= 9, so cosh(x) ~= exp(|x|) */ +- if (ix < 0x42b17218) { +- /* x < 88.7: expf(|x|) won't overflow */ +- h = expf(fabsf(x)) * 0.5f; +- return CMPLXF(copysignf(h, x) * cosf(y), h * sinf(y)); +- } else if (ix < 0x4340b1e7) { +- /* x < 192.7: scale to avoid overflow */ +- z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); +- return CMPLXF(crealf(z) * copysignf(1, x), cimagf(z)); +- } else { +- /* x >= 192.7: the result always overflows */ +- h = huge * x; +- return CMPLXF(h * cosf(y), h * h * sinf(y)); +- } +- } +- +- if (ix == 0 && iy >= 0x7f800000) +- return CMPLXF(copysignf(0, x * (y - y)), y - y); +- +- if (iy == 0 && ix >= 0x7f800000) { +- if ((hx & 0x7fffff) == 0) +- return CMPLXF(x, y); +- return CMPLXF(x, copysignf(0, y)); +- } +- +- if (ix < 0x7f800000 && iy >= 0x7f800000) +- return CMPLXF(y - y, x * (y - y)); +- +- if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { +- if (iy >= 0x7f800000) +- return CMPLXF(x * x, x * (y - y)); +- return CMPLXF(x * cosf(y), INFINITY * sinf(y)); +- } +- +- return CMPLXF((x * x) * (y - y), (x + x) * (y - y)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csinhl.c /tmp/clean_musltcc/src/complex/csinhl.c +--- a/musl-1.2.5/src/complex/csinhl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csinhl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-//FIXME +-long double complex csinhl(long double complex z) +-{ +- return csinh(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csinl.c /tmp/clean_musltcc/src/complex/csinl.c +--- a/musl-1.2.5/src/complex/csinl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csinl.c 1969-12-31 16:00:00 +@@ -1,14 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex csinl(long double complex z) +-{ +- return csin(z); +-} +-#else +-long double complex csinl(long double complex z) +-{ +- z = csinhl(CMPLXL(-cimagl(z), creall(z))); +- return CMPLXL(cimagl(z), -creall(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/complex/csqrt.c /tmp/clean_musltcc/src/complex/csqrt.c +--- a/musl-1.2.5/src/complex/csqrt.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csqrt.c 1969-12-31 16:00:00 +@@ -1,100 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_csqrt.c */ +-/*- +- * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG> +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +- * SUCH DAMAGE. +- */ +- +-#include "complex_impl.h" +- +-/* +- * gcc doesn't implement complex multiplication or division correctly, +- * so we need to handle infinities specially. We turn on this pragma to +- * notify conforming c99 compilers that the fast-but-incorrect code that +- * gcc generates is acceptable, since the special cases have already been +- * handled. +- */ +-#pragma STDC CX_LIMITED_RANGE ON +- +-/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ +-#define THRESH 0x1.a827999fcef32p+1022 +- +-double complex csqrt(double complex z) +-{ +- double complex result; +- double a, b; +- double t; +- int scale; +- +- a = creal(z); +- b = cimag(z); +- +- /* Handle special cases. */ +- if (z == 0) +- return CMPLX(0, b); +- if (isinf(b)) +- return CMPLX(INFINITY, b); +- if (isnan(a)) { +- t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ +- return CMPLX(a, t); /* return NaN + NaN i */ +- } +- if (isinf(a)) { +- /* +- * csqrt(inf + NaN i) = inf + NaN i +- * csqrt(inf + y i) = inf + 0 i +- * csqrt(-inf + NaN i) = NaN +- inf i +- * csqrt(-inf + y i) = 0 + inf i +- */ +- if (signbit(a)) +- return CMPLX(fabs(b - b), copysign(a, b)); +- else +- return CMPLX(a, copysign(b - b, b)); +- } +- /* +- * The remaining special case (b is NaN) is handled just fine by +- * the normal code path below. +- */ +- +- /* Scale to avoid overflow. */ +- if (fabs(a) >= THRESH || fabs(b) >= THRESH) { +- a *= 0.25; +- b *= 0.25; +- scale = 1; +- } else { +- scale = 0; +- } +- +- /* Algorithm 312, CACM vol 10, Oct 1967. */ +- if (a >= 0) { +- t = sqrt((a + hypot(a, b)) * 0.5); +- result = CMPLX(t, b / (2 * t)); +- } else { +- t = sqrt((-a + hypot(a, b)) * 0.5); +- result = CMPLX(fabs(b) / (2 * t), copysign(t, b)); +- } +- +- /* Rescale. */ +- if (scale) +- result *= 2; +- return result; +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csqrtf.c /tmp/clean_musltcc/src/complex/csqrtf.c +--- a/musl-1.2.5/src/complex/csqrtf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csqrtf.c 1969-12-31 16:00:00 +@@ -1,82 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_csqrtf.c */ +-/*- +- * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG> +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +- * SUCH DAMAGE. +- */ +- +-#include "complex_impl.h" +- +-/* +- * gcc doesn't implement complex multiplication or division correctly, +- * so we need to handle infinities specially. We turn on this pragma to +- * notify conforming c99 compilers that the fast-but-incorrect code that +- * gcc generates is acceptable, since the special cases have already been +- * handled. +- */ +-#pragma STDC CX_LIMITED_RANGE ON +- +-float complex csqrtf(float complex z) +-{ +- float a = crealf(z), b = cimagf(z); +- double t; +- +- /* Handle special cases. */ +- if (z == 0) +- return CMPLXF(0, b); +- if (isinf(b)) +- return CMPLXF(INFINITY, b); +- if (isnan(a)) { +- t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ +- return CMPLXF(a, t); /* return NaN + NaN i */ +- } +- if (isinf(a)) { +- /* +- * csqrtf(inf + NaN i) = inf + NaN i +- * csqrtf(inf + y i) = inf + 0 i +- * csqrtf(-inf + NaN i) = NaN +- inf i +- * csqrtf(-inf + y i) = 0 + inf i +- */ +- if (signbit(a)) +- return CMPLXF(fabsf(b - b), copysignf(a, b)); +- else +- return CMPLXF(a, copysignf(b - b, b)); +- } +- /* +- * The remaining special case (b is NaN) is handled just fine by +- * the normal code path below. +- */ +- +- /* +- * We compute t in double precision to avoid overflow and to +- * provide correct rounding in nearly all cases. +- * This is Algorithm 312, CACM vol 10, Oct 1967. +- */ +- if (a >= 0) { +- t = sqrt((a + hypot(a, b)) * 0.5); +- return CMPLXF(t, b / (2.0 * t)); +- } else { +- t = sqrt((-a + hypot(a, b)) * 0.5); +- return CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b)); +- } +-} +diff -urN orig_musl/musl-1.2.5/src/complex/csqrtl.c /tmp/clean_musltcc/src/complex/csqrtl.c +--- a/musl-1.2.5/src/complex/csqrtl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/csqrtl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-//FIXME +-long double complex csqrtl(long double complex z) +-{ +- return csqrt(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ctan.c /tmp/clean_musltcc/src/complex/ctan.c +--- a/musl-1.2.5/src/complex/ctan.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ctan.c 1969-12-31 16:00:00 +@@ -1,9 +0,0 @@ +-#include "complex_impl.h" +- +-/* tan(z) = -i tanh(i z) */ +- +-double complex ctan(double complex z) +-{ +- z = ctanh(CMPLX(-cimag(z), creal(z))); +- return CMPLX(cimag(z), -creal(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ctanf.c /tmp/clean_musltcc/src/complex/ctanf.c +--- a/musl-1.2.5/src/complex/ctanf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ctanf.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-float complex ctanf(float complex z) +-{ +- z = ctanhf(CMPLXF(-cimagf(z), crealf(z))); +- return CMPLXF(cimagf(z), -crealf(z)); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ctanh.c /tmp/clean_musltcc/src/complex/ctanh.c +--- a/musl-1.2.5/src/complex/ctanh.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ctanh.c 1969-12-31 16:00:00 +@@ -1,129 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_ctanh.c */ +-/*- +- * Copyright (c) 2011 David Schultz +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice unmodified, this list of conditions, and the following +- * disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- */ +-/* +- * Hyperbolic tangent of a complex argument z = x + i y. +- * +- * The algorithm is from: +- * +- * W. Kahan. Branch Cuts for Complex Elementary Functions or Much +- * Ado About Nothing's Sign Bit. In The State of the Art in +- * Numerical Analysis, pp. 165 ff. Iserles and Powell, eds., 1987. +- * +- * Method: +- * +- * Let t = tan(x) +- * beta = 1/cos^2(y) +- * s = sinh(x) +- * rho = cosh(x) +- * +- * We have: +- * +- * tanh(z) = sinh(z) / cosh(z) +- * +- * sinh(x) cos(y) + i cosh(x) sin(y) +- * = --------------------------------- +- * cosh(x) cos(y) + i sinh(x) sin(y) +- * +- * cosh(x) sinh(x) / cos^2(y) + i tan(y) +- * = ------------------------------------- +- * 1 + sinh^2(x) / cos^2(y) +- * +- * beta rho s + i t +- * = ---------------- +- * 1 + beta s^2 +- * +- * Modifications: +- * +- * I omitted the original algorithm's handling of overflow in tan(x) after +- * verifying with nearpi.c that this can't happen in IEEE single or double +- * precision. I also handle large x differently. +- */ +- +-#include "complex_impl.h" +- +-double complex ctanh(double complex z) +-{ +- double x, y; +- double t, beta, s, rho, denom; +- uint32_t hx, ix, lx; +- +- x = creal(z); +- y = cimag(z); +- +- EXTRACT_WORDS(hx, lx, x); +- ix = hx & 0x7fffffff; +- +- /* +- * ctanh(NaN + i 0) = NaN + i 0 +- * +- * ctanh(NaN + i y) = NaN + i NaN for y != 0 +- * +- * The imaginary part has the sign of x*sin(2*y), but there's no +- * special effort to get this right. +- * +- * ctanh(+-Inf +- i Inf) = +-1 +- 0 +- * +- * ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite +- * +- * The imaginary part of the sign is unspecified. This special +- * case is only needed to avoid a spurious invalid exception when +- * y is infinite. +- */ +- if (ix >= 0x7ff00000) { +- if ((ix & 0xfffff) | lx) /* x is NaN */ +- return CMPLX(x, (y == 0 ? y : x * y)); +- SET_HIGH_WORD(x, hx - 0x40000000); /* x = copysign(1, x) */ +- return CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y))); +- } +- +- /* +- * ctanh(+-0 + i NAN) = +-0 + i NaN +- * ctanh(+-0 +- i Inf) = +-0 + i NaN +- * ctanh(x + i NAN) = NaN + i NaN +- * ctanh(x +- i Inf) = NaN + i NaN +- */ +- if (!isfinite(y)) +- return CMPLX(x ? y - y : x, y - y); +- +- /* +- * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the +- * approximation sinh^2(huge) ~= exp(2*huge) / 4. +- * We use a modified formula to avoid spurious overflow. +- */ +- if (ix >= 0x40360000) { /* x >= 22 */ +- double exp_mx = exp(-fabs(x)); +- return CMPLX(copysign(1, x), 4 * sin(y) * cos(y) * exp_mx * exp_mx); +- } +- +- /* Kahan's algorithm */ +- t = tan(y); +- beta = 1.0 + t * t; /* = 1 / cos^2(y) */ +- s = sinh(x); +- rho = sqrt(1 + s * s); /* = cosh(x) */ +- denom = 1 + beta * s * s; +- return CMPLX((beta * rho * s) / denom, t / denom); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ctanhf.c /tmp/clean_musltcc/src/complex/ctanhf.c +--- a/musl-1.2.5/src/complex/ctanhf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ctanhf.c 1969-12-31 16:00:00 +@@ -1,66 +0,0 @@ +-/* origin: FreeBSD /usr/src/lib/msun/src/s_ctanhf.c */ +-/*- +- * Copyright (c) 2011 David Schultz +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without +- * modification, are permitted provided that the following conditions +- * are met: +- * 1. Redistributions of source code must retain the above copyright +- * notice unmodified, this list of conditions, and the following +- * disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright +- * notice, this list of conditions and the following disclaimer in the +- * documentation and/or other materials provided with the distribution. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- */ +-/* +- * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details. +- */ +- +-#include "complex_impl.h" +- +-float complex ctanhf(float complex z) +-{ +- float x, y; +- float t, beta, s, rho, denom; +- uint32_t hx, ix; +- +- x = crealf(z); +- y = cimagf(z); +- +- GET_FLOAT_WORD(hx, x); +- ix = hx & 0x7fffffff; +- +- if (ix >= 0x7f800000) { +- if (ix & 0x7fffff) +- return CMPLXF(x, (y == 0 ? y : x * y)); +- SET_FLOAT_WORD(x, hx - 0x40000000); +- return CMPLXF(x, copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))); +- } +- +- if (!isfinite(y)) +- return CMPLXF(ix ? y - y : x, y - y); +- +- if (ix >= 0x41300000) { /* x >= 11 */ +- float exp_mx = expf(-fabsf(x)); +- return CMPLXF(copysignf(1, x), 4 * sinf(y) * cosf(y) * exp_mx * exp_mx); +- } +- +- t = tanf(y); +- beta = 1.0 + t * t; +- s = sinhf(x); +- rho = sqrtf(1 + s * s); +- denom = 1 + beta * s * s; +- return CMPLXF((beta * rho * s) / denom, t / denom); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ctanhl.c /tmp/clean_musltcc/src/complex/ctanhl.c +--- a/musl-1.2.5/src/complex/ctanhl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ctanhl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include "complex_impl.h" +- +-//FIXME +-long double complex ctanhl(long double complex z) +-{ +- return ctanh(z); +-} +diff -urN orig_musl/musl-1.2.5/src/complex/ctanl.c /tmp/clean_musltcc/src/complex/ctanl.c +--- a/musl-1.2.5/src/complex/ctanl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/complex/ctanl.c 1969-12-31 16:00:00 +@@ -1,14 +0,0 @@ +-#include "complex_impl.h" +- +-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +-long double complex ctanl(long double complex z) +-{ +- return ctan(z); +-} +-#else +-long double complex ctanl(long double complex z) +-{ +- z = ctanhl(CMPLXL(-cimagl(z), creall(z))); +- return CMPLXL(cimagl(z), -creall(z)); +-} +-#endif +diff -urN orig_musl/musl-1.2.5/src/fenv/x86_64/fenv.s /tmp/clean_musltcc/src/fenv/x86_64/fenv.s +--- a/musl-1.2.5/src/fenv/x86_64/fenv.s 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/fenv/x86_64/fenv.s 1969-12-31 16:00:00 +@@ -1,98 +0,0 @@ +-.global feclearexcept +-.type feclearexcept,@function +-feclearexcept: +- # maintain exceptions in the sse mxcsr, clear x87 exceptions +- mov %edi,%ecx +- and $0x3f,%ecx +- fnstsw %ax +- test %eax,%ecx +- jz 1f +- fnclex +-1: stmxcsr -8(%rsp) +- and $0x3f,%eax +- or %eax,-8(%rsp) +- test %ecx,-8(%rsp) +- jz 1f +- not %ecx +- and %ecx,-8(%rsp) +- ldmxcsr -8(%rsp) +-1: xor %eax,%eax +- ret +- +-.global feraiseexcept +-.type feraiseexcept,@function +-feraiseexcept: +- and $0x3f,%edi +- stmxcsr -8(%rsp) +- or %edi,-8(%rsp) +- ldmxcsr -8(%rsp) +- xor %eax,%eax +- ret +- +-.global __fesetround +-.hidden __fesetround +-.type __fesetround,@function +-__fesetround: +- push %rax +- xor %eax,%eax +- mov %edi,%ecx +- fnstcw (%rsp) +- andb $0xf3,1(%rsp) +- or %ch,1(%rsp) +- fldcw (%rsp) +- stmxcsr (%rsp) +- shl $3,%ch +- andb $0x9f,1(%rsp) +- or %ch,1(%rsp) +- ldmxcsr (%rsp) +- pop %rcx +- ret +- +-.global fegetround +-.type fegetround,@function +-fegetround: +- push %rax +- stmxcsr (%rsp) +- pop %rax +- shr $3,%eax +- and $0xc00,%eax +- ret +- +-.global fegetenv +-.type fegetenv,@function +-fegetenv: +- xor %eax,%eax +- fnstenv (%rdi) +- stmxcsr 28(%rdi) +- ret +- +-.global fesetenv +-.type fesetenv,@function +-fesetenv: +- xor %eax,%eax +- inc %rdi +- jz 1f +- fldenv -1(%rdi) +- ldmxcsr 27(%rdi) +- ret +-1: push %rax +- push %rax +- pushq $0xffff +- pushq $0x37f +- fldenv (%rsp) +- pushq $0x1f80 +- ldmxcsr (%rsp) +- add $40,%rsp +- ret +- +-.global fetestexcept +-.type fetestexcept,@function +-fetestexcept: +- and $0x3f,%edi +- push %rax +- stmxcsr (%rsp) +- pop %rsi +- fnstsw %ax +- or %esi,%eax +- and %edi,%eax +- ret +diff -urN orig_musl/musl-1.2.5/src/include/features.h /tmp/clean_musltcc/src/include/features.h +--- a/musl-1.2.5/src/include/features.h 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/include/features.h 2026-04-28 22:51:21 +@@ -5,7 +5,11 @@ + + #define weak __attribute__((__weak__)) + #define hidden __attribute__((__visibility__("hidden"))) ++/* tcc-build: tcc silently ignores __attribute__((alias(...))), leaving ++ every weak_alias target undefined. Emit the alias as raw assembly ++ directives, plus a plain extern decl so callers see a prototype. */ + #define weak_alias(old, new) \ +- extern __typeof(old) new __attribute__((__weak__, __alias__(#old))) ++ extern __typeof(old) new; \ ++ __asm__(".weak " #new "\n.set " #new "," #old) + + #endif +diff -urN orig_musl/musl-1.2.5/src/internal/syscall.h /tmp/clean_musltcc/src/internal/syscall.h +--- a/musl-1.2.5/src/internal/syscall.h 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/internal/syscall.h 2026-04-28 22:05:59 +@@ -403,7 +403,10 @@ + #define sys_wait4(a,b,c,d) __syscall_ret(__sys_wait4(a,b,c,d)) + #define sys_wait4_cp(a,b,c,d) __syscall_ret(__sys_wait4_cp(a,b,c,d)) + +-hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned); ++/* tcc-build: stock tcc 0.9.27 does not parse C99 [static N] array ++ parameter syntax. The static qualifier here is a hint to the compiler ++ only; dropping it preserves identical semantics. */ ++hidden void __procfdname(char __buf[15+3*sizeof(int)], unsigned); + + hidden void *__vdsosym(const char *, const char *); + +diff -urN orig_musl/musl-1.2.5/src/internal/x86_64/syscall.s /tmp/clean_musltcc/src/internal/x86_64/syscall.s +--- a/musl-1.2.5/src/internal/x86_64/syscall.s 1969-12-31 16:00:00 ++++ b/musl-1.2.5/src/internal/x86_64/syscall.s 2026-04-28 20:23:56 +@@ -0,0 +1,13 @@ ++.global __syscall ++.hidden __syscall ++.type __syscall,@function ++__syscall: ++ movq %rdi, %rax /* syscall number */ ++ movq %rsi, %rdi /* arg1 (was C arg2) */ ++ movq %rdx, %rsi /* arg2 (was C arg3) */ ++ movq %rcx, %rdx /* arg3 (was C arg4) */ ++ movq %r8, %r10 /* arg4 (kernel uses r10, not rcx) */ ++ movq %r9, %r8 /* arg5 */ ++ movq 8(%rsp), %r9 /* arg6 from stack */ ++ syscall ++ ret +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/expl.s /tmp/clean_musltcc/src/math/x86_64/expl.s +--- a/musl-1.2.5/src/math/x86_64/expl.s 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/expl.s 1969-12-31 16:00:00 +@@ -1,101 +0,0 @@ +-# exp(x) = 2^hi + 2^hi (2^lo - 1) +-# where hi+lo = log2e*x with 128bit precision +-# exact log2e*x calculation depends on nearest rounding mode +-# using the exact multiplication method of Dekker and Veltkamp +- +-.global expl +-.type expl,@function +-expl: +- fldt 8(%rsp) +- +- # interesting case: 0x1p-32 <= |x| < 16384 +- # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13] +- mov 16(%rsp), %ax +- or $0x8000, %ax +- sub $0xbfdf, %ax +- cmp $45, %ax +- jbe 2f +- test %ax, %ax +- fld1 +- js 1f +- # if |x|>=0x1p14 or nan return 2^trunc(x) +- fscale +- fstp %st(1) +- ret +- # if |x|<0x1p-32 return 1+x +-1: faddp +- ret +- +- # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc +- # it will be wrong on non-nearest rounding mode +-2: fldl2e +- subq $48, %rsp +- # hi = log2e_hi*x +- # 2^hi = exp2l(hi) +- fmul %st(1),%st +- fld %st(0) +- fstpt (%rsp) +- fstpt 16(%rsp) +- fstpt 32(%rsp) +- call exp2l@PLT +- # if 2^hi == inf return 2^hi +- fld %st(0) +- fstpt (%rsp) +- cmpw $0x7fff, 8(%rsp) +- je 1f +- fldt 32(%rsp) +- fldt 16(%rsp) +- # fpu stack: 2^hi x hi +- # exact mult: x*log2e +- fld %st(1) +- # c = 0x1p32+1 +- movq $0x41f0000000100000,%rax +- pushq %rax +- fldl (%rsp) +- # xh = x - c*x + c*x +- # xl = x - xh +- fmulp +- fld %st(2) +- fsub %st(1), %st +- faddp +- fld %st(2) +- fsub %st(1), %st +- # yh = log2e_hi - c*log2e_hi + c*log2e_hi +- movq $0x3ff7154765200000,%rax +- pushq %rax +- fldl (%rsp) +- # fpu stack: 2^hi x hi xh xl yh +- # lo = hi - xh*yh + xl*yh +- fld %st(2) +- fmul %st(1), %st +- fsubp %st, %st(4) +- fmul %st(1), %st +- faddp %st, %st(3) +- # yl = log2e_hi - yh +- movq $0x3de705fc2f000000,%rax +- pushq %rax +- fldl (%rsp) +- # fpu stack: 2^hi x lo xh xl yl +- # lo += xh*yl + xl*yl +- fmul %st, %st(2) +- fmulp %st, %st(1) +- fxch %st(2) +- faddp +- faddp +- # log2e_lo +- movq $0xbfbe,%rax +- pushq %rax +- movq $0x82f0025f2dc582ee,%rax +- pushq %rax +- fldt (%rsp) +- addq $40,%rsp +- # fpu stack: 2^hi x lo log2e_lo +- # lo += log2e_lo*x +- # return 2^hi + 2^hi (2^lo - 1) +- fmulp %st, %st(2) +- faddp +- f2xm1 +- fmul %st(1), %st +- faddp +-1: addq $48, %rsp +- ret +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/fabs.c /tmp/clean_musltcc/src/math/x86_64/fabs.c +--- a/musl-1.2.5/src/math/x86_64/fabs.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/fabs.c 1969-12-31 16:00:00 +@@ -1,10 +0,0 @@ +-#include <math.h> +- +-double fabs(double x) +-{ +- double t; +- __asm__ ("pcmpeqd %0, %0" : "=x"(t)); // t = ~0 +- __asm__ ("psrlq $1, %0" : "+x"(t)); // t >>= 1 +- __asm__ ("andps %1, %0" : "+x"(x) : "x"(t)); // x &= t +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/fabsf.c /tmp/clean_musltcc/src/math/x86_64/fabsf.c +--- a/musl-1.2.5/src/math/x86_64/fabsf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/fabsf.c 1969-12-31 16:00:00 +@@ -1,10 +0,0 @@ +-#include <math.h> +- +-float fabsf(float x) +-{ +- float t; +- __asm__ ("pcmpeqd %0, %0" : "=x"(t)); // t = ~0 +- __asm__ ("psrld $1, %0" : "+x"(t)); // t >>= 1 +- __asm__ ("andps %1, %0" : "+x"(x) : "x"(t)); // x &= t +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/fabsl.c /tmp/clean_musltcc/src/math/x86_64/fabsl.c +--- a/musl-1.2.5/src/math/x86_64/fabsl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/fabsl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include <math.h> +- +-long double fabsl(long double x) +-{ +- __asm__ ("fabs" : "+t"(x)); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/fma.c /tmp/clean_musltcc/src/math/x86_64/fma.c +--- a/musl-1.2.5/src/math/x86_64/fma.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/fma.c 1969-12-31 16:00:00 +@@ -1,23 +0,0 @@ +-#include <math.h> +- +-#if __FMA__ +- +-double fma(double x, double y, double z) +-{ +- __asm__ ("vfmadd132sd %1, %2, %0" : "+x" (x) : "x" (y), "x" (z)); +- return x; +-} +- +-#elif __FMA4__ +- +-double fma(double x, double y, double z) +-{ +- __asm__ ("vfmaddsd %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z)); +- return x; +-} +- +-#else +- +-#include "../fma.c" +- +-#endif +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/fmaf.c /tmp/clean_musltcc/src/math/x86_64/fmaf.c +--- a/musl-1.2.5/src/math/x86_64/fmaf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/fmaf.c 1969-12-31 16:00:00 +@@ -1,23 +0,0 @@ +-#include <math.h> +- +-#if __FMA__ +- +-float fmaf(float x, float y, float z) +-{ +- __asm__ ("vfmadd132ss %1, %2, %0" : "+x" (x) : "x" (y), "x" (z)); +- return x; +-} +- +-#elif __FMA4__ +- +-float fmaf(float x, float y, float z) +-{ +- __asm__ ("vfmaddss %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z)); +- return x; +-} +- +-#else +- +-#include "../fmaf.c" +- +-#endif +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/fmodl.c /tmp/clean_musltcc/src/math/x86_64/fmodl.c +--- a/musl-1.2.5/src/math/x86_64/fmodl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/fmodl.c 1969-12-31 16:00:00 +@@ -1,9 +0,0 @@ +-#include <math.h> +- +-long double fmodl(long double x, long double y) +-{ +- unsigned short fpsr; +- do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); +- while (fpsr & 0x400); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/llrint.c /tmp/clean_musltcc/src/math/x86_64/llrint.c +--- a/musl-1.2.5/src/math/x86_64/llrint.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/llrint.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include <math.h> +- +-long long llrint(double x) +-{ +- long long r; +- __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x)); +- return r; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/llrintf.c /tmp/clean_musltcc/src/math/x86_64/llrintf.c +--- a/musl-1.2.5/src/math/x86_64/llrintf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/llrintf.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include <math.h> +- +-long long llrintf(float x) +-{ +- long long r; +- __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x)); +- return r; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/llrintl.c /tmp/clean_musltcc/src/math/x86_64/llrintl.c +--- a/musl-1.2.5/src/math/x86_64/llrintl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/llrintl.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include <math.h> +- +-long long llrintl(long double x) +-{ +- long long r; +- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st"); +- return r; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/lrint.c /tmp/clean_musltcc/src/math/x86_64/lrint.c +--- a/musl-1.2.5/src/math/x86_64/lrint.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/lrint.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include <math.h> +- +-long lrint(double x) +-{ +- long r; +- __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x)); +- return r; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/lrintf.c /tmp/clean_musltcc/src/math/x86_64/lrintf.c +--- a/musl-1.2.5/src/math/x86_64/lrintf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/lrintf.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include <math.h> +- +-long lrintf(float x) +-{ +- long r; +- __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x)); +- return r; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/lrintl.c /tmp/clean_musltcc/src/math/x86_64/lrintl.c +--- a/musl-1.2.5/src/math/x86_64/lrintl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/lrintl.c 1969-12-31 16:00:00 +@@ -1,8 +0,0 @@ +-#include <math.h> +- +-long lrintl(long double x) +-{ +- long r; +- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st"); +- return r; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/remainderl.c /tmp/clean_musltcc/src/math/x86_64/remainderl.c +--- a/musl-1.2.5/src/math/x86_64/remainderl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/remainderl.c 1969-12-31 16:00:00 +@@ -1,9 +0,0 @@ +-#include <math.h> +- +-long double remainderl(long double x, long double y) +-{ +- unsigned short fpsr; +- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); +- while (fpsr & 0x400); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/remquol.c /tmp/clean_musltcc/src/math/x86_64/remquol.c +--- a/musl-1.2.5/src/math/x86_64/remquol.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/remquol.c 1969-12-31 16:00:00 +@@ -1,32 +0,0 @@ +-#include <math.h> +- +-long double remquol(long double x, long double y, int *quo) +-{ +- signed char *cx = (void *)&x, *cy = (void *)&y; +- /* By ensuring that addresses of x and y cannot be discarded, +- * this empty asm guides GCC into representing extraction of +- * their sign bits as memory loads rather than making x and y +- * not-address-taken internally and using bitfield operations, +- * which in the end wouldn't work out, as extraction from FPU +- * registers needs to go through memory anyway. This way GCC +- * should manage to use incoming stack slots without spills. */ +- __asm__ ("" :: "X"(cx), "X"(cy)); +- +- long double t = x; +- unsigned fpsr; +- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(t), "=a"(fpsr) : "u"(y)); +- while (fpsr & 0x400); +- /* C0, C1, C3 flags in x87 status word carry low bits of quotient: +- * 15 14 13 12 11 10 9 8 +- * . C3 . . . C2 C1 C0 +- * . b1 . . . 0 b0 b2 */ +- unsigned char i = fpsr >> 8; +- i = i>>4 | i<<4; +- /* i[5:2] is now {b0 b2 ? b1}. Retrieve {0 b2 b1 b0} via +- * in-register table lookup. */ +- unsigned qbits = 0x7575313164642020 >> (i & 60); +- qbits &= 7; +- +- *quo = (cx[9]^cy[9]) < 0 ? -qbits : qbits; +- return t; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/rintl.c /tmp/clean_musltcc/src/math/x86_64/rintl.c +--- a/musl-1.2.5/src/math/x86_64/rintl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/rintl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include <math.h> +- +-long double rintl(long double x) +-{ +- __asm__ ("frndint" : "+t"(x)); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/sqrt.c /tmp/clean_musltcc/src/math/x86_64/sqrt.c +--- a/musl-1.2.5/src/math/x86_64/sqrt.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/sqrt.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include <math.h> +- +-double sqrt(double x) +-{ +- __asm__ ("sqrtsd %1, %0" : "=x"(x) : "x"(x)); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/sqrtf.c /tmp/clean_musltcc/src/math/x86_64/sqrtf.c +--- a/musl-1.2.5/src/math/x86_64/sqrtf.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/sqrtf.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include <math.h> +- +-float sqrtf(float x) +-{ +- __asm__ ("sqrtss %1, %0" : "=x"(x) : "x"(x)); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/math/x86_64/sqrtl.c /tmp/clean_musltcc/src/math/x86_64/sqrtl.c +--- a/musl-1.2.5/src/math/x86_64/sqrtl.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/math/x86_64/sqrtl.c 1969-12-31 16:00:00 +@@ -1,7 +0,0 @@ +-#include <math.h> +- +-long double sqrtl(long double x) +-{ +- __asm__ ("fsqrt" : "+t"(x)); +- return x; +-} +diff -urN orig_musl/musl-1.2.5/src/network/lookup.h /tmp/clean_musltcc/src/network/lookup.h +--- a/musl-1.2.5/src/network/lookup.h 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/network/lookup.h 2026-04-28 22:17:25 +@@ -43,9 +43,9 @@ + #define MAXADDRS 48 + #define MAXSERVS 2 + +-hidden int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags); +-hidden int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags); +-hidden int __lookup_ipliteral(struct address buf[static 1], const char *name, int family); ++hidden int __lookup_serv(struct service buf[MAXSERVS], const char *name, int proto, int socktype, int flags); ++hidden int __lookup_name(struct address buf[MAXADDRS], char canon[256], const char *name, int family, int flags); ++hidden int __lookup_ipliteral(struct address buf[1], const char *name, int family); + + hidden int __get_resolv_conf(struct resolvconf *, char *, size_t); + hidden int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *); +diff -urN orig_musl/musl-1.2.5/src/network/lookup_ipliteral.c /tmp/clean_musltcc/src/network/lookup_ipliteral.c +--- a/musl-1.2.5/src/network/lookup_ipliteral.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/network/lookup_ipliteral.c 2026-04-28 22:17:25 +@@ -9,7 +9,7 @@ + #include <ctype.h> + #include "lookup.h" + +-int __lookup_ipliteral(struct address buf[static 1], const char *name, int family) ++int __lookup_ipliteral(struct address buf[1], const char *name, int family) + { + struct in_addr a4; + struct in6_addr a6; +diff -urN orig_musl/musl-1.2.5/src/network/lookup_name.c /tmp/clean_musltcc/src/network/lookup_name.c +--- a/musl-1.2.5/src/network/lookup_name.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/network/lookup_name.c 2026-04-28 22:17:25 +@@ -23,7 +23,7 @@ + return !*s; + } + +-static int name_from_null(struct address buf[static 2], const char *name, int family, int flags) ++static int name_from_null(struct address buf[2], const char *name, int family, int flags) + { + int cnt = 0; + if (name) return 0; +@@ -41,12 +41,12 @@ + return cnt; + } + +-static int name_from_numeric(struct address buf[static 1], const char *name, int family) ++static int name_from_numeric(struct address buf[1], const char *name, int family) + { + return __lookup_ipliteral(buf, name, family); + } + +-static int name_from_hosts(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family) ++static int name_from_hosts(struct address buf[MAXADDRS], char canon[256], const char *name, int family) + { + char line[512]; + size_t l = strlen(name); +@@ -140,7 +140,7 @@ + return 0; + } + +-static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf) ++static int name_from_dns(struct address buf[MAXADDRS], char canon[256], const char *name, int family, const struct resolvconf *conf) + { + unsigned char qbuf[2][280], abuf[2][ABUF_SIZE]; + const unsigned char *qp[2] = { qbuf[0], qbuf[1] }; +@@ -187,7 +187,7 @@ + return EAI_NODATA; + } + +-static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family) ++static int name_from_dns_search(struct address buf[MAXADDRS], char canon[256], const char *name, int family) + { + char search[256]; + struct resolvconf conf; +@@ -305,7 +305,7 @@ + return b->sortkey - a->sortkey; + } + +-int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags) ++int __lookup_name(struct address buf[MAXADDRS], char canon[256], const char *name, int family, int flags) + { + int cnt = 0, i, j; + +diff -urN orig_musl/musl-1.2.5/src/network/lookup_serv.c /tmp/clean_musltcc/src/network/lookup_serv.c +--- a/musl-1.2.5/src/network/lookup_serv.c 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/network/lookup_serv.c 2026-04-28 22:17:25 +@@ -9,7 +9,7 @@ + #include "lookup.h" + #include "stdio_impl.h" + +-int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags) ++int __lookup_serv(struct service buf[MAXSERVS], const char *name, int proto, int socktype, int flags) + { + char line[128]; + int cnt = 0; +diff -urN orig_musl/musl-1.2.5/src/signal/x86_64/sigsetjmp.s /tmp/clean_musltcc/src/signal/x86_64/sigsetjmp.s +--- a/musl-1.2.5/src/signal/x86_64/sigsetjmp.s 2024-02-29 18:07:33 ++++ b/musl-1.2.5/src/signal/x86_64/sigsetjmp.s 1969-12-31 16:00:00 +@@ -1,24 +0,0 @@ +-.global sigsetjmp +-.global __sigsetjmp +-.type sigsetjmp,@function +-.type __sigsetjmp,@function +-sigsetjmp: +-__sigsetjmp: +- test %esi,%esi +- jz 1f +- +- popq 64(%rdi) +- mov %rbx,72+8(%rdi) +- mov %rdi,%rbx +- +- call setjmp@PLT +- +- pushq 64(%rbx) +- mov %rbx,%rdi +- mov %eax,%esi +- mov 72+8(%rbx),%rbx +- +-.hidden __sigsetjmp_tail +- jmp __sigsetjmp_tail +- +-1: jmp setjmp@PLT diff --git a/vendor/upstream/musl-1.2.5.tar.gz b/vendor/upstream/musl-1.2.5.tar.gz Binary files differ.