[haiku-commits] haiku: hrev53745 - headers/posix/arch/sparc64 src/system/libroot/posix/musl/math/sparc

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 21 Jan 2020 19:25:23 -0500 (EST)

hrev53745 adds 3 changesets to branch 'master'
old head: 992ae400ec160a3e2ef6ad71c011cd688c9f2476
new head: 2de6164042b652de21b30f8b8ec1e5d22e9b4488
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=2de6164042b6+%5E992ae400ec16

----------------------------------------------------------------------------

ca9fab68494d: Link host tools with libbsd on haiku host
  
  Needed for the sparc port, allows to build elf2aout which uses err() and
  errx(). Allows to build the sparc port from Haiku.
  
  Change-Id: Ia14dd9b1be1c03b36634a675f1a51eeac8d4aacf
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2129
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

175d1f0eca46: sparc: remove ARM files.
  
  Change-Id: I208baa6a97800a8d3a423ffeb00279767706ddef
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2130
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

2de6164042b6: Add missing fenv.h for sparc.
  
  Borrowed from FreeBSD with some changes to get it building.
  Now we need to rebuild the gcc package...
  
  Change-Id: I6b8dfd7fb6ca912c76e2ff10fbe01ad583a09aec
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2131
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

9 files changed, 267 insertions(+), 90 deletions(-)
build/jam/BuildSetup                             |   1 +
headers/posix/arch/sparc64/fenv.h                | 264 +++++++++++++++++++
headers/posix/fenv.h                             |   2 +
src/system/libroot/posix/musl/math/sparc/fabs.c  |  15 --
src/system/libroot/posix/musl/math/sparc/fabsf.c |  15 --
src/system/libroot/posix/musl/math/sparc/fma.c   |  15 --
src/system/libroot/posix/musl/math/sparc/fmaf.c  |  15 --
src/system/libroot/posix/musl/math/sparc/sqrt.c  |  15 --
src/system/libroot/posix/musl/math/sparc/sqrtf.c |  15 --

############################################################################

Commit:      ca9fab68494da5606dcc52204468ae124bd8bf2b
URL:         https://git.haiku-os.org/haiku/commit/?id=ca9fab68494d
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Jan 19 12:01:57 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Jan 22 00:25:19 2020 UTC

Link host tools with libbsd on haiku host

Needed for the sparc port, allows to build elf2aout which uses err() and
errx(). Allows to build the sparc port from Haiku.

Change-Id: Ia14dd9b1be1c03b36634a675f1a51eeac8d4aacf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2129
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup
index c5d485ebee..8a3bf05663 100644
--- a/build/jam/BuildSetup
+++ b/build/jam/BuildSetup
@@ -389,6 +389,7 @@ if $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
        HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR
                = 
"LIBRARY_PATH=\"$LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)\"" ;
        HOST_PTHREAD_LINKFLAGS = ;
+       HOST_LINKFLAGS += -lbsd ;
        HOST_LIBRARY_NAME_MAP_input_server = /system/servers/input_server ;
        HOST_DEFINES += __STDC_FORMAT_MACROS __STDC_LIMIT_MACROS ;
 

############################################################################

Commit:      175d1f0eca46cef49117bedc37dc1de926221d8d
URL:         https://git.haiku-os.org/haiku/commit/?id=175d1f0eca46
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Jan 19 13:05:21 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Jan 22 00:25:19 2020 UTC

sparc: remove ARM files.

