aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-07-05 03:18:31 +0200
committerGitHub <noreply@github.com>2025-07-05 03:18:31 +0200
commitfc993945a92a1bf2577354359897071ec52f4b90 (patch)
tree083c07bd48a4234c3785cc9ee796b3057c0a83c7 /lib
parentbe20f97eb97d4712bfd9be85ed2e41acbb7718de (diff)
parentb78751051f4b386899fb82054fc008f9dad73432 (diff)
downloadzig-fc993945a92a1bf2577354359897071ec52f4b90.tar.gz
zig-fc993945a92a1bf2577354359897071ec52f4b90.zip
Merge pull request #24335 from kada49/common-impl-libc-floor
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/mingw/math/x86/floorf.S51
-rw-r--r--lib/libc/mingw/math/x86/floorl.S63
-rw-r--r--lib/libc/musl/src/math/aarch64/floor.c7
-rw-r--r--lib/libc/musl/src/math/aarch64/floorf.c7
-rw-r--r--lib/libc/musl/src/math/floor.c31
-rw-r--r--lib/libc/musl/src/math/floorf.c27
-rw-r--r--lib/libc/musl/src/math/floorl.c34
-rw-r--r--lib/libc/musl/src/math/i386/floor.s17
-rw-r--r--lib/libc/musl/src/math/i386/floorf.s1
-rw-r--r--lib/libc/musl/src/math/i386/floorl.s1
-rw-r--r--lib/libc/musl/src/math/powerpc64/floor.c15
-rw-r--r--lib/libc/musl/src/math/powerpc64/floorf.c15
-rw-r--r--lib/libc/musl/src/math/s390x/floor.c15
-rw-r--r--lib/libc/musl/src/math/s390x/floorf.c15
-rw-r--r--lib/libc/musl/src/math/s390x/floorl.c15
15 files changed, 1 insertions, 313 deletions
diff --git a/lib/libc/mingw/math/x86/floorf.S b/lib/libc/mingw/math/x86/floorf.S
deleted file mode 100644
index c6226f82b5..0000000000
--- a/lib/libc/mingw/math/x86/floorf.S
+++ /dev/null
@@ -1,51 +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 <_mingw_mac.h>
-
- .file "floorf.S"
- .text
- .p2align 4,,15
- .globl __MINGW_USYMBOL(floorf)
- .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef
-#ifdef __x86_64__
- .seh_proc __MINGW_USYMBOL(floorf)
-#endif
-__MINGW_USYMBOL(floorf):
-#if defined(_AMD64_) || defined(__x86_64__)
- subq $40, %rsp
- .seh_stackalloc 40
- .seh_endprologue
- unpcklps %xmm0, %xmm0
- cvtps2pd %xmm0, %xmm0
- call floor
- unpcklpd %xmm0, %xmm0
- cvtpd2ps %xmm0, %xmm0
- addq $40, %rsp
- ret
- .seh_endproc
- .def __MINGW_USYMBOL(floor); .scl 2; .type 32; .endef
-#elif defined(_X86_) || defined(__i386__)
- flds 4(%esp)
- subl $8,%esp
-
- fstcw 4(%esp) /* store fpu control word */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl 4(%esp),%edx
- andl $0xf7ff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- fldcw 4(%esp) /* restore original control word */
-
- addl $8,%esp
- ret
-#endif
diff --git a/lib/libc/mingw/math/x86/floorl.S b/lib/libc/mingw/math/x86/floorl.S
deleted file mode 100644
index 6a08d590a1..0000000000
--- a/lib/libc/mingw/math/x86/floorl.S
+++ /dev/null
@@ -1,63 +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 <_mingw_mac.h>
-
- .file "floorl.S"
- .text
-#ifdef __x86_64__
- .align 8
-#else
- .align 4
-#endif
- .globl __MINGW_USYMBOL(floorl)
- .def __MINGW_USYMBOL(floorl); .scl 2; .type 32; .endef
-__MINGW_USYMBOL(floorl):
-#if defined(_AMD64_) || defined(__x86_64__)
- fldt (%rdx)
- subq $24,%rsp
-
- fstcw 8(%rsp) /* store fpu control word */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl 8(%rsp),%edx
- andl $0xf7ff,%edx
- movl %edx,(%rsp)
- fldcw (%rsp) /* load modified control word */
-
- frndint /* round */
-
- fldcw 8(%rsp) /* restore original control word */
-
- addq $24,%rsp
- movq %rcx,%rax
- movq $0,8(%rcx)
- fstpt (%rcx)
- ret
-#elif defined(_X86_) || defined(__i386__)
- fldt 4(%esp)
- subl $8,%esp
-
- fstcw 4(%esp) /* store fpu control word */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl 4(%esp),%edx
- andl $0xf7ff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- fldcw 4(%esp) /* restore original control word */
-
- addl $8,%esp
- ret
-#endif
diff --git a/lib/libc/musl/src/math/aarch64/floor.c b/lib/libc/musl/src/math/aarch64/floor.c
deleted file mode 100644
index 50ffdb281b..0000000000
--- a/lib/libc/musl/src/math/aarch64/floor.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double floor(double x)
-{
- __asm__ ("frintm %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/musl/src/math/aarch64/floorf.c b/lib/libc/musl/src/math/aarch64/floorf.c
deleted file mode 100644
index 8d007e9f84..0000000000
--- a/lib/libc/musl/src/math/aarch64/floorf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float floorf(float x)
-{
- __asm__ ("frintm %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/musl/src/math/floor.c b/lib/libc/musl/src/math/floor.c
deleted file mode 100644
index 14a31cd8c4..0000000000
--- a/lib/libc/musl/src/math/floor.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double floor(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i >> 52 & 0x7ff;
- double_t y;
-
- if (e >= 0x3ff+52 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i >> 63)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3ff-1) {
- FORCE_EVAL(y);
- return u.i >> 63 ? -1 : 0;
- }
- if (y > 0)
- return x + y - 1;
- return x + y;
-}
diff --git a/lib/libc/musl/src/math/floorf.c b/lib/libc/musl/src/math/floorf.c
deleted file mode 100644
index dceec739db..0000000000
--- a/lib/libc/musl/src/math/floorf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "libm.h"
-
-float floorf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f;
- uint32_t m;
-
- if (e >= 23)
- return x;
- if (e >= 0) {
- m = 0x007fffff >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31)
- u.i += m;
- u.i &= ~m;
- } else {
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31 == 0)
- u.i = 0;
- else if (u.i << 1)
- u.f = -1.0;
- }
- return u.f;
-}
diff --git a/lib/libc/musl/src/math/floorl.c b/lib/libc/musl/src/math/floorl.c
deleted file mode 100644
index 16aaec48ee..0000000000
--- a/lib/libc/musl/src/math/floorl.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double floorl(long double x)
-{
- return floor(x);
-}
-#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-
-static const long double toint = 1/LDBL_EPSILON;
-
-long double floorl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- long double y;
-
- if (e >= 0x3fff+LDBL_MANT_DIG-1 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i.se >> 15)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3fff-1) {
- FORCE_EVAL(y);
- return u.i.se >> 15 ? -1 : 0;
- }
- if (y > 0)
- return x + y - 1;
- return x + y;
-}
-#endif
diff --git a/lib/libc/musl/src/math/i386/floor.s b/lib/libc/musl/src/math/i386/floor.s
index 46ba88db53..2571fb3ded 100644
--- a/lib/libc/musl/src/math/i386/floor.s
+++ b/lib/libc/musl/src/math/i386/floor.s
@@ -1,20 +1,5 @@
-.global floorf
-.type floorf,@function
-floorf:
- flds 4(%esp)
- jmp 1f
-
-.global floorl
-.type floorl,@function
-floorl:
- fldt 4(%esp)
- jmp 1f
+/* zig patch: removed `floorl` and `floorf` in favor of using zig compiler_rt's implementations */
-.global floor
-.type floor,@function
-floor:
- fldl 4(%esp)
-1: mov $0x7,%al
1: fstcw 4(%esp)
mov 5(%esp),%ah
mov %al,5(%esp)
diff --git a/lib/libc/musl/src/math/i386/floorf.s b/lib/libc/musl/src/math/i386/floorf.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/musl/src/math/i386/floorf.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/musl/src/math/i386/floorl.s b/lib/libc/musl/src/math/i386/floorl.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/musl/src/math/i386/floorl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/musl/src/math/powerpc64/floor.c b/lib/libc/musl/src/math/powerpc64/floor.c
deleted file mode 100644
index 4e6804449d..0000000000
--- a/lib/libc/musl/src/math/powerpc64/floor.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-double floor(double x)
-{
- __asm__ ("frim %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
-
-#else
-
-#include "../floor.c"
-
-#endif
diff --git a/lib/libc/musl/src/math/powerpc64/floorf.c b/lib/libc/musl/src/math/powerpc64/floorf.c
deleted file mode 100644
index e1031ef401..0000000000
--- a/lib/libc/musl/src/math/powerpc64/floorf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-float floorf(float x)
-{
- __asm__ ("frim %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floorf.c"
-
-#endif
diff --git a/lib/libc/musl/src/math/s390x/floor.c b/lib/libc/musl/src/math/s390x/floor.c
deleted file mode 100644
index 4c0c7f1adb..0000000000
--- a/lib/libc/musl/src/math/s390x/floor.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double floor(double x)
-{
- __asm__ ("fidbra %0, 7, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floor.c"
-
-#endif
diff --git a/lib/libc/musl/src/math/s390x/floorf.c b/lib/libc/musl/src/math/s390x/floorf.c
deleted file mode 100644
index ea28ec7ac5..0000000000
--- a/lib/libc/musl/src/math/s390x/floorf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float floorf(float x)
-{
- __asm__ ("fiebra %0, 7, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floorf.c"
-
-#endif
diff --git a/lib/libc/musl/src/math/s390x/floorl.c b/lib/libc/musl/src/math/s390x/floorl.c
deleted file mode 100644
index 8a0e16a2f8..0000000000
--- a/lib/libc/musl/src/math/s390x/floorl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double floorl(long double x)
-{
- __asm__ ("fixbra %0, 7, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floorl.c"
-
-#endif