Source: openlibm
Version: 0.4.1+dfsg-3
Tags: patch

This builds on arm64 with very few changes. With the attached patch it
passed the test suite and only failed at the dh_makeshlibs stage
because of the list of symbols.

A few notes on the patch:

In several places Intel becomes another architecture rather than the
default.

Makefile, arm/fenv.h, include/fenv.h: Normally people treat
aarch64/arm64 as a separate architecture from arm but in this case
fenv.* is almost the same so I used arm/ for both.

bsdsrc/b_tgamma.c: Ordinary floating-point comparisons with NaN may
set FE_INVALID. They do on arm64, though not on Intel, apparently. So
use the C99 macros instead. (A fun alternative would be to put
"if (x != x) return x;" at the start of the function.)
diff -ru openlibm-0.4.1+dfsg.orig/Makefile openlibm-0.4.1+dfsg/Makefile
--- openlibm-0.4.1+dfsg.orig/Makefile
+++ openlibm-0.4.1+dfsg/Makefile
@@ -1,8 +1,13 @@
 OPENLIBM_HOME=$(abspath .)
 include ./Make.inc
 
+ifeq ($(ARCH), aarch64)
+SUBDIRS = src arm bsdsrc
+else
 SUBDIRS = src $(ARCH) bsdsrc
-ifneq ($(ARCH), arm)
+endif
+
+ifneq (,$(filter amd64 i386, $(ARCH)))
 SUBDIRS += ld80
 endif
 
diff -ru openlibm-0.4.1+dfsg.orig/arm/fenv.h openlibm-0.4.1+dfsg/arm/fenv.h
--- openlibm-0.4.1+dfsg.orig/arm/fenv.h
+++ openlibm-0.4.1+dfsg/arm/fenv.h
@@ -64,7 +64,10 @@
 #define _FPUSW_SHIFT	16
 #define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
 
-#ifdef	ARM_HARD_FLOAT
+#if defined(__aarch64__)
+#define __rfs(__fpsr)   __asm __volatile("mrs %0,fpsr" : "=r" (*(__fpsr)))
+#define __wfs(__fpsr)   __asm __volatile("msr fpsr,%0" : : "r" (__fpsr))
+#elif defined(ARM_HARD_FLOAT)
 #define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
 #define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
 #else
diff -ru openlibm-0.4.1+dfsg.orig/bsdsrc/b_tgamma.c openlibm-0.4.1+dfsg/bsdsrc/b_tgamma.c
--- openlibm-0.4.1+dfsg.orig/bsdsrc/b_tgamma.c
+++ openlibm-0.4.1+dfsg/bsdsrc/b_tgamma.c
@@ -127,16 +127,16 @@
 {
 	struct Double u;
 
-	if (x >= 6) {
+	if (isgreaterequal(x, 6)) {
 		if(x > 171.63)
 			return (x / zero);
 		u = large_gam(x);
 		return(__exp__D(u.a, u.b));
-	} else if (x >= 1.0 + LEFT + x0)
+	} else if (isgreaterequal(x, 1.0 + LEFT + x0))
 		return (small_gam(x));
-	else if (x > 1.e-17)
+	else if (isgreater(x, 1.e-17))
 		return (smaller_gam(x));
-	else if (x > -1.e-17) {
+	else if (isgreater(x, -1.e-17)) {
 		if (x != 0.0)
 			u.a = one - tiny;	/* raise inexact */
 		return (one/x);
diff -ru openlibm-0.4.1+dfsg.orig/include/fenv.h openlibm-0.4.1+dfsg/include/fenv.h
--- openlibm-0.4.1+dfsg.orig/include/fenv.h
+++ openlibm-0.4.1+dfsg/include/fenv.h
@@ -1,6 +1,9 @@
-#ifdef __arm__
+
+#if defined(__aarch64__) || defined(__arm__)
 #include "../arm/fenv.h"
-#else
+#endif
+
+#if defined(__i386__) || defined(__x86_64__)
 #ifdef __LP64
 #include "../amd64/fenv.h"
 #else
diff -ru openlibm-0.4.1+dfsg.orig/src/Make.files openlibm-0.4.1+dfsg/src/Make.files
--- openlibm-0.4.1+dfsg.orig/src/Make.files
+++ openlibm-0.4.1+dfsg/src/Make.files
@@ -37,7 +37,7 @@
 $(CUR_SRCS) += s_nan.c
 endif		
 		
-ifneq ($(ARCH), arm)
+ifneq (,$(filter amd64 i386, $(ARCH)))
 # C99 long double functions
 $(CUR_SRCS) +=	s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
 
diff -ru openlibm-0.4.1+dfsg.orig/src/openlibm.h openlibm-0.4.1+dfsg/src/openlibm.h
--- openlibm-0.4.1+dfsg.orig/src/openlibm.h
+++ openlibm-0.4.1+dfsg/src/openlibm.h
@@ -23,7 +23,7 @@
     #define __WIN32__
 #endif
 
-#ifndef __arm__
+#if defined(__i386__) || defined(__x86_64__)
 #define LONG_DOUBLE
 #endif
 

Reply via email to