mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
libc -> libzigc: copysign
This commit is contained in:
@@ -32,6 +32,12 @@ comptime {
|
||||
@export(&nanf, .{ .name = "nanf", .linkage = common.linkage, .visibility = common.visibility });
|
||||
@export(&nanl, .{ .name = "nanl", .linkage = common.linkage, .visibility = common.visibility });
|
||||
}
|
||||
|
||||
if (builtin.target.isMuslLibC()) {
|
||||
@export(©signf, .{ .name = "copysignf", .linkage = common.linkage, .visibility = common.visibility });
|
||||
@export(©sign, .{ .name = "copysign", .linkage = common.linkage, .visibility = common.visibility });
|
||||
}
|
||||
@export(©signl, .{ .name = "copysignl", .linkage = common.linkage, .visibility = common.visibility });
|
||||
}
|
||||
|
||||
fn isnan(x: f64) callconv(.c) c_int {
|
||||
@@ -57,3 +63,15 @@ fn nanf(_: [*:0]const c_char) callconv(.c) f32 {
|
||||
fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble {
|
||||
return std.math.nan(c_longdouble);
|
||||
}
|
||||
|
||||
fn copysignf(x: f32, y: f32) callconv(.c) f32 {
|
||||
return std.math.copysign(x, y);
|
||||
}
|
||||
|
||||
fn copysign(x: f64, y: f64) callconv(.c) f64 {
|
||||
return std.math.copysign(x, y);
|
||||
}
|
||||
|
||||
fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
|
||||
return std.math.copysign(x, y);
|
||||
}
|
||||
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
typedef union U
|
||||
{
|
||||
unsigned int u[2];
|
||||
double d;
|
||||
} U;
|
||||
|
||||
double copysign(double x, double y)
|
||||
{
|
||||
U h,j;
|
||||
h.d = x;
|
||||
j.d = y;
|
||||
h.u[1] = (h.u[1] & 0x7fffffff) | (j.u[1] & 0x80000000);
|
||||
return h.d;
|
||||
}
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
typedef union ui_f {
|
||||
float f;
|
||||
unsigned int ui;
|
||||
} ui_f;
|
||||
|
||||
float copysignf(float aX, float aY)
|
||||
{
|
||||
ui_f x,y;
|
||||
x.f=aX; y.f=aY;
|
||||
x.ui= (x.ui & 0x7fffffff) | (y.ui & 0x80000000);
|
||||
return x.f;
|
||||
}
|
||||
Vendored
-44
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Changes for long double by Ulrich Drepper <drepper@cygnus.com>
|
||||
* Public domain.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "copysignl.S"
|
||||
.text
|
||||
#ifdef __x86_64__
|
||||
.align 8
|
||||
#else
|
||||
.align 4
|
||||
#endif
|
||||
|
||||
.globl __MINGW_USYMBOL(copysignl)
|
||||
.def __MINGW_USYMBOL(copysignl); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(copysignl):
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
movq (%rdx), %rax
|
||||
movq %rax, (%rcx)
|
||||
movq 8(%rdx), %rax
|
||||
movq 8(%r8), %rdx
|
||||
andq $0x7fff, %rax
|
||||
andq $0x8000, %rdx
|
||||
orq %rdx, %rax
|
||||
movq %rax, 8(%rcx)
|
||||
movq %rcx, %rax
|
||||
ret
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
movl 24(%esp),%edx
|
||||
movl 12(%esp),%eax
|
||||
andl $0x8000,%edx
|
||||
andl $0x7fff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,12(%esp)
|
||||
fldt 4(%esp)
|
||||
ret
|
||||
#endif
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
#include "libm.h"
|
||||
|
||||
double copysign(double x, double y) {
|
||||
union {double f; uint64_t i;} ux={x}, uy={y};
|
||||
ux.i &= -1ULL/2;
|
||||
ux.i |= uy.i & 1ULL<<63;
|
||||
return ux.f;
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float copysignf(float x, float y)
|
||||
{
|
||||
union {float f; uint32_t i;} ux={x}, uy={y};
|
||||
ux.i &= 0x7fffffff;
|
||||
ux.i |= uy.i & 0x80000000;
|
||||
return ux.f;
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
#include "libm.h"
|
||||
|
||||
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
|
||||
long double copysignl(long double x, long double y)
|
||||
{
|
||||
return copysign(x, y);
|
||||
}
|
||||
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
|
||||
long double copysignl(long double x, long double y)
|
||||
{
|
||||
union ldshape ux = {x}, uy = {y};
|
||||
ux.i.se &= 0x7fff;
|
||||
ux.i.se |= uy.i.se & 0x8000;
|
||||
return ux.f;
|
||||
}
|
||||
#endif
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
#if __riscv_flen >= 64
|
||||
|
||||
double copysign(double x, double y)
|
||||
{
|
||||
__asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
|
||||
return x;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../copysign.c"
|
||||
|
||||
#endif
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
#if __riscv_flen >= 32
|
||||
|
||||
float copysignf(float x, float y)
|
||||
{
|
||||
__asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
|
||||
return x;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../copysignf.c"
|
||||
|
||||
#endif
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
#if __riscv_flen >= 64
|
||||
|
||||
double copysign(double x, double y)
|
||||
{
|
||||
__asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
|
||||
return x;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../copysign.c"
|
||||
|
||||
#endif
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
#if __riscv_flen >= 32
|
||||
|
||||
float copysignf(float x, float y)
|
||||
{
|
||||
__asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
|
||||
return x;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../copysignf.c"
|
||||
|
||||
#endif
|
||||
@@ -957,7 +957,6 @@ const mingw32_x86_src = [_][]const u8{
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
|
||||
"math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c",
|
||||
|
||||
@@ -856,9 +856,6 @@ const src_files = [_][]const u8{
|
||||
"musl/src/math/cbrt.c",
|
||||
"musl/src/math/cbrtf.c",
|
||||
"musl/src/math/cbrtl.c",
|
||||
"musl/src/math/copysign.c",
|
||||
"musl/src/math/copysignf.c",
|
||||
"musl/src/math/copysignl.c",
|
||||
"musl/src/math/__cos.c",
|
||||
"musl/src/math/__cosdf.c",
|
||||
"musl/src/math/cosh.c",
|
||||
@@ -1048,14 +1045,10 @@ const src_files = [_][]const u8{
|
||||
"musl/src/math/rint.c",
|
||||
"musl/src/math/rintf.c",
|
||||
"musl/src/math/rintl.c",
|
||||
"musl/src/math/riscv32/copysign.c",
|
||||
"musl/src/math/riscv32/copysignf.c",
|
||||
"musl/src/math/riscv32/fma.c",
|
||||
"musl/src/math/riscv32/fmaf.c",
|
||||
"musl/src/math/riscv32/sqrt.c",
|
||||
"musl/src/math/riscv32/sqrtf.c",
|
||||
"musl/src/math/riscv64/copysign.c",
|
||||
"musl/src/math/riscv64/copysignf.c",
|
||||
"musl/src/math/riscv64/fma.c",
|
||||
"musl/src/math/riscv64/fmaf.c",
|
||||
"musl/src/math/riscv64/sqrt.c",
|
||||
|
||||
@@ -710,7 +710,6 @@ const libc_top_half_src_files = [_][]const u8{
|
||||
"musl/src/math/cbrt.c",
|
||||
"musl/src/math/cbrtf.c",
|
||||
"musl/src/math/cbrtl.c",
|
||||
"musl/src/math/copysignl.c",
|
||||
"musl/src/math/__cos.c",
|
||||
"musl/src/math/__cosdf.c",
|
||||
"musl/src/math/coshl.c",
|
||||
|
||||
Reference in New Issue
Block a user