Here's a patch that I've tested on arm64, amd64 and i386.

The file aarch64_fpmath.h is copied from upstream.

Although the build finished on amd64, I now realise that I presumably
got it wrong when I added "(arch=i386 kfreebsd-i386 hurd-i386)" to the
symbols file: amd64 should be in that list too. Or can you use an
architecture wildcard? Alternatively, you could easily arrange for
those symbols to be in the arm64 library, if you think they should be
there.
diff --git a/Make.inc b/Make.inc
index 386c1dc..541df5f 100644
--- a/Make.inc
+++ b/Make.inc
@@ -38,7 +38,7 @@ ifeq ($(ARCH),mingw32)
 $(error "the mingw32 compiler you are using fails the openblas testsuite. please see the Julia README.windows.md document for a replacement")
 endif
 
-CFLAGS_add += -std=c99 -Wall -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(OPENLIBM_HOME)/ld80 -I$(OPENLIBM_HOME)/$(ARCH) -I$(OPENLIBM_HOME)/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
+CFLAGS_add += -std=c99 -Wall -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(OPENLIBM_HOME)/ld80 -I$(OPENLIBM_HOME)/ld128 -I$(OPENLIBM_HOME)/$(ARCH) -I$(OPENLIBM_HOME)/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
 
 default: all
 
diff --git a/Makefile b/Makefile
index 3c987e9..c0f32c0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,13 @@
 OPENLIBM_HOME=$(abspath .)
 include ./Make.inc
 
+ifeq ($(ARCH), aarch64)
+SUBDIRS = src arm bsdsrc ld128
+else
 SUBDIRS = src $(ARCH) bsdsrc
-ifneq ($(ARCH), arm)
+endif
+
+ifneq (,$(filter amd64 i387, $(ARCH)))
 SUBDIRS += ld80
 endif
 
diff --git a/arm/fenv.h b/arm/fenv.h
index cd25ea9..0d2ef7b 100644
--- a/arm/fenv.h
+++ b/arm/fenv.h
@@ -64,7 +64,10 @@ extern const fenv_t	__fe_dfl_env;
 #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 --git a/bsdsrc/b_tgamma.c b/bsdsrc/b_tgamma.c
