authorgravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-01-08 08:19:53+01:00
committergravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-01-10 00:09:54+01:00
log813ae89208ae39181ecfbd6b76a0e8fd9a38e97b
tree5f74b7d66478eecec7395f07b61ed6627ee451d4
parentaa7dac9739f7ce332c2c3841dd7f3a6d17343e0d
signaturebadge-check Signed by SSH key SHA256:A2g6ATENrgLKQcUdthsn72P0njmQxnHSimzwnyJsZzo

libc -> libzigc: copysign


14 files changed, 18 insertions(+), 187 deletions(-)

lib/c/math.zig+18
......@@ -32,6 +32,12 @@ comptime {
3232 @export(&nanf, .{ .name = "nanf", .linkage = common.linkage, .visibility = common.visibility });
3333 @export(&nanl, .{ .name = "nanl", .linkage = common.linkage, .visibility = common.visibility });
3434 }
35
36 if (builtin.target.isMuslLibC()) {
37 @export(&copysignf, .{ .name = "copysignf", .linkage = common.linkage, .visibility = common.visibility });
38 @export(&copysign, .{ .name = "copysign", .linkage = common.linkage, .visibility = common.visibility });
39 }
40 @export(&copysignl, .{ .name = "copysignl", .linkage = common.linkage, .visibility = common.visibility });
3541}
3642
3743fn isnan(x: f64) callconv(.c) c_int {
......@@ -57,3 +63,15 @@ fn nanf(_: [*:0]const c_char) callconv(.c) f32 {
5763fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble {
5864 return std.math.nan(c_longdouble);
5965}
66
67fn copysignf(x: f32, y: f32) callconv(.c) f32 {
68 return std.math.copysign(x, y);
69}
70
71fn copysign(x: f64, y: f64) callconv(.c) f64 {
72 return std.math.copysign(x, y);
73}
74
75fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
76 return std.math.copysign(x, y);
77}
lib/libc/mingw/math/copysign.c deleted-21
......@@ -1,21 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <math.h>
7
8typedef union U
9{
10 unsigned int u[2];
11 double d;
12} U;
13
14double copysign(double x, double y)
15{
16 U h,j;
17 h.d = x;
18 j.d = y;
19 h.u[1] = (h.u[1] & 0x7fffffff) | (j.u[1] & 0x80000000);
20 return h.d;
21}
lib/libc/mingw/math/copysignf.c deleted-19
......@@ -1,19 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#include <math.h>
7
8typedef union ui_f {
9 float f;
10 unsigned int ui;
11} ui_f;
12
13float copysignf(float aX, float aY)
14{
15 ui_f x,y;
16 x.f=aX; y.f=aY;
17 x.ui= (x.ui & 0x7fffffff) | (y.ui & 0x80000000);
18 return x.f;
19}
lib/libc/mingw/math/x86/copysignl.S deleted-44
......@@ -1,44 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6/*
7 * Written by J.T. Conklin <jtc@netbsd.org>.
8 * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
9 * Public domain.
10 */
11#include <_mingw_mac.h>
12
13 .file "copysignl.S"
14 .text
15#ifdef __x86_64__
16 .align 8
17#else
18 .align 4
19#endif
20
21 .globl __MINGW_USYMBOL(copysignl)
22 .def __MINGW_USYMBOL(copysignl); .scl 2; .type 32; .endef
23__MINGW_USYMBOL(copysignl):
24#if defined(_AMD64_) || defined(__x86_64__)
25 movq (%rdx), %rax
26 movq %rax, (%rcx)
27 movq 8(%rdx), %rax
28 movq 8(%r8), %rdx
29 andq $0x7fff, %rax
30 andq $0x8000, %rdx
31 orq %rdx, %rax
32 movq %rax, 8(%rcx)
33 movq %rcx, %rax
34 ret
35#elif defined(_X86_) || defined(__i386__)
36 movl 24(%esp),%edx
37 movl 12(%esp),%eax
38 andl $0x8000,%edx
39 andl $0x7fff,%eax
40 orl %edx,%eax
41 movl %eax,12(%esp)
42 fldt 4(%esp)
43 ret
44#endif
lib/libc/musl/src/math/copysign.c deleted-8
......@@ -1,8 +0,0 @@
1#include "libm.h"
2
3double copysign(double x, double y) {
4 union {double f; uint64_t i;} ux={x}, uy={y};
5 ux.i &= -1ULL/2;
6 ux.i |= uy.i & 1ULL<<63;
7 return ux.f;
8}
lib/libc/musl/src/math/copysignf.c deleted-10
......@@ -1,10 +0,0 @@
1#include <math.h>
2#include <stdint.h>
3
4float copysignf(float x, float y)
5{
6 union {float f; uint32_t i;} ux={x}, uy={y};
7 ux.i &= 0x7fffffff;
8 ux.i |= uy.i & 0x80000000;
9 return ux.f;
10}
lib/libc/musl/src/math/copysignl.c deleted-16
......@@ -1,16 +0,0 @@
1#include "libm.h"
2
3#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4long double copysignl(long double x, long double y)
5{
6 return copysign(x, y);
7}
8#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
9long double copysignl(long double x, long double y)
10{
11 union ldshape ux = {x}, uy = {y};
12 ux.i.se &= 0x7fff;
13 ux.i.se |= uy.i.se & 0x8000;
14 return ux.f;
15}
16#endif
lib/libc/musl/src/math/riscv32/copysign.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double copysign(double x, double y)
6{
7 __asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../copysign.c"
14
15#endif
lib/libc/musl/src/math/riscv32/copysignf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float copysignf(float x, float y)
6{
7 __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../copysignf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/copysign.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double copysign(double x, double y)
6{
7 __asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../copysign.c"
14
15#endif
lib/libc/musl/src/math/riscv64/copysignf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float copysignf(float x, float y)
6{
7 __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../copysignf.c"
14
15#endif
src/libs/mingw.zig-1
......@@ -957,7 +957,6 @@ const mingw32_x86_src = [_][]const u8{
957957 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",
958958 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",
959959 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",
960 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
961960 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
962961 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
963962 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c",
src/libs/musl.zig-7
......@@ -856,9 +856,6 @@ const src_files = [_][]const u8{
856856 "musl/src/math/cbrt.c",
857857 "musl/src/math/cbrtf.c",
858858 "musl/src/math/cbrtl.c",
859 "musl/src/math/copysign.c",
860 "musl/src/math/copysignf.c",
861 "musl/src/math/copysignl.c",
862859 "musl/src/math/__cos.c",
863860 "musl/src/math/__cosdf.c",
864861 "musl/src/math/cosh.c",
......@@ -1048,14 +1045,10 @@ const src_files = [_][]const u8{
10481045 "musl/src/math/rint.c",
10491046 "musl/src/math/rintf.c",
10501047 "musl/src/math/rintl.c",
1051 "musl/src/math/riscv32/copysign.c",
1052 "musl/src/math/riscv32/copysignf.c",
10531048 "musl/src/math/riscv32/fma.c",
10541049 "musl/src/math/riscv32/fmaf.c",
10551050 "musl/src/math/riscv32/sqrt.c",
10561051 "musl/src/math/riscv32/sqrtf.c",
1057 "musl/src/math/riscv64/copysign.c",
1058 "musl/src/math/riscv64/copysignf.c",
10591052 "musl/src/math/riscv64/fma.c",
10601053 "musl/src/math/riscv64/fmaf.c",
10611054 "musl/src/math/riscv64/sqrt.c",
src/libs/wasi_libc.zig-1
......@@ -710,7 +710,6 @@ const libc_top_half_src_files = [_][]const u8{
710710 "musl/src/math/cbrt.c",
711711 "musl/src/math/cbrtf.c",
712712 "musl/src/math/cbrtl.c",
713 "musl/src/math/copysignl.c",
714713 "musl/src/math/__cos.c",
715714 "musl/src/math/__cosdf.c",
716715 "musl/src/math/coshl.c",