Change-Id: I208baa6a97800a8d3a423ffeb00279767706ddef
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2130
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/musl/math/sparc/fabs.c 
b/src/system/libroot/posix/musl/math/sparc/fabs.c
deleted file mode 100644
index f890520a5c..0000000000
--- a/src/system/libroot/posix/musl/math/sparc/fabs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_PCS_VFP
-
-double fabs(double x)
-{
-       __asm__ ("vabs.f64 %P0, %P1" : "=w"(x) : "w"(x));
-       return x;
-}
-
-#else
-
-#include "../fabs.c"
-
-#endif
diff --git a/src/system/libroot/posix/musl/math/sparc/fabsf.c 
b/src/system/libroot/posix/musl/math/sparc/fabsf.c
deleted file mode 100644
index 4a217c9889..0000000000
--- a/src/system/libroot/posix/musl/math/sparc/fabsf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_PCS_VFP && !BROKEN_VFP_ASM
-
-float fabsf(float x)
-{
-       __asm__ ("vabs.f32 %0, %1" : "=t"(x) : "t"(x));
-       return x;
-}
-
-#else
-
-#include "../fabsf.c"
-
-#endif
diff --git a/src/system/libroot/posix/musl/math/sparc/fma.c 
b/src/system/libroot/posix/musl/math/sparc/fma.c
deleted file mode 100644
index 2a9b8efa77..0000000000
--- a/src/system/libroot/posix/musl/math/sparc/fma.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_FEATURE_FMA && __ARM_FP&8 && !__SOFTFP__
-
-double fma(double x, double y, double z)
-{
-       __asm__ ("vfma.f64 %P0, %P1, %P2" : "+w"(z) : "w"(x), "w"(y));
-       return z;
-}
-
-#else
-
-#include "../fma.c"
-
-#endif
diff --git a/src/system/libroot/posix/musl/math/sparc/fmaf.c 
b/src/system/libroot/posix/musl/math/sparc/fmaf.c
deleted file mode 100644
index a1793d27f1..0000000000
--- a/src/system/libroot/posix/musl/math/sparc/fmaf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_FEATURE_FMA && __ARM_FP&4 && !__SOFTFP__ && !BROKEN_VFP_ASM
-
-float fmaf(float x, float y, float z)
-{
-       __asm__ ("vfma.f32 %0, %1, %2" : "+t"(z) : "t"(x), "t"(y));
-       return z;
-}
-
-#else
-
-#include "../fmaf.c"
-
-#endif
diff --git a/src/system/libroot/posix/musl/math/sparc/sqrt.c 
b/src/system/libroot/posix/musl/math/sparc/sqrt.c
deleted file mode 100644
index 874af9606c..0000000000
--- a/src/system/libroot/posix/musl/math/sparc/sqrt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)
-
-double sqrt(double x)
-{
-       __asm__ ("vsqrt.f64 %P0, %P1" : "=w"(x) : "w"(x));
-       return x;
-}
-
-#else
-
-#include "../sqrt.c"
-
-#endif
diff --git a/src/system/libroot/posix/musl/math/sparc/sqrtf.c 
b/src/system/libroot/posix/musl/math/sparc/sqrtf.c
deleted file mode 100644
index 32693293b4..0000000000
--- a/src/system/libroot/posix/musl/math/sparc/sqrtf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM
-
-float sqrtf(float x)
-{
-       __asm__ ("vsqrt.f32 %0, %1" : "=t"(x) : "t"(x));
-       return x;
-}
-
-#else
-
-#include "../sqrtf.c"
-
-#endif

############################################################################

Revision:    hrev53745
Commit:      2de6164042b652de21b30f8b8ec1e5d22e9b4488
URL:         https://git.haiku-os.org/haiku/commit/?id=2de6164042b6
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Jan 19 14:43:27 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Jan 22 00:25:19 2020 UTC

Add missing fenv.h for sparc.

Borrowed from FreeBSD with some changes to get it building.
Now we need to rebuild the gcc package...

Change-Id: I6b8dfd7fb6ca912c76e2ff10fbe01ad583a09aec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2131
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/headers/posix/arch/sparc64/fenv.h 
b/headers/posix/arch/sparc64/fenv.h
new file mode 100644
index 0000000000..903d770f3d
--- /dev/null
+++ b/headers/posix/arch/sparc64/fenv.h
@@ -0,0 +1,264 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2004-2005 David Schultz <das@xxxxxxxxxxx>
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef        _FENV_H_
+#define        _FENV_H_
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#ifndef        __fenv_static
+#define        __fenv_static   static
+#endif
+
+typedef        uint64_t        fenv_t;
+typedef        uint64_t        fexcept_t;
+
+/* Exception flags */
+#define        FE_INVALID      0x00000200
+#define        FE_DIVBYZERO    0x00000040
+#define        FE_OVERFLOW     0x00000100
+#define        FE_UNDERFLOW    0x00000080
+#define        FE_INEXACT      0x00000020
+#define        FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_INEXACT | \
+                        FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+
+/*
+ * Rounding modes
+ *
+ * We can't just use the hardware bit values here, because that would
+ * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.
+ */
+#define        FE_TONEAREST    0x0
+#define        FE_TOWARDZERO   0x1
+#define        FE_UPWARD       0x2
+#define        FE_DOWNWARD     0x3
+#define        _ROUND_MASK     (FE_TONEAREST | FE_DOWNWARD | \
+                        FE_UPWARD | FE_TOWARDZERO)
+#define        _ROUND_SHIFT    30
+
+__BEGIN_DECLS
+
+/* Default floating-point environment */
+extern const fenv_t    __fe_dfl_env;
+#define        FE_DFL_ENV      (&__fe_dfl_env)
+
+/* We need to be able to map status flag positions to mask flag positions */
+#define _FPUSW_SHIFT   18
+#define        _ENABLE_MASK    (FE_ALL_EXCEPT << _FPUSW_SHIFT)
+
+#define        __ldxfsr(__r)   __asm __volatile("ldx %0, %%fsr" : : "m" (__r))
+#define        __stxfsr(__r)   __asm __volatile("stx %%fsr, %0" : "=m" 
(*(__r)))
+
+__fenv_static __inline int
+feclearexcept(int __excepts)
+{
+       fexcept_t __r;
+
+       __stxfsr(&__r);
+       __r &= ~__excepts;
+       __ldxfsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+       fexcept_t __r;
+
+       __stxfsr(&__r);
+       *__flagp = __r & __excepts;
+       return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+       fexcept_t __r;
+
+       __stxfsr(&__r);
+       __r &= ~__excepts;
+       __r |= *__flagp & __excepts;
+       __ldxfsr(__r);
+       return (0);
+}
+
+/*
+ * It seems to be worthwhile to inline this function even when the
+ * arguments are not compile-time constants.  Perhaps this depends
+ * on the register window.
+ */
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+       volatile double d;
+
+       /*
+        * With a compiler that supports the FENV_ACCESS pragma
+        * properly, simple expressions like '0.0 / 0.0' should
+        * be sufficient to generate traps.  Unfortunately, we
+        * need to bring a volatile variable into the equation
+        * to prevent incorrect optimizations.
+        */
+       if (__excepts & FE_INVALID) {
+               d = 0.0;
+               d = 0.0 / d;
+       }
+       if (__excepts & FE_DIVBYZERO) {
+               d = 0.0;
+               d = 1.0 / d;
+       }
+       if (__excepts & FE_OVERFLOW) {
+               d = 0x1.ffp1023;
+               d *= 2.0;
+       }
+       if (__excepts & FE_UNDERFLOW) {
+               d = 0x1p-1022;
+               d /= 0x1p1023;
+       }
+       if (__excepts & FE_INEXACT) {
+               d = 0x1p-1022;
+               d += 1.0;
+       }
+       return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+       fexcept_t __r;
+
+       __stxfsr(&__r);
+       return (__r & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+       fenv_t __r;
+
+       __stxfsr(&__r);
+       return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+       fenv_t __r;
+
+       if (__round & ~_ROUND_MASK)
+               return (-1);
+       __stxfsr(&__r);
+       __r &= ~(_ROUND_MASK << _ROUND_SHIFT);
+       __r |= __round << _ROUND_SHIFT;
+       __ldxfsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+
+       __stxfsr(__envp);
+       return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+       fenv_t __r;
+
+       __stxfsr(&__r);
+       *__envp = __r;
+       __r &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
+       __ldxfsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+       __ldxfsr(*__envp);
+       return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+       fexcept_t __r;
+
+       __stxfsr(&__r);
+       __ldxfsr(*__envp);
+       feraiseexcept(__r & FE_ALL_EXCEPT);
+       return (0);
+}
+
+#if __BSD_VISIBLE
+
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
+feenableexcept(int __mask)
+{
+       fenv_t __old_r, __new_r;
+
+       __stxfsr(&__old_r);
+       __new_r = __old_r | ((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+       __ldxfsr(__new_r);
+       return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fedisableexcept(int __mask)
+{
+       fenv_t __old_r, __new_r;
+
+       __stxfsr(&__old_r);
+       __new_r = __old_r & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+       __ldxfsr(__new_r);
+       return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fegetexcept(void)
+{
+       fenv_t __r;
+
+       __stxfsr(&__r);
+       return ((__r & _ENABLE_MASK) >> _FPUSW_SHIFT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* !_FENV_H_ */
diff --git a/headers/posix/fenv.h b/headers/posix/fenv.h
index 2c82833090..02a48a2c90 100644
--- a/headers/posix/fenv.h
+++ b/headers/posix/fenv.h
@@ -11,6 +11,8 @@
 #  include <arch/arm64/fenv.h>
 #elif defined(__POWERPC__)
 #  include <arch/ppc/fenv.h>
+#elif defined(__sparc__)
+#  include <arch/sparc64/fenv.h>
 #else
 #  error There is no fenv.h for this architecture!
 #endif


Other related posts:

  • » [haiku-commits] haiku: hrev53745 - headers/posix/arch/sparc64 src/system/libroot/posix/musl/math/sparc - waddlesplash