Summary
Port musl's powf (float power function) from C to Zig. This replaces powf.c, powf_data.c, and powf_data.h with a native Zig implementation in lib/c/math.zig.
Also removes the corresponding entries from wasi_libc.zig since the Zig implementation handles wasi targets.
Implementation
Full port of musl's double-precision log2+exp2 algorithm for powf:
- Uses
POWF_SCALE = 1.0 (non-intrinsic path with POWF_SCALE_BITS = 0)
exp2f uses shift_scaled (0x1.8p+52/N) and poly (not poly_scaled)
- FP exceptions via
fpBarrier pattern (volatile pointer read)
xflowf: only first operand gets sign, second stays positive
y == 1.0 fast path (bitwise compare) to avoid spurious INEXACT
Test Results — All Targets Pass ✅
CI Run
Built stage4 compiler via cmake+ninja with pre-compiled LLVM 21.1.8, then ran zig build test-libc -Dtest-filter=powf across all musl target architectures (4 optimization levels each):
| Target Group |
Targets |
Result |
| x86_64 |
x86_64-linux-musl, muslx32 |
✅ Pass |
| x86 |
x86-linux-musl |
✅ Pass |
| aarch64 |
aarch64-linux-musl, aarch64_be-linux-musl |
✅ Pass |
| arm |
arm-linux-musleabi/hf, armeb-linux-musleabi/hf |
✅ Pass |
| thumb |
thumb-linux-musleabi/hf |
✅ Pass |
| riscv |
riscv32/riscv64-linux-musl |
✅ Pass |
| powerpc |
powerpc/powerpc64/powerpc64le-linux-musl |
✅ Pass |
| s390x |
s390x-linux-musl |
✅ Pass |
| loongarch64 |
loongarch64-linux-musl |
✅ Pass |
| wasm32 |
wasm32-wasi-musl |
✅ Pass |
Part of ctaggart/zig#10
## Summary
Port musl's `powf` (float power function) from C to Zig. This replaces `powf.c`, `powf_data.c`, and `powf_data.h` with a native Zig implementation in `lib/c/math.zig`.
Also removes the corresponding entries from `wasi_libc.zig` since the Zig implementation handles wasi targets.
## Implementation
Full port of musl's double-precision log2+exp2 algorithm for powf:
- Uses `POWF_SCALE = 1.0` (non-intrinsic path with `POWF_SCALE_BITS = 0`)
- `exp2f` uses `shift_scaled` (`0x1.8p+52/N`) and `poly` (not `poly_scaled`)
- FP exceptions via `fpBarrier` pattern (volatile pointer read)
- `xflowf`: only first operand gets sign, second stays positive
- `y == 1.0` fast path (bitwise compare) to avoid spurious INEXACT
## Test Results — All Targets Pass ✅
[CI Run](https://github.com/ctaggart/zig/actions/runs/23981501098)
Built stage4 compiler via cmake+ninja with pre-compiled LLVM 21.1.8, then ran `zig build test-libc -Dtest-filter=powf` across all musl target architectures (4 optimization levels each):
| Target Group | Targets | Result |
|---|---|---|
| x86_64 | x86_64-linux-musl, muslx32 | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104018) |
| x86 | x86-linux-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104014) |
| aarch64 | aarch64-linux-musl, aarch64_be-linux-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104013) |
| arm | arm-linux-musleabi/hf, armeb-linux-musleabi/hf | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104009) |
| thumb | thumb-linux-musleabi/hf | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104017) |
| riscv | riscv32/riscv64-linux-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104015) |
| powerpc | powerpc/powerpc64/powerpc64le-linux-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104023) |
| s390x | s390x-linux-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104012) |
| loongarch64 | loongarch64-linux-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104020) |
| wasm32 | wasm32-wasi-musl | [✅ Pass](https://github.com/ctaggart/zig/actions/runs/23981501098/job/69948104027) |
Part of [ctaggart/zig#10](https://github.com/ctaggart/zig/issues/10)