diff --git a/amd64/bsd_fpu.h b/amd64/bsd_fpu.h index 3096d83..afe5b6b 100644 --- a/amd64/bsd_fpu.h +++ b/amd64/bsd_fpu.h @@ -41,6 +41,8 @@ #ifndef _X86_FPU_H_ #define _X86_FPU_H_ +#include "types-compat.h" + /* Environment information of floating point unit. */ struct env87 { int32_t en_cw; /* control word (16bits) */ @@ -128,7 +130,7 @@ struct savexmm { } sv_fp[8]; struct xmmacc sv_xmm[8]; uint8_t sv_pad[224]; -} __aligned(16); +} __attribute__ ((aligned(16))); #ifdef __i386__ union savefpu { @@ -145,7 +147,7 @@ struct savefpu { } sv_fp[8]; struct xmmacc sv_xmm[16]; uint8_t sv_pad[96]; -} __aligned(16); +} __attribute__ ((aligned(16))); #endif struct xstate_hdr { @@ -168,7 +170,7 @@ struct savexmm_ymm { struct xmmacc sv_xmm[16]; uint8_t sv_pad[96]; struct savexmm_xstate sv_xstate; -} __aligned(64); +} __attribute__ ((aligned(16))); struct savefpu_xstate { struct xstate_hdr sx_hd; @@ -184,7 +186,7 @@ struct savefpu_ymm { struct xmmacc sv_xmm[16]; uint8_t sv_pad[96]; struct savefpu_xstate sv_xstate; -} __aligned(64); +} __attribute__ ((aligned(64))); #undef __envxmm32 #undef __envxmm64 diff --git a/amd64/fenv.c b/amd64/fenv.c index 5b23d9f..3debef6 100644 --- a/amd64/fenv.c +++ b/amd64/fenv.c @@ -26,11 +26,9 @@ * $FreeBSD: src/lib/msun/amd64/fenv.c,v 1.8 2011/10/21 06:25:31 das Exp $ */ -#include -#include #include "bsd_fpu.h" -#define __fenv_static +#define _fenv_static #include "fenv.h" #ifdef __GNUC_GNU_INLINE__ diff --git a/amd64/fenv.h b/amd64/fenv.h index c20fc92..c5ad264 100644 --- a/amd64/fenv.h +++ b/amd64/fenv.h @@ -93,7 +93,7 @@ extern const fenv_t __fe_dfl_env; #define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr)) #define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr))) -__fenv_static inline int +__fenv_static __attribute__((always_inline)) inline int feclearexcept(int __excepts) { fenv_t __env; @@ -126,7 +126,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts) int fesetexceptflag(const fexcept_t *__flagp, int __excepts); int feraiseexcept(int __excepts); -__fenv_static inline int +__fenv_static __attribute__((always_inline)) inline int fetestexcept(int __excepts) { uint32_t __mxcsr; diff --git a/i387/fenv.h b/i387/fenv.h index 0dc51ae..c3a987c 100644 --- a/i387/fenv.h +++ b/i387/fenv.h @@ -29,8 +29,8 @@ #ifndef _FENV_H_ #define _FENV_H_ -#include "include/cdefs-compat.h" -#include "include/types-compat.h" +#include "cdefs-compat.h" +#include "types-compat.h" #ifndef __fenv_static #define __fenv_static static diff --git a/include/fenv.h b/include/fenv.h new file mode 100644 index 0000000..f60bc0d --- /dev/null +++ b/include/fenv.h @@ -0,0 +1,5 @@ +#ifdef __LP64 +#include "../amd64/fenv.h" +#else +#include "../i387/fenv.h" +#endif diff --git a/include/types-compat.h b/include/types-compat.h index f90b396..f8d932e 100644 --- a/include/types-compat.h +++ b/include/types-compat.h @@ -15,7 +15,7 @@ #endif #ifdef __WIN32__ -/* Not sure what to do about __pure2 on linux */ +/* Not sure what to do about __pure2 on windows */ #define __pure2 typedef uint8_t u_int8_t; typedef uint16_t u_int16_t; diff --git a/test/.gitignore b/test/.gitignore index e9c6be8..2a72d0e 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,2 +1,3 @@ /test-float -/test-double \ No newline at end of file +/test-float-system +/test-double-system diff --git a/test/Makefile b/test/Makefile index f741135..cbf04a3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,13 +1,13 @@ OPENLIBM_HOME=$(abspath ..) include ../Make.inc -all: test-double test-float test-double-system +all: test-double test-float test-double-system test-float-system test-double: test-double.c libm-test.c - $(CC) -g $< -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ + $(CC) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ test-float: test-float.c libm-test.c - $(CC) -g $< -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ + $(CC) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ test-double-system: test-double.c libm-test.c $(CC) -g $< -DSYS_MATH_H -lm -o $@ diff --git a/test/libm-test.c b/test/libm-test.c index 74f2665..712a440 100644 --- a/test/libm-test.c +++ b/test/libm-test.c @@ -224,11 +224,13 @@ static FLOAT max_error, real_max_error, imag_max_error; #define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1), \ (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1)) +#ifndef SYS_MATH_H void FUNC(sincos) (int n, FLOAT *s, FLOAT *c) { *s = FUNC(sin) ( *s ); *c = FUNC(cos) ( *c ); } +#endif static void init_max_error (void)