index 7380b1d..1f977f4 100644
--- a/bsdsrc/b_tgamma.c
+++ b/bsdsrc/b_tgamma.c
@@ -127,16 +127,16 @@ tgamma(x)
 {
 	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 --git a/debian/libopenlibm1.symbols b/debian/libopenlibm1.symbols
index 84d30e8..a749912 100644
--- a/debian/libopenlibm1.symbols
+++ b/debian/libopenlibm1.symbols
@@ -17,8 +17,8 @@ libopenlibm.so.1 libopenlibm1 #MINVER#
  _ItL_qS5@Base 0.4
  __exp__D@Base 0.4
  __fe_dfl_env@Base 0.4
- __fedisableexcept@Base 0.4
- __feenableexcept@Base 0.4
+ (arch=i386 kfreebsd-i386 hurd-i386)__fedisableexcept@Base 0.4
+ (arch=i386 kfreebsd-i386 hurd-i386)__feenableexcept@Base 0.4
  __fpclassifyd@Base 0.4
  __fpclassifyf@Base 0.4
  __fpclassifyl@Base 0.4
@@ -145,18 +145,18 @@ libopenlibm.so.1 libopenlibm1 #MINVER#
  fdim@Base 0.4
  fdimf@Base 0.4
  fdiml@Base 0.4
- (arch=i386 kfreebsd-i386 hurd-i386)feclearexcept@Base 0.4
- fedisableexcept@Base 0.4
- feenableexcept@Base 0.4
+ (arch=arm64 i386 kfreebsd-i386 hurd-i386)feclearexcept@Base 0.4
+ (arch=i386 kfreebsd-i386 hurd-i386)fedisableexcept@Base 0.4
+ (arch=i386 kfreebsd-i386 hurd-i386)feenableexcept@Base 0.4
  fegetenv@Base 0.4
- (arch=i386 kfreebsd-i386 hurd-i386)fegetexceptflag@Base 0.4
- (arch=i386 kfreebsd-i386 hurd-i386)fegetround@Base 0.4
+ (arch=arm64 i386 kfreebsd-i386 hurd-i386)fegetexceptflag@Base 0.4
+ (arch=arm64 i386 kfreebsd-i386 hurd-i386)fegetround@Base 0.4
  feholdexcept@Base 0.4
  feraiseexcept@Base 0.4
- (arch=i386 kfreebsd-i386 hurd-i386)fesetenv@Base 0.4
+ (arch=arm64 i386 kfreebsd-i386 hurd-i386)fesetenv@Base 0.4
  fesetexceptflag@Base 0.4
- (arch=i386 kfreebsd-i386 hurd-i386)fesetround@Base 0.4
- (arch=i386 kfreebsd-i386 hurd-i386)fetestexcept@Base 0.4
+ (arch=arm64 i386 kfreebsd-i386 hurd-i386)fesetround@Base 0.4
+ (arch=arm64 i386 kfreebsd-i386 hurd-i386)fetestexcept@Base 0.4
  feupdateenv@Base 0.4
  finite@Base 0.4
  finitef@Base 0.4
diff --git a/include/aarch64_fpmath.h b/include/aarch64_fpmath.h
new file mode 100644
index 0000000..c4e407c
--- /dev/null
+++ b/include/aarch64_fpmath.h
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2002, 2003 David Schultz <d...@freebsd.org>
+ * Copyright (2) 2014 The FreeBSD Foundation
+ * 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: head/lib/libc/aarch64/_fpmath.h 281197 2015-04-07 09:52:14Z andrew $
+ */
+
+union IEEEl2bits {
+	long double	e;
+	struct {
+		unsigned long	manl	:64;
+		unsigned long	manh	:48;
+		unsigned int	exp	:15;
+		unsigned int	sign	:1;
+	} bits;
+	/* TODO andrew: Check the packing here */
+	struct {
+		unsigned long	manl	:64;
+		unsigned long	manh	:48;
+		unsigned int	expsign	:16;
+	} xbits;
+};
+
+#define	LDBL_NBIT	0
+#define	LDBL_IMPLICIT_NBIT
+#define	mask_nbit_l(u)	((void)0)
+
+#define	LDBL_MANH_SIZE	48
+#define	LDBL_MANL_SIZE	64
+
+#define	LDBL_TO_ARRAY32(u, a) do {			\
+	(a)[0] = (uint32_t)(u).bits.manl;		\
+	(a)[1] = (uint32_t)((u).bits.manl >> 32);	\
+	(a)[2] = (uint32_t)(u).bits.manh;		\
+	(a)[3] = (uint32_t)((u).bits.manh >> 32);	\
+} while(0)
diff --git a/include/fenv.h b/include/fenv.h
index cfe40b9..5919fff 100644
--- a/include/fenv.h
+++ b/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 --git a/include/fpmath.h b/include/fpmath.h
index 54ee8d4..0799efb 100644
--- a/include/fpmath.h
+++ b/include/fpmath.h
@@ -29,8 +29,9 @@
 #ifndef _FPMATH_H_
 #define _FPMATH_H_
 
-// Currently assumes Intel platform
-#if defined (__i386__) || defined(__x86_64__)
+#if defined(__aarch64__)
+#include "aarch64_fpmath.h"
+#elif defined (__i386__) || defined(__x86_64__)
 #ifdef __LP64__
 #include "amd64_fpmath.h"
 #else 
diff --git a/ld128/Make.files b/ld128/Make.files
index 0eab034..a59f6d3 100644
--- a/ld128/Make.files
+++ b/ld128/Make.files
@@ -1 +1 @@
-SRCS = invtrig.c k_cosl.c k_sinl.c k_tanl.c # s_nanl.c s_exp2l.c 
+$(CUR_SRCS) += invtrig.c k_cosl.c k_sinl.c k_tanl.c s_nanl.c s_exp2l.c
diff --git a/src/Make.files b/src/Make.files
index 668af4c..108e1c6 100644
--- a/src/Make.files
+++ b/src/Make.files
@@ -37,7 +37,7 @@ ifneq ($(OS), WINNT)
 $(CUR_SRCS) += s_nan.c
 endif		
 		
-ifneq ($(ARCH), arm)
+ifneq (,$(filter aarch64 amd64 i387, $(ARCH)))
 # C99 long double functions
 $(CUR_SRCS) +=	s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
 
diff --git a/src/openlibm.h b/src/openlibm.h
index 174ac4a..a1ce6d2 100644
--- a/src/openlibm.h
+++ b/src/openlibm.h
@@ -23,7 +23,7 @@
     #define __WIN32__
 #endif
 
-#ifndef __arm__
+#if defined(__aarch64__) || defined(__i386__) || defined(__x86_64__)
 #define LONG_DOUBLE
 #endif
 

Reply via email to