Browse Source

Openlibm changes from msun sync.

Viral B. Shah 9 years ago
parent
commit
53807511ac
100 changed files with 1189 additions and 855 deletions
  1. 1 1
      aarch64/_fpmath.h
  2. 1 1
      amd64/_fpmath.h
  3. 18 20
      amd64/bsd_asm.h
  4. 338 57
      amd64/bsd_cdefs.h
  5. 50 175
      amd64/bsd_fpu.h
  6. 122 86
      amd64/bsd_ieeefp.h
  7. 28 26
      amd64/fenv.c
  8. 0 0
      arm/_fpmath.h
  9. 1 1
      bsdsrc/b_exp.c
  10. 1 1
      bsdsrc/b_log.c
  11. 1 1
      bsdsrc/b_tgamma.c
  12. 1 1
      bsdsrc/mathimpl.h
  13. 1 1
      i387/_fpmath.h
  14. 0 8
      include/openlibm.h
  15. 3 1
      include/openlibm_compat.h
  16. 11 5
      include/openlibm_fenv.h
  17. 246 0
      include/openlibm_fenv_aarch64.h
  18. 0 226
      include/openlibm_fenv_amd64.h
  19. 177 80
      include/openlibm_fenv_x86.h
  20. 25 11
      include/openlibm_math.h
  21. 9 9
      ld128/e_rem_pio2l.h
  22. 1 0
      ld80/e_acoshl.c
  23. 1 0
      ld80/e_atanhl.c
  24. 1 0
      ld80/e_coshl.c
  25. 1 0
      ld80/e_hypotl.c
  26. 2 2
      ld80/e_lgammal_r.c
  27. 1 1
      ld80/e_rem_pio2l.h
  28. 1 0
      ld80/e_sinhl.c
  29. 1 1
      ld80/invtrig.c
  30. 1 1
      ld80/k_cosl.c
  31. 1 1
      ld80/k_sinl.c
  32. 2 2
      ld80/k_tanl.c
  33. 1 0
      ld80/s_asinhl.c
  34. 2 2
      ld80/s_erfl.c
  35. 3 3
      ld80/s_exp2l.c
  36. 2 2
      ld80/s_expl.c
  37. 3 3
      ld80/s_logl.c
  38. 1 1
      ld80/s_nanl.c
  39. 1 0
      ld80/s_tanhl.c
  40. 0 0
      powerpc/_fpmath.h
  41. 1 1
      src/Make.files
  42. 3 3
      src/catrig.c
  43. 3 3
      src/catrigf.c
  44. 3 2
      src/e_acos.c
  45. 2 2
      src/e_acosf.c
  46. 2 2
      src/e_acosh.c
  47. 2 2
      src/e_acoshf.c
  48. 5 4
      src/e_acoshl.c
  49. 2 2
      src/e_acosl.c
  50. 2 2
      src/e_asin.c
  51. 2 2
      src/e_asinf.c
  52. 2 2
      src/e_asinl.c
  53. 2 2
      src/e_atan2.c
  54. 2 2
      src/e_atan2f.c
  55. 2 2
      src/e_atan2l.c
  56. 2 2
      src/e_atanh.c
  57. 2 2
      src/e_atanhf.c
  58. 5 4
      src/e_atanhl.c
  59. 2 2
      src/e_cosh.c
  60. 2 2
      src/e_coshf.c
  61. 3 2
      src/e_coshl.c
  62. 2 2
      src/e_exp.c
  63. 2 2
      src/e_expf.c
  64. 2 2
      src/e_fmod.c
  65. 2 2
      src/e_fmodf.c
  66. 2 2
      src/e_fmodl.c
  67. 2 2
      src/e_gamma.c
  68. 2 2
      src/e_gamma_r.c
  69. 2 2
      src/e_gammaf.c
  70. 2 2
      src/e_gammaf_r.c
  71. 2 2
      src/e_hypot.c
  72. 2 2
      src/e_hypotf.c
  73. 2 2
      src/e_hypotl.c
  74. 2 2
      src/e_j0.c
  75. 2 2
      src/e_j0f.c
  76. 2 2
      src/e_j1.c
  77. 2 2
      src/e_j1f.c
  78. 2 2
      src/e_jn.c
  79. 2 2
      src/e_jnf.c
  80. 2 2
      src/e_lgamma.c
  81. 2 2
      src/e_lgamma_r.c
  82. 2 2
      src/e_lgammaf.c
  83. 2 2
      src/e_lgammaf_r.c
  84. 2 2
      src/e_lgammal.c
  85. 2 2
      src/e_log.c
  86. 2 2
      src/e_log10.c
  87. 2 2
      src/e_log10f.c
  88. 2 2
      src/e_log2.c
  89. 2 2
      src/e_log2f.c
  90. 2 2
      src/e_logf.c
  91. 2 2
      src/e_pow.c
  92. 2 2
      src/e_powf.c
  93. 2 2
      src/e_rem_pio2.c
  94. 2 2
      src/e_rem_pio2f.c
  95. 2 2
      src/e_remainder.c
  96. 2 2
      src/e_remainderf.c
  97. 2 2
      src/e_remainderl.c
  98. 2 2
      src/e_scalb.c
  99. 2 2
      src/e_scalbf.c
  100. 2 2
      src/e_sinh.c

+ 1 - 1
src/aarch64_fpmath.h → aarch64/_fpmath.h

@@ -24,7 +24,7 @@
  * 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 $
+ * $FreeBSD$
  */
 
 union IEEEl2bits {

+ 1 - 1
src/amd64_fpmath.h → amd64/_fpmath.h

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libc/amd64/_fpmath.h,v 1.7 2008/01/17 16:39:06 bde Exp $
+ * $FreeBSD$
  */
 
 union IEEEl2bits {

+ 18 - 20
amd64/bsd_asm.h

@@ -30,15 +30,17 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)DEFS.h	5.1 (Berkeley) 4/23/90
- * $FreeBSD: src/sys/amd64/include/asm.h,v 1.18 2007/08/22 04:26:07 jkoshy Exp $
+ * $FreeBSD$
  */
 
 #ifndef _MACHINE_ASM_H_
 #define	_MACHINE_ASM_H_
 
+
 #ifdef __APPLE__
 #include "../i387/osx_asm.h"
 #define CNAME(x) EXT(x)
+
 #else
 #include "bsd_cdefs.h"
 
@@ -47,7 +49,6 @@
 #define	PIC_GOT(x)	x@GOTPCREL(%rip)
 #else
 #define	PIC_PLT(x)	x
-#define	PIC_GOT(x)	x
 #endif
 
 /*
@@ -60,25 +61,10 @@
 #define CNAME(csym)		csym
 #define HIDENAME(asmsym)	.asmsym
 
-#define _START_ENTRY	.p2align 4,0x90
+#define _START_ENTRY	.text; .p2align 4,0x90
 
-#if defined(__ELF__)
-#define _ENTRY(x)	.text; _START_ENTRY; \
+#define _ENTRY(x)	_START_ENTRY; \
 			.globl CNAME(x); .type CNAME(x),@function; CNAME(x):
-#define	END(x)		.size x, . - x
-
-#elif defined(_WIN32)
-#ifndef _MSC_VER
-#define END(x) .end
-#define _START_ENTRY_WIN .text; _START_ENTRY
-#else
-#define END(x) end
-#define _START_ENTRY_WIN .code; _START_ENTRY
-#endif
-#define _ENTRY(x)	_START_ENTRY_WIN; \
-            .globl CNAME(x); .section .drectve; .ascii " -export:" #x; \
-            .section .text; .def CNAME(x); .scl 2; .type 32; .endef; CNAME(x):
-#endif
 
 #ifdef PROF
 #define	ALTENTRY(x)	_ENTRY(x); \
@@ -96,6 +82,19 @@
 #define	ENTRY(x)	_ENTRY(x)
 #endif
 
+#define	END(x)		.size x, . - x
+
+#endif /* __APPLE */
+
+/*
+ * WEAK_REFERENCE(): create a weak reference alias from sym.
+ * The macro is not a general asm macro that takes arbitrary names,
+ * but one that takes only C names. It does the non-null name
+ * translation inside the macro.
+ */
+#define	WEAK_REFERENCE(sym, alias)					\
+	.weak CNAME(alias);						\
+	.equ CNAME(alias),CNAME(sym)
 
 #define RCSID(x)	.text; .asciz x
 
@@ -106,5 +105,4 @@
 #define __FBSDID(s)	/* nothing */
 #endif /* not lint and not STRIP_FBSDID */
 
-#endif
 #endif /* !_MACHINE_ASM_H_ */

+ 338 - 57
amd64/bsd_cdefs.h

@@ -30,12 +30,31 @@
  * SUCH DAMAGE.
  *
  *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $
+ * $FreeBSD$
  */
 
 #ifndef	_SYS_CDEFS_H_
 #define	_SYS_CDEFS_H_
 
+/*
+ * Testing against Clang-specific extensions.
+ */
+#ifndef	__has_attribute
+#define	__has_attribute(x)	0
+#endif
+#ifndef	__has_extension
+#define	__has_extension		__has_feature
+#endif
+#ifndef	__has_feature
+#define	__has_feature(x)	0
+#endif
+#ifndef	__has_include
+#define	__has_include(x)	0
+#endif
+#ifndef	__has_builtin
+#define	__has_builtin(x)	0
+#endif
+
 #if defined(__cplusplus)
 #define	__BEGIN_DECLS	extern "C" {
 #define	__END_DECLS	}
@@ -53,53 +72,60 @@
 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
 
 #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
-#define __GNUCLIKE_ASM 3
-#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
+#define	__GNUCLIKE_ASM 3
+#define	__GNUCLIKE_MATH_BUILTIN_CONSTANTS
 #else
-#define __GNUCLIKE_ASM 2
+#define	__GNUCLIKE_ASM 2
 #endif
-#define __GNUCLIKE___TYPEOF 1
-#define __GNUCLIKE___OFFSETOF 1
-#define __GNUCLIKE___SECTION 1
+#define	__GNUCLIKE___TYPEOF 1
+#define	__GNUCLIKE___OFFSETOF 1
+#define	__GNUCLIKE___SECTION 1
 
 #ifndef __INTEL_COMPILER
-# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
+#define	__GNUCLIKE_CTOR_SECTION_HANDLING 1
 #endif
 
-#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
-# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
-    && __INTEL_COMPILER < 800
-#  undef __GNUCLIKE_BUILTIN_CONSTANT_P
-# endif
+#define	__GNUCLIKE_BUILTIN_CONSTANT_P 1
+#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
+   __INTEL_COMPILER < 800
+#undef __GNUCLIKE_BUILTIN_CONSTANT_P
+#endif
 
-#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
-# define __GNUCLIKE_BUILTIN_VARARGS 1
-# define __GNUCLIKE_BUILTIN_STDARG 1
-# define __GNUCLIKE_BUILTIN_VAALIST 1
+#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
+#define	__GNUCLIKE_BUILTIN_VARARGS 1
+#define	__GNUCLIKE_BUILTIN_STDARG 1
+#define	__GNUCLIKE_BUILTIN_VAALIST 1
 #endif
 
 #if defined(__GNUC__)
-# define __GNUC_VA_LIST_COMPATIBILITY 1
+#define	__GNUC_VA_LIST_COMPATIBILITY 1
+#endif
+
+/*
+ * Compiler memory barriers, specific to gcc and clang.
+ */
+#if defined(__GNUC__)
+#define	__compiler_membar()	__asm __volatile(" " : : : "memory")
 #endif
 
 #ifndef __INTEL_COMPILER
-# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
-# define __GNUCLIKE_MATH_BUILTIN_RELOPS
+#define	__GNUCLIKE_BUILTIN_NEXT_ARG 1
+#define	__GNUCLIKE_MATH_BUILTIN_RELOPS
 #endif
 
-#define __GNUCLIKE_BUILTIN_MEMCPY 1
+#define	__GNUCLIKE_BUILTIN_MEMCPY 1
 
 /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
-#define __CC_SUPPORTS_INLINE 1
-#define __CC_SUPPORTS___INLINE 1
-#define __CC_SUPPORTS___INLINE__ 1
+#define	__CC_SUPPORTS_INLINE 1
+#define	__CC_SUPPORTS___INLINE 1
+#define	__CC_SUPPORTS___INLINE__ 1
 
-#define __CC_SUPPORTS___FUNC__ 1
-#define __CC_SUPPORTS_WARNING 1
+#define	__CC_SUPPORTS___FUNC__ 1
+#define	__CC_SUPPORTS_WARNING 1
 
-#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
+#define	__CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
 
-#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
+#define	__CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
 
 #endif /* __GNUC__ || __INTEL_COMPILER */
 
@@ -185,8 +211,12 @@
 #define	__unused
 #define	__packed
 #define	__aligned(x)
+#define	__alloc_align(x)
+#define	__alloc_size(x)
 #define	__section(x)
+#define	__weak_symbol
 #else
+#define	__weak_symbol	__attribute__((__weak__))
 #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
 #define	__dead2
 #define	__pure2
@@ -198,7 +228,7 @@
 #define	__unused
 /* XXX Find out what to do for __packed, __aligned and __section */
 #endif
-#if __GNUC_PREREQ__(2, 7)
+#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
 #define	__dead2		__attribute__((__noreturn__))
 #define	__pure2		__attribute__((__const__))
 #define	__unused	__attribute__((__unused__))
@@ -207,17 +237,109 @@
 #define	__aligned(x)	__attribute__((__aligned__(x)))
 #define	__section(x)	__attribute__((__section__(x)))
 #endif
-#if defined(__INTEL_COMPILER)
-#define __dead2		__attribute__((__noreturn__))
-#define __pure2		__attribute__((__const__))
-#define __unused	__attribute__((__unused__))
-#define __used		__attribute__((__used__))
-#define __packed	__attribute__((__packed__))
-#define __aligned(x)	__attribute__((__aligned__(x)))
-#define __section(x)	__attribute__((__section__(x)))
+#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
+#define	__alloc_size(x)	__attribute__((__alloc_size__(x)))
+#else
+#define	__alloc_size(x)
+#endif
+#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
+#define	__alloc_align(x)	__attribute__((__alloc_align__(x)))
+#else
+#define	__alloc_align(x)
+#endif
+#endif /* lint */
+
+#if !__GNUC_PREREQ__(2, 95)
+#define	__alignof(x)	__offsetof(struct { char __a; x __b; }, __b)
+#endif
+
+/*
+ * Keywords added in C11.
+ */
+
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
+
+#if !__has_extension(c_alignas)
+#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
+    __has_extension(cxx_alignas)
+#define	_Alignas(x)		alignas(x)
+#else
+/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
+#define	_Alignas(x)		__aligned(x)
+#endif
+#endif
+
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define	_Alignof(x)		alignof(x)
+#else
+#define	_Alignof(x)		__alignof(x)
+#endif
+
+#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
+/*
+ * No native support for _Atomic(). Place object in structure to prevent
+ * most forms of direct non-atomic access.
+ */
+#define	_Atomic(T)		struct { T volatile __val; }
+#endif
+
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define	_Noreturn		[[noreturn]]
+#else
+#define	_Noreturn		__dead2
+#endif
+
+#if !__has_extension(c_static_assert)
+#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
+    __has_extension(cxx_static_assert)
+#define	_Static_assert(x, y)	static_assert(x, y)
+#elif __GNUC_PREREQ__(4,6)
+/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
+#elif defined(__COUNTER__)
+#define	_Static_assert(x, y)	__Static_assert(x, __COUNTER__)
+#define	__Static_assert(x, y)	___Static_assert(x, y)
+#define	___Static_assert(x, y)	typedef char __assert_ ## y[(x) ? 1 : -1] \
+				__unused
+#else
+#define	_Static_assert(x, y)	struct __hack
 #endif
 #endif
 
+#if !__has_extension(c_thread_local)
+/*
+ * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
+ * without actually supporting the thread_local keyword. Don't check for
+ * the presence of C++11 when defining _Thread_local.
+ */
+#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
+    __has_extension(cxx_thread_local)
+#define	_Thread_local		thread_local
+#else
+#define	_Thread_local		__thread
+#endif
+#endif
+
+#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
+
+/*
+ * Emulation of C11 _Generic().  Unlike the previously defined C11
+ * keywords, it is not possible to implement this using exactly the same
+ * syntax.  Therefore implement something similar under the name
+ * __generic().  Unlike _Generic(), this macro can only distinguish
+ * between a single type, so it requires nested invocations to
+ * distinguish multiple cases.
+ */
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
+    __has_extension(c_generic_selections)
+#define	__generic(expr, t, yes, no)					\
+	_Generic(expr, t: yes, default: no)
+#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
+#define	__generic(expr, t, yes, no)					\
+	__builtin_choose_expr(						\
+	    __builtin_types_compatible_p(__typeof(expr), t), yes, no)
+#endif
+
 #if __GNUC_PREREQ__(2, 96)
 #define	__malloc_like	__attribute__((__malloc__))
 #define	__pure		__attribute__((__pure__))
@@ -239,9 +361,31 @@
 #endif
 
 #if __GNUC_PREREQ__(3, 3)
-#define __nonnull(x)	__attribute__((__nonnull__(x)))
+#define	__nonnull(x)	__attribute__((__nonnull__(x)))
+#define	__nonnull_all	__attribute__((__nonnull__))
 #else
-#define __nonnull(x)
+#define	__nonnull(x)
+#define	__nonnull_all
+#endif
+
+#if __GNUC_PREREQ__(3, 4)
+#define	__fastcall	__attribute__((__fastcall__))
+#define	__result_use_check	__attribute__((__warn_unused_result__))
+#else
+#define	__fastcall
+#define	__result_use_check
+#endif
+
+#if __GNUC_PREREQ__(4, 1)
+#define	__returns_twice	__attribute__((__returns_twice__))
+#else
+#define	__returns_twice
+#endif
+
+#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
+#define	__unreachable()	__builtin_unreachable()
+#else
+#define	__unreachable()	((void)0)
 #endif
 
 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
@@ -253,6 +397,17 @@
 #define	__LONG_LONG_SUPPORTED
 #endif
 
+/* C++11 exposes a load of C99 stuff */
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define	__LONG_LONG_SUPPORTED
+#ifndef	__STDC_LIMIT_MACROS
+#define	__STDC_LIMIT_MACROS
+#endif
+#ifndef	__STDC_CONSTANT_MACROS
+#define	__STDC_CONSTANT_MACROS
+#endif
+#endif
+
 /*
  * GCC 2.95 provides `__restrict' as an extension to C90 to support the
  * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
@@ -296,19 +451,21 @@
  *	  larger code.
  */
 #if __GNUC_PREREQ__(2, 96)
-#define __predict_true(exp)     __builtin_expect((exp), 1)
-#define __predict_false(exp)    __builtin_expect((exp), 0)
+#define	__predict_true(exp)     __builtin_expect((exp), 1)
+#define	__predict_false(exp)    __builtin_expect((exp), 0)
 #else
-#define __predict_true(exp)     (exp)
-#define __predict_false(exp)    (exp)
+#define	__predict_true(exp)     (exp)
+#define	__predict_false(exp)    (exp)
 #endif
 
-#if __GNUC_PREREQ__(4, 2)
-#define	__hidden	__attribute__((__visibility__("hidden")))
+#if __GNUC_PREREQ__(4, 0)
+#define	__null_sentinel	__attribute__((__sentinel__))
 #define	__exported	__attribute__((__visibility__("default")))
+#define	__hidden	__attribute__((__visibility__("hidden")))
 #else
-#define	__hidden
+#define	__null_sentinel
 #define	__exported
+#define	__hidden
 #endif
 
 /*
@@ -316,13 +473,14 @@
  * require it.
  */
 #if __GNUC_PREREQ__(4, 1)
-#define __offsetof(type, field)	 __builtin_offsetof(type, field)
+#define	__offsetof(type, field)	 __builtin_offsetof(type, field)
 #else
 #ifndef __cplusplus
-#define	__offsetof(type, field)	((size_t)(&((type *)0)->field))
+#define	__offsetof(type, field) \
+	((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
 #else
-#define __offsetof(type, field)					\
-  (__offsetof__ (reinterpret_cast <size_t>			\
+#define	__offsetof(type, field)					\
+  (__offsetof__ (reinterpret_cast <__size_t>			\
                  (&reinterpret_cast <const volatile char &>	\
                   (static_cast<type *> (0)->field))))
 #endif
@@ -330,6 +488,22 @@
 #define	__rangeof(type, start, end) \
 	(__offsetof(type, end) - __offsetof(type, start))
 
+/*
+ * Given the pointer x to the member m of the struct s, return
+ * a pointer to the containing structure.  When using GCC, we first
+ * assign pointer x to a local variable, to check that its type is
+ * compatible with member m.
+ */
+#if __GNUC_PREREQ__(3, 1)
+#define	__containerof(x, s, m) ({					\
+	const volatile __typeof(((s *)0)->m) *__x = (x);		\
+	__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
+})
+#else
+#define	__containerof(x, s, m)						\
+	__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
+#endif
+
 /*
  * Compiler-dependent macros to declare that functions take printf-like
  * or scanf-like arguments.  They are null except for versions of gcc
@@ -340,16 +514,39 @@
 #define	__printflike(fmtarg, firstvararg)
 #define	__scanflike(fmtarg, firstvararg)
 #define	__format_arg(fmtarg)
+#define	__strfmonlike(fmtarg, firstvararg)
+#define	__strftimelike(fmtarg, firstvararg)
 #else
 #define	__printflike(fmtarg, firstvararg) \
 	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 #define	__scanflike(fmtarg, firstvararg) \
 	    __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
 #define	__format_arg(fmtarg)	__attribute__((__format_arg__ (fmtarg)))
+#define	__strfmonlike(fmtarg, firstvararg) \
+	    __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
+#define	__strftimelike(fmtarg, firstvararg) \
+	    __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
+#endif
+
+/*
+ * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
+ * the use of non-standard inlining.  In general we should try to avoid
+ * using these but GCC-compatible compilers tend to support the extensions
+ * well enough to use them in limited cases.
+ */ 
+#if defined(__GNUC_GNU_INLINE__) || defined(__GNUC_STDC_INLINE__)
+#if __GNUC_PREREQ__(4, 3) || __has_attribute(__artificial__)
+#define	__gnu_inline	__attribute__((__gnu_inline__, __artificial__))
+#else
+#define	__gnu_inline	__attribute__((__gnu_inline__))
+#endif /* artificial */
+#else
+#define	__gnu_inline
 #endif
 
 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
-#if __FreeBSD_cc_version >= 300001 && defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
+    defined(__GNUC__) && !defined(__INTEL_COMPILER)
 #define	__printf0like(fmtarg, firstvararg) \
 	    __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
 #else
@@ -398,7 +595,7 @@
  * The following definition might not work well if used in header files,
  * but it should be better than nothing.  If you want a "do nothing"
  * version, then it should generate some harmless declaration, such as:
- *    #define __IDSTRING(name,string)	struct __hack
+ *    #define	__IDSTRING(name,string)	struct __hack
  */
 #define	__IDSTRING(name,string)	static const char name[] __unused = string
 #endif
@@ -407,7 +604,7 @@
  * Embed the rcs id of a source file in the resulting library.  Note that in
  * more recent ELF binutils, we use .ident allowing the ID to be stripped.
  * Usage:
- *	__FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $");
+ *	__FBSDID("$FreeBSD$");
  */
 #ifndef	__FBSDID
 #if !defined(lint) && !defined(STRIP_FBSDID)
@@ -450,15 +647,15 @@
 #endif
 
 #ifndef	__DECONST
-#define	__DECONST(type, var)	((type)(uintptr_t)(const void *)(var))
+#define	__DECONST(type, var)	((type)(__uintptr_t)(const void *)(var))
 #endif
 
 #ifndef	__DEVOLATILE
-#define	__DEVOLATILE(type, var)	((type)(uintptr_t)(volatile void *)(var))
+#define	__DEVOLATILE(type, var)	((type)(__uintptr_t)(volatile void *)(var))
 #endif
 
 #ifndef	__DEQUALIFY
-#define	__DEQUALIFY(type, var)	((type)(uintptr_t)(const volatile void *)(var))
+#define	__DEQUALIFY(type, var)	((type)(__uintptr_t)(const volatile void *)(var))
 #endif
 
 /*-
@@ -566,12 +763,96 @@
 #define	__XSI_VISIBLE		0
 #define	__BSD_VISIBLE		0
 #define	__ISO_C_VISIBLE		1999
+#elif defined(_C11_SOURCE)	/* Localism to specify strict C11 env. */
+#define	__POSIX_VISIBLE		0
+#define	__XSI_VISIBLE		0
+#define	__BSD_VISIBLE		0
+#define	__ISO_C_VISIBLE		2011
 #else				/* Default environment: show everything. */
 #define	__POSIX_VISIBLE		200809
 #define	__XSI_VISIBLE		700
 #define	__BSD_VISIBLE		1
-#define	__ISO_C_VISIBLE		1999
+#define	__ISO_C_VISIBLE		2011
+#endif
 #endif
+
+#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__)
+#define	__NO_TLS 1
 #endif
 
+/*
+ * Type Safety Checking
+ *
+ * Clang provides additional attributes to enable checking type safety
+ * properties that cannot be enforced by the C type system. 
+ */
+
+#if __has_attribute(__argument_with_type_tag__) && \
+    __has_attribute(__type_tag_for_datatype__) && !defined(lint)
+#define	__arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
+	    __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
+#define	__datatype_type_tag(kind, type) \
+	    __attribute__((__type_tag_for_datatype__(kind, type)))
+#else
+#define	__arg_type_tag(arg_kind, arg_idx, type_tag_idx)
+#define	__datatype_type_tag(kind, type)
+#endif
+
+/*
+ * Lock annotations.
+ *
+ * Clang provides support for doing basic thread-safety tests at
+ * compile-time, by marking which locks will/should be held when
+ * entering/leaving a functions.
+ *
+ * Furthermore, it is also possible to annotate variables and structure
+ * members to enforce that they are only accessed when certain locks are
+ * held.
+ */
+
+#if __has_extension(c_thread_safety_attributes)
+#define	__lock_annotate(x)	__attribute__((x))
+#else
+#define	__lock_annotate(x)
+#endif
+
+/* Structure implements a lock. */
+#define	__lockable		__lock_annotate(lockable)
+
+/* Function acquires an exclusive or shared lock. */
+#define	__locks_exclusive(...) \
+	__lock_annotate(exclusive_lock_function(__VA_ARGS__))
+#define	__locks_shared(...) \
+	__lock_annotate(shared_lock_function(__VA_ARGS__))
+
+/* Function attempts to acquire an exclusive or shared lock. */
+#define	__trylocks_exclusive(...) \
+	__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
+#define	__trylocks_shared(...) \
+	__lock_annotate(shared_trylock_function(__VA_ARGS__))
+
+/* Function releases a lock. */
+#define	__unlocks(...)		__lock_annotate(unlock_function(__VA_ARGS__))
+
+/* Function asserts that an exclusive or shared lock is held. */
+#define	__asserts_exclusive(...) \
+	__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
+#define	__asserts_shared(...) \
+	__lock_annotate(assert_shared_lock(__VA_ARGS__))
+
+/* Function requires that an exclusive or shared lock is or is not held. */
+#define	__requires_exclusive(...) \
+	__lock_annotate(exclusive_locks_required(__VA_ARGS__))
+#define	__requires_shared(...) \
+	__lock_annotate(shared_locks_required(__VA_ARGS__))
+#define	__requires_unlocked(...) \
+	__lock_annotate(locks_excluded(__VA_ARGS__))
+
+/* Function should not be analyzed. */
+#define	__no_lock_analysis	__lock_annotate(no_thread_safety_analysis)
+
+/* Guard variables and structure members by lock. */
+#define	__guarded_by(x)		__lock_annotate(guarded_by(x))
+#define	__pt_guarded_by(x)	__lock_annotate(pt_guarded_by(x))
+
 #endif /* !_SYS_CDEFS_H_ */

+ 50 - 175
amd64/bsd_fpu.h

@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)npx.h	5.3 (Berkeley) 1/18/91
- * $FreeBSD: src/sys/x86/include/fpu.h,v 1.1 2012/03/16 20:24:30 tijl Exp $
+ * $FreeBSD$
  */
 
 /*
@@ -38,181 +38,56 @@
  * W. Jolitz 1/90
  */
 
-#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) */
-	int32_t		en_sw;		/* status word (16bits) */
-	int32_t		en_tw;		/* tag word (16bits) */
-	int32_t		en_fip;		/* fp instruction pointer */
-	uint16_t	en_fcs;		/* fp code segment selector */
-	uint16_t	en_opcode;	/* opcode last executed (11 bits) */
-	int32_t		en_foo;		/* fp operand offset */
-	int32_t		en_fos;		/* fp operand segment selector */
-};
-
-/* Contents of each x87 floating point accumulator. */
-struct fpacc87 {
-	uint8_t		fp_bytes[10];
-};
-
-/* Floating point context. (i386 fnsave/frstor) */
-struct save87 {
-	struct env87	sv_env;		/* floating point control/status */
-	struct fpacc87	sv_ac[8];	/* accumulator contents, 0-7 */
-	uint8_t		sv_pad0[4];	/* saved status word (now unused) */
-	/*
-	 * Bogus padding for emulators.  Emulators should use their own
-	 * struct and arrange to store into this struct (ending here)
-	 * before it is inspected for ptracing or for core dumps.  Some
-	 * emulators overwrite the whole struct.  We have no good way of
-	 * knowing how much padding to leave.  Leave just enough for the
-	 * GPL emulator's i387_union (176 bytes total).
-	 */
-	uint8_t		sv_pad[64];	/* padding; used by emulators */
-};
-
-/* Contents of each SSE extended accumulator. */
-struct xmmacc {
-	uint8_t		xmm_bytes[16];
-};
-
-/* Contents of the upper 16 bytes of each AVX extended accumulator. */
-struct ymmacc {
-	uint8_t		ymm_bytes[16];
-};
-
-/* Rename structs below depending on machine architecture. */
-#ifdef __i386__
-#define	__envxmm32	envxmm
-#else
-#define	__envxmm32	envxmm32
-#define	__envxmm64	envxmm
-#endif
-
-struct __envxmm32 {
-	uint16_t	en_cw;		/* control word (16bits) */
-	uint16_t	en_sw;		/* status word (16bits) */
-	uint16_t	en_tw;		/* tag word (16bits) */
-	uint16_t	en_opcode;	/* opcode last executed (11 bits) */
-	uint32_t	en_fip;		/* fp instruction pointer */
-	uint16_t	en_fcs;		/* fp code segment selector */
-	uint16_t	en_pad0;	/* padding */
-	uint32_t	en_foo;		/* fp operand offset */
-	uint16_t	en_fos;		/* fp operand segment selector */
-	uint16_t	en_pad1;	/* padding */
-	uint32_t	en_mxcsr;	/* SSE control/status register */
-	uint32_t	en_mxcsr_mask;	/* valid bits in mxcsr */
-};
-
-struct __envxmm64 {
-	uint16_t	en_cw;		/* control word (16bits) */
-	uint16_t	en_sw;		/* status word (16bits) */
-	uint8_t		en_tw;		/* tag word (8bits) */
-	uint8_t		en_zero;
-	uint16_t	en_opcode;	/* opcode last executed (11 bits ) */
-	uint64_t	en_rip;		/* fp instruction pointer */
-	uint64_t	en_rdp;		/* fp operand pointer */
-	uint32_t	en_mxcsr;	/* SSE control/status register */
-	uint32_t	en_mxcsr_mask;	/* valid bits in mxcsr */
-};
-
-/* Floating point context. (i386 fxsave/fxrstor) */
-struct savexmm {
-	struct __envxmm32	sv_env;
-	struct {
-		struct fpacc87	fp_acc;
-		uint8_t		fp_pad[6];      /* padding */
-	} sv_fp[8];
-	struct xmmacc		sv_xmm[8];
-	uint8_t			sv_pad[224];
-} __attribute__ ((aligned(16)));
-
-#ifdef __i386__
-union savefpu {
-	struct save87	sv_87;
-	struct savexmm	sv_xmm;
-};
-#else
-/* Floating point context. (amd64 fxsave/fxrstor) */
-struct savefpu {
-	struct __envxmm64	sv_env;
-	struct {
-		struct fpacc87	fp_acc;
-		uint8_t		fp_pad[6];	/* padding */
-	} sv_fp[8];
-	struct xmmacc		sv_xmm[16];
-	uint8_t			sv_pad[96];
-} __attribute__ ((aligned(16)));
-#endif
-
-struct xstate_hdr {
-	uint64_t	xstate_bv;
-	uint8_t		xstate_rsrv0[16];
-	uint8_t		xstate_rsrv[40];
-};
-
-struct savexmm_xstate {
-	struct xstate_hdr	sx_hd;
-	struct ymmacc		sx_ymm[16];
-};
-
-struct savexmm_ymm {
-	struct __envxmm32	sv_env;
-	struct {
-		struct fpacc87	fp_acc;
-		int8_t		fp_pad[6];	/* padding */
-	} sv_fp[8];
-	struct xmmacc		sv_xmm[16];
-	uint8_t			sv_pad[96];
-	struct savexmm_xstate	sv_xstate;
-} __attribute__ ((aligned(16)));
-
-struct savefpu_xstate {
-	struct xstate_hdr	sx_hd;
-	struct ymmacc		sx_ymm[16];
-};
-
-struct savefpu_ymm {
-	struct __envxmm64	sv_env;
-	struct {
-		struct fpacc87	fp_acc;
-		int8_t		fp_pad[6];	/* padding */
-	} sv_fp[8];
-	struct xmmacc		sv_xmm[16];
-	uint8_t			sv_pad[96];
-	struct savefpu_xstate	sv_xstate;
-} __attribute__ ((aligned(64)));
-
-#undef __envxmm32
-#undef __envxmm64
+#ifndef _MACHINE_FPU_H_
+#define	_MACHINE_FPU_H_
+
+#include <openlibm_compat.h>
+#include <x86/fpu.h>
+
+#ifdef _KERNEL
+
+struct fpu_kern_ctx;
+
+#define	PCB_USER_FPU(pcb) (((pcb)->pcb_flags & PCB_KERNFPU) == 0)
+
+#define	XSAVE_AREA_ALIGN	64
+
+void	fpudna(void);
+void	fpudrop(void);
+void	fpuexit(struct thread *td);
+int	fpuformat(void);
+int	fpugetregs(struct thread *td);
+void	fpuinit(void);
+void	fpurestore(void *addr);
+void	fpuresume(void *addr);
+void	fpusave(void *addr);
+int	fpusetregs(struct thread *td, struct savefpu *addr,
+	    char *xfpustate, size_t xfpustate_size);
+int	fpusetxstate(struct thread *td, char *xfpustate,
+	    size_t xfpustate_size);
+void	fpususpend(void *addr);
+int	fputrap_sse(void);
+int	fputrap_x87(void);
+void	fpuuserinited(struct thread *td);
+struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
+void	fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
+int	fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
+	    u_int flags);
+int	fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
+int	fpu_kern_thread(u_int flags);
+int	is_fpu_kern_thread(u_int flags);
+
+struct savefpu	*fpu_save_area_alloc(void);
+void	fpu_save_area_free(struct savefpu *fsa);
+void	fpu_save_area_reset(struct savefpu *fsa);
 
 /*
- * The hardware default control word for i387's and later coprocessors is
- * 0x37F, giving:
- *
- *	round to nearest
- *	64-bit precision
- *	all exceptions masked.
- *
- * FreeBSD/i386 uses 53 bit precision for things like fadd/fsub/fsqrt etc
- * because of the difference between memory and fpu register stack arguments.
- * If its using an intermediate fpu register, it has 80/64 bits to work
- * with.  If it uses memory, it has 64/53 bits to work with.  However,
- * gcc is aware of this and goes to a fair bit of trouble to make the
- * best use of it.
- *
- * This is mostly academic for AMD64, because the ABI prefers the use
- * SSE2 based math.  For FreeBSD/amd64, we go with the default settings.
+ * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread().
  */
-#define	__INITIAL_FPUCW__	0x037F
-#define	__INITIAL_FPUCW_I386__	0x127F
-#define	__INITIAL_NPXCW__	__INITIAL_FPUCW_I386__
-#define	__INITIAL_MXCSR__	0x1F80
-#define	__INITIAL_MXCSR_MASK__	0xFFBF
+#define	FPU_KERN_NORMAL	0x0000
+#define	FPU_KERN_NOWAIT	0x0001
+#define	FPU_KERN_KTHR	0x0002
+
+#endif
 
-#endif /* !_X86_FPU_H_ */
+#endif /* !_MACHINE_FPU_H_ */

+ 122 - 86
amd64/bsd_ieeefp.h

@@ -11,7 +11,11 @@
  * 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.
- * 3. Neither the name of the University nor the names of its contributors
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -28,28 +32,35 @@
  * SUCH DAMAGE.
  *
  * 	from: @(#) ieeefp.h 	1.0 (Berkeley) 9/23/93
- * $FreeBSD: src/sys/amd64/include/ieeefp.h,v 1.14 2005/04/12 23:12:00 jhb Exp $
+ * $FreeBSD$
  */
 
+#ifndef _MACHINE_IEEEFP_H_
+#define _MACHINE_IEEEFP_H_
+
 /*
- *	IEEE floating point type and constant definitions.
+ * Deprecated historical FPU control interface
+ *
+ * IEEE floating point type, constant and function definitions.
+ * XXX: {FP,SSE}*FLD and {FP,SSE}*OFF are undocumented pollution.
  */
 
-#ifndef _MACHINE_IEEEFP_H_
-#define _MACHINE_IEEEFP_H_
+#ifndef _SYS_CDEFS_H_
+#error this file needs sys/cdefs.h as a prerequisite
+#endif
 
 /*
- * FP rounding modes
+ * Rounding modes.
  */
 typedef enum {
 	FP_RN=0,	/* round to nearest */
-	FP_RM,		/* round down to minus infinity */
-	FP_RP,		/* round up to plus infinity */
+	FP_RM,		/* round down towards minus infinity */
+	FP_RP,		/* round up towards plus infinity */
 	FP_RZ		/* truncate */
 } fp_rnd_t;
 
 /*
- * FP precision modes
+ * Precision (i.e., rounding precision) modes.
  */
 typedef enum {
 	FP_PS=0,	/* 24 bit (single-precision) */
@@ -61,7 +72,7 @@ typedef enum {
 #define fp_except_t	int
 
 /*
- * FP exception masks
+ * Exception bit masks.
  */
 #define FP_X_INV	0x01	/* invalid operation */
 #define FP_X_DNML	0x02	/* denormal */
@@ -72,23 +83,19 @@ typedef enum {
 #define FP_X_STK	0x40	/* stack fault */
 
 /*
- * FP registers
+ * FPU control word bit-field masks.
  */
-#define FP_MSKS_REG	0	/* exception masks */
-#define FP_PRC_REG	0	/* precision */
-#define FP_RND_REG	0	/* direction */
-#define FP_STKY_REG	1	/* sticky flags */
+#define FP_MSKS_FLD	0x3f	/* exception masks field */
+#define FP_PRC_FLD	0x300	/* precision control field */
+#define	FP_RND_FLD	0xc00	/* rounding control field */
 
 /*
- * FP register bit field masks
+ * FPU status word bit-field masks.
  */
-#define FP_MSKS_FLD	0x3f	/* exception masks field */
-#define FP_PRC_FLD	0x300	/* precision control field */
-#define FP_RND_FLD	0xc00	/* round control field */
 #define FP_STKY_FLD	0x3f	/* sticky flags field */
 
 /*
- * SSE mxcsr register bit field masks
+ * SSE mxcsr register bit-field masks.
  */
 #define	SSE_STKY_FLD	0x3f	/* exception flags */
 #define	SSE_DAZ_FLD	0x40	/* Denormals are zero */
@@ -97,15 +104,19 @@ typedef enum {
 #define	SSE_FZ_FLD	0x8000	/* flush to zero on underflow */
 
 /*
- * FP register bit field offsets
+ * FPU control word bit-field offsets (shift counts).
  */
 #define FP_MSKS_OFF	0	/* exception masks offset */
 #define FP_PRC_OFF	8	/* precision control offset */
-#define FP_RND_OFF	10	/* round control offset */
+#define	FP_RND_OFF	10	/* rounding control offset */
+
+/*
+ * FPU status word bit-field offsets (shift counts).
+ */
 #define FP_STKY_OFF	0	/* sticky flags offset */
 
 /*
- * SSE mxcsr register bit field offsets
+ * SSE mxcsr register bit-field offsets (shift counts).
  */
 #define	SSE_STKY_OFF	0	/* exception flags offset */
 #define	SSE_DAZ_OFF	6	/* DAZ exception mask offset */
@@ -113,17 +124,44 @@ typedef enum {
 #define	SSE_RND_OFF	13	/* rounding control offset */
 #define	SSE_FZ_OFF	15	/* flush to zero offset */
 
-#if (defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE__)) || defined(_WIN32) \
-    && !defined(__cplusplus)
+#ifdef __GNUCLIKE_ASM
 
-#define	__fldenv(addr)	__asm __volatile("fldenv %0" : : "m" (*(addr)))
-#define	__fnstenv(addr)	__asm __volatile("fnstenv %0" : "=m" (*(addr)))
 #define	__fldcw(addr)	__asm __volatile("fldcw %0" : : "m" (*(addr)))
+#define	__fldenv(addr)	__asm __volatile("fldenv %0" : : "m" (*(addr)))
 #define	__fnstcw(addr)	__asm __volatile("fnstcw %0" : "=m" (*(addr)))
+#define	__fnstenv(addr)	__asm __volatile("fnstenv %0" : "=m" (*(addr)))
 #define	__fnstsw(addr)	__asm __volatile("fnstsw %0" : "=m" (*(addr)))
 #define	__ldmxcsr(addr)	__asm __volatile("ldmxcsr %0" : : "m" (*(addr)))
 #define	__stmxcsr(addr)	__asm __volatile("stmxcsr %0" : "=m" (*(addr)))
 
+/*
+ * Load the control word.  Be careful not to trap if there is a currently
+ * unmasked exception (ones that will become freshly unmasked are not a
+ * problem).  This case must be handled by a save/restore of the
+ * environment or even of the full x87 state.  Accessing the environment
+ * is very inefficient, so only do it when necessary.
+ */
+static __inline void
+__fnldcw(unsigned short _cw, unsigned short _newcw)
+{
+	struct {
+		unsigned _cw;
+		unsigned _other[6];
+	} _env;
+	unsigned short _sw;
+
+	if ((_cw & FP_MSKS_FLD) != FP_MSKS_FLD) {
+		__fnstsw(&_sw);
+		if (((_sw & ~_cw) & FP_STKY_FLD) != 0) {
+			__fnstenv(&_env);
+			_env._cw = _newcw;
+			__fldenv(&_env);
+			return;
+		}
+	}
+	__fldcw(&_newcw);
+}
+
 /*
  * General notes about conflicting SSE vs FP status bits.
  * This code assumes that software will not fiddle with the control
@@ -135,28 +173,27 @@ typedef enum {
  * merge the two together.  I think.
  */
 
-/* Set rounding control */
-static __inline__ fp_rnd_t
+static __inline fp_rnd_t
 __fpgetround(void)
 {
 	unsigned short _cw;
 
 	__fnstcw(&_cw);
-	return ((_cw & FP_RND_FLD) >> FP_RND_OFF);
+	return ((fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF));
 }
 
-static __inline__ fp_rnd_t
+static __inline fp_rnd_t
 __fpsetround(fp_rnd_t _m)
 {
-	unsigned short _cw;
-	unsigned int _mxcsr;
 	fp_rnd_t _p;
+	unsigned _mxcsr;
+	unsigned short _cw, _newcw;
 
 	__fnstcw(&_cw);
-	_p = (_cw & FP_RND_FLD) >> FP_RND_OFF;
-	_cw &= ~FP_RND_FLD;
-	_cw |= (_m << FP_RND_OFF) & FP_RND_FLD;
-	__fldcw(&_cw);
+	_p = (fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF);
+	_newcw = _cw & ~FP_RND_FLD;
+	_newcw |= (_m << FP_RND_OFF) & FP_RND_FLD;
+	__fnldcw(_cw, _newcw);
 	__stmxcsr(&_mxcsr);
 	_mxcsr &= ~SSE_RND_FLD;
 	_mxcsr |= (_m << SSE_RND_OFF) & SSE_RND_FLD;
@@ -165,108 +202,107 @@ __fpsetround(fp_rnd_t _m)
 }
 
 /*
- * Set precision for fadd/fsub/fsqrt etc x87 instructions
+ * Get or set the rounding precision for x87 arithmetic operations.
  * There is no equivalent SSE mode or control.
  */
-static __inline__ fp_prec_t
+
+static __inline fp_prec_t
 __fpgetprec(void)
 {
 	unsigned short _cw;
 
 	__fnstcw(&_cw);
-	return ((_cw & FP_PRC_FLD) >> FP_PRC_OFF);
+	return ((fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF));
 }
 
-static __inline__ fp_prec_t
-__fpsetprec(fp_rnd_t _m)
+static __inline fp_prec_t
+__fpsetprec(fp_prec_t _m)
 {
-	unsigned short _cw;
 	fp_prec_t _p;
+	unsigned short _cw, _newcw;
 
 	__fnstcw(&_cw);
-	_p = (_cw & FP_PRC_FLD) >> FP_PRC_OFF;
-	_cw &= ~FP_PRC_FLD;
-	_cw |= (_m << FP_PRC_OFF) & FP_PRC_FLD;
-	__fldcw(&_cw);
+	_p = (fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF);
+	_newcw = _cw & ~FP_PRC_FLD;
+	_newcw |= (_m << FP_PRC_OFF) & FP_PRC_FLD;
+	__fnldcw(_cw, _newcw);
 	return (_p);
 }
 
 /*
- * Look at the exception masks
- * Note that x87 masks are inverse of the fp*() functions
- * API.  ie: mask = 1 means disable for x87 and SSE, but
- * for the fp*() api, mask = 1 means enabled.
+ * Get or set the exception mask.
+ * Note that the x87 mask bits are inverted by the API -- a mask bit of 1
+ * means disable for x87 and SSE, but for fp*mask() it means enable.
  */
-static __inline__ fp_except_t
+
+static __inline fp_except_t
 __fpgetmask(void)
 {
 	unsigned short _cw;
 
 	__fnstcw(&_cw);
-	return ((~_cw) & FP_MSKS_FLD);
+	return ((~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF);
 }
 
-static __inline__ fp_except_t
+static __inline fp_except_t
 __fpsetmask(fp_except_t _m)
 {
-	unsigned short _cw;
-	unsigned int _mxcsr;
 	fp_except_t _p;
+	unsigned _mxcsr;
+	unsigned short _cw, _newcw;
 
 	__fnstcw(&_cw);
-	_p = (~_cw) & FP_MSKS_FLD;
-	_cw &= ~FP_MSKS_FLD;
-	_cw |= (~_m) & FP_MSKS_FLD;
-	__fldcw(&_cw);
+	_p = (~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF;
+	_newcw = _cw & ~FP_MSKS_FLD;
+	_newcw |= (~_m << FP_MSKS_OFF) & FP_MSKS_FLD;
+	__fnldcw(_cw, _newcw);
 	__stmxcsr(&_mxcsr);
 	/* XXX should we clear non-ieee SSE_DAZ_FLD and SSE_FZ_FLD ? */
 	_mxcsr &= ~SSE_MSKS_FLD;
-	_mxcsr |= ((~_m) << SSE_MSKS_OFF) & SSE_MSKS_FLD;
+	_mxcsr |= (~_m << SSE_MSKS_OFF) & SSE_MSKS_FLD;
 	__ldmxcsr(&_mxcsr);
 	return (_p);
 }
 
-/* See which sticky exceptions are pending, and reset them */
-static __inline__ fp_except_t
+static __inline fp_except_t
 __fpgetsticky(void)
 {
+	unsigned _ex, _mxcsr;
 	unsigned short _sw;
-	unsigned int _mxcsr;
-	fp_except_t _ex;
 
 	__fnstsw(&_sw);
-	_ex = _sw & FP_STKY_FLD;
+	_ex = (_sw & FP_STKY_FLD) >> FP_STKY_OFF;
 	__stmxcsr(&_mxcsr);
-	_ex |= _mxcsr & SSE_STKY_FLD;
-	return (_ex);
+	_ex |= (_mxcsr & SSE_STKY_FLD) >> SSE_STKY_OFF;
+	return ((fp_except_t)_ex);
 }
 
-#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE__ && !__cplusplus */
+#endif /* __GNUCLIKE_ASM */
 
-#if !defined(__IEEEFP_NOINLINES__) && !defined(__cplusplus) \
-    && defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE__)
+#if !defined(__IEEEFP_NOINLINES__) && defined(__GNUCLIKE_ASM)
 
-#define	fpgetround()	__fpgetround()
-#define	fpsetround(_m)	__fpsetround(_m)
-#define	fpgetprec()	__fpgetprec()
-#define	fpsetprec(_m)	__fpsetprec(_m)
 #define	fpgetmask()	__fpgetmask()
-#define	fpsetmask(_m)	__fpsetmask(_m)
+#define	fpgetprec()	__fpgetprec()
+#define	fpgetround()	__fpgetround()
 #define	fpgetsticky()	__fpgetsticky()
+#define	fpsetmask(m)	__fpsetmask(m)
+#define	fpsetprec(m)	__fpsetprec(m)
+#define	fpsetround(m)	__fpsetround(m)
 
-/* Suppress prototypes in the MI header. */
-#define	_IEEEFP_INLINED_	1
-
-#else /* !__IEEEFP_NOINLINES__ && !__cplusplus && __GNUCLIKE_ASM
-         && __CC_SUPPORTS___INLINE__ */
+#else /* !(!__IEEEFP_NOINLINES__ && __GNUCLIKE_ASM) */
 
-/* Augment the userland declarations */
+/* Augment the userland declarations. */
 __BEGIN_DECLS
-extern fp_prec_t fpgetprec(void);
-extern fp_prec_t fpsetprec(fp_prec_t);
+extern fp_rnd_t    fpgetround(void);
+extern fp_rnd_t    fpsetround(fp_rnd_t);
+extern fp_except_t fpgetmask(void);
+extern fp_except_t fpsetmask(fp_except_t);
+extern fp_except_t fpgetsticky(void);
+extern fp_except_t fpsetsticky(fp_except_t);
+fp_prec_t	fpgetprec(void);
+fp_prec_t	fpsetprec(fp_prec_t);
 __END_DECLS
 
-#endif /* !__IEEEFP_NOINLINES__ && !__cplusplus && __GNUCLIKE_ASM
-          && __CC_SUPPORTS___INLINE__ */
+#endif /* !__IEEEFP_NOINLINES__ && __GNUCLIKE_ASM */
 
 #endif /* !_MACHINE_IEEEFP_H_ */

+ 28 - 26
amd64/fenv.c

@@ -23,16 +23,15 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/msun/amd64/fenv.c,v 1.8 2011/10/21 06:25:31 das Exp $
+ * $FreeBSD$
  */
 
+#include <sys/cdefs.h>
+#include <sys/types.h>
 #include "bsd_fpu.h"
-#include "math_private.h"
 
-#ifdef _WIN32
-#define __fenv_static
-#endif
-#include <openlibm_fenv.h>
+#define	__fenv_static
+#include "openlibm_fenv.h"
 
 #ifdef __GNUC_GNU_INLINE__
 #error "This file must be compiled with C99 'inline' semantics"
@@ -48,10 +47,10 @@ const fenv_t __fe_dfl_env = {
 	__INITIAL_MXCSR__
 };
 
-extern inline DLLEXPORT int feclearexcept(int __excepts);
-extern inline DLLEXPORT int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
 
-DLLEXPORT int
+int
 fesetexceptflag(const fexcept_t *flagp, int excepts)
 {
 	fenv_t env;
@@ -69,7 +68,7 @@ fesetexceptflag(const fexcept_t *flagp, int excepts)
 	return (0);
 }
 
-DLLEXPORT int
+int
 feraiseexcept(int excepts)
 {
 	fexcept_t ex = excepts;
@@ -79,11 +78,11 @@ feraiseexcept(int excepts)
 	return (0);
 }
 
-extern inline DLLEXPORT int fetestexcept(int __excepts);
-extern inline DLLEXPORT int fegetround(void);
-extern inline DLLEXPORT int fesetround(int __round);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
 
-DLLEXPORT int
+int
 fegetenv(fenv_t *envp)
 {
 
@@ -97,10 +96,10 @@ fegetenv(fenv_t *envp)
 	return (0);
 }
 
-DLLEXPORT int
+int
 feholdexcept(fenv_t *envp)
 {
-	uint32_t mxcsr;
+	__uint32_t mxcsr;
 
 	__stmxcsr(&mxcsr);
 	__fnstenv(&envp->__x87);
@@ -112,13 +111,13 @@ feholdexcept(fenv_t *envp)
 	return (0);
 }
 
-extern inline DLLEXPORT int fesetenv(const fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
 
-DLLEXPORT int
+int
 feupdateenv(const fenv_t *envp)
 {
-	uint32_t mxcsr;
-	uint16_t status;
+	__uint32_t mxcsr;
+	__uint16_t status;
 
 	__fnstsw(&status);
 	__stmxcsr(&mxcsr);
@@ -128,10 +127,10 @@ feupdateenv(const fenv_t *envp)
 }
 
 int
-feenableexcept(int mask)
+__feenableexcept(int mask)
 {
-	uint32_t mxcsr, omask;
-	uint16_t control;
+	__uint32_t mxcsr, omask;
+	__uint16_t control;
 
 	mask &= FE_ALL_EXCEPT;
 	__fnstcw(&control);
@@ -145,10 +144,10 @@ feenableexcept(int mask)
 }
 
 int
-fedisableexcept(int mask)
+__fedisableexcept(int mask)
 {
-	uint32_t mxcsr, omask;
-	uint16_t control;
+	__uint32_t mxcsr, omask;
+	__uint16_t control;
 
 	mask &= FE_ALL_EXCEPT;
 	__fnstcw(&control);
@@ -160,3 +159,6 @@ fedisableexcept(int mask)
 	__ldmxcsr(mxcsr);
 	return (omask);
 }
+
+__weak_reference(__feenableexcept, feenableexcept);
+__weak_reference(__fedisableexcept, fedisableexcept);

+ 0 - 0
src/arm_fpmath.h → arm/_fpmath.h


+ 1 - 1
bsdsrc/b_exp.c

@@ -28,7 +28,7 @@
  */
 
 /* @(#)exp.c	8.1 (Berkeley) 6/4/93 */
-#include "cdefs-compat.h"
+#include "openlibm_compat.h"
 //__FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_exp.c,v 1.9 2011/10/16 05:37:20 das Exp $");
 
 #include <openlibm_math.h>

+ 1 - 1
bsdsrc/b_log.c

@@ -28,7 +28,7 @@
  */
 
 /* @(#)log.c	8.2 (Berkeley) 11/30/93 */
-#include "cdefs-compat.h"
+#include "openlibm_compat.h"
 //__FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_log.c,v 1.9 2008/02/22 02:26:51 das Exp $");
 
 #include <openlibm_math.h>

+ 1 - 1
bsdsrc/b_tgamma.c

@@ -28,7 +28,7 @@
  */
 
 /* @(#)gamma.c	8.1 (Berkeley) 6/4/93 */
-#include "cdefs-compat.h"
+#include "openlibm_compat.h"
 //__FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_tgamma.c,v 1.10 2008/02/22 02:26:51 das Exp $");
 
 /*

+ 1 - 1
bsdsrc/mathimpl.h

@@ -33,7 +33,7 @@
 #ifndef _MATHIMPL_H_
 #define	_MATHIMPL_H_
 
-#include "cdefs-compat.h"
+#include "openlibm_compat.h"
 #include "math_private.h"
 
 /*

+ 1 - 1
src/i386_fpmath.h → i387/_fpmath.h

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libc/i386/_fpmath.h,v 1.6 2008/01/17 16:39:06 bde Exp $
+ * $FreeBSD$
  */
 
 union IEEEl2bits {

+ 0 - 8
include/openlibm.h

@@ -1,8 +0,0 @@
-#ifndef OPENLIBM_H
-#define OPENLIBM_H
-
-#include <openlibm_complex.h>
-#include <openlibm_fenv.h>
-#include <openlibm_math.h>
-
-#endif /* !OPENLIBM_H */

+ 3 - 1
include/openlibm_compat.h

@@ -105,6 +105,8 @@ typedef uint64_t              u_int64_t;
 
 typedef float float_t;
 
-#define __always_inline
+#ifndef __always_inline
+# define __always_inline __inline __attribute__ ((__always_inline__))
+#endif
 
 #endif

+ 11 - 5
include/openlibm_fenv.h

@@ -1,17 +1,23 @@
+#ifndef _OPENLIBM_FENV_H
+
+#define _OPENLIBM_FENV_H
+
 #ifdef OPENLIBM_USE_HOST_FENV_H
 #include <fenv.h>
 #else /* !OPENLIBM_USE_HOST_FENV_H */
 
 #if defined(__arm__)
 #include <openlibm_fenv_arm.h>
-#elif defined(__x86_64__)
-#include <openlibm_fenv_amd64.h>
-#elif defined(__i386__)
-#include <openlibm_fenv_i387.h>
+#elif defined(__aarch64__)
+#include <openlibm_fenv_aarch64.h>
+#elif defined(__i386__) || defined(__x86_64__)
+#include <openlibm_fenv_x86.h>
 #elif defined(__powerpc__)
 #include <openlibm_fenv_powerpc.h>
 #else
-#error "Unsupported platform"
+#error "Unsupported platform: Try -DOPENLIBM_USE_HOST_FENV_H"
 #endif
 
 #endif /* OPENLIBM_USE_HOST_FENV_H */
+
+#endif /* _OPENLIBM_FENV_H */

+ 246 - 0
include/openlibm_fenv_aarch64.h

@@ -0,0 +1,246 @@
+/*-
+ * Copyright (c) 2004-2005 David Schultz <[email protected]>
+ * 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 <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	0x00000001
+#define	FE_DIVBYZERO	0x00000002
+#define	FE_OVERFLOW	0x00000004
+#define	FE_UNDERFLOW	0x00000008
+#define	FE_INEXACT	0x00000010
+#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_UPWARD	0x1
+#define	FE_DOWNWARD	0x2
+#define	FE_TOWARDZERO	0x3
+#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
+			 FE_UPWARD | FE_TOWARDZERO)
+#define	_ROUND_SHIFT	22
+
+__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	8
+#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
+
+#define	__mrs_fpcr(__r)	__asm __volatile("mrs %0, fpcr" : "=r" (__r))
+#define	__msr_fpcr(__r)	__asm __volatile("msr fpcr, %0" : : "r" (__r))
+
+#define	__mrs_fpsr(__r)	__asm __volatile("mrs %0, fpsr" : "=r" (__r))
+#define	__msr_fpsr(__r)	__asm __volatile("msr fpsr, %0" : : "r" (__r))
+
+__fenv_static __inline int
+feclearexcept(int __excepts)
+{
+	fexcept_t __r;
+
+	__mrs_fpsr(__r);
+	__r &= ~__excepts;
+	__msr_fpsr(__r);
+	return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+	fexcept_t __r;
+
+	__mrs_fpsr(__r);
+	*__flagp = __r & __excepts;
+	return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+	fexcept_t __r;
+
+	__mrs_fpsr(__r);
+	__r &= ~__excepts;
+	__r |= *__flagp & __excepts;
+	__msr_fpsr(__r);
+	return (0);
+}
+
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+	fexcept_t __r;
+
+	__mrs_fpsr(__r);
+	__r |= __excepts;
+	__msr_fpsr(__r);
+	return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+	fexcept_t __r;
+
+	__mrs_fpsr(__r);
+	return (__r & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+	fenv_t __r;
+
+	__mrs_fpcr(__r);
+	return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+	fenv_t __r;
+
+	if (__round & ~_ROUND_MASK)
+		return (-1);
+	__mrs_fpcr(__r);
+	__r &= ~(_ROUND_MASK << _ROUND_SHIFT);
+	__r |= __round << _ROUND_SHIFT;
+	__msr_fpcr(__r);
+	return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+	fenv_t __r;
+
+	__mrs_fpcr(__r);
+	*__envp = __r & _ENABLE_MASK;
+
+	__mrs_fpsr(__r);
+	*__envp |= __r & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT));
+
+	return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+	fenv_t __r;
+
+	__mrs_fpcr(__r);
+	*__envp = __r & _ENABLE_MASK;
+	__r &= ~(_ENABLE_MASK);
+	__msr_fpcr(__r);
+
+	__mrs_fpsr(__r);
+	*__envp |= __r & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT));
+	__r &= ~(_ENABLE_MASK);
+	__msr_fpsr(__r);
+	return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+	__msr_fpcr((*__envp) & _ENABLE_MASK);
+	__msr_fpsr((*__envp) & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT)));
+	return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+	fexcept_t __r;
+
+	__mrs_fpsr(__r);
+	fesetenv(__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;
+
+	__mrs_fpcr(__old_r);
+	__new_r = __old_r | ((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+	__msr_fpcr(__new_r);
+	return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fedisableexcept(int __mask)
+{
+	fenv_t __old_r, __new_r;
+
+	__mrs_fpcr(__old_r);
+	__new_r = __old_r & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+	__msr_fpcr(__new_r);
+	return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fegetexcept(void)
+{
+	fenv_t __r;
+
+	__mrs_fpcr(__r);
+	return ((__r & _ENABLE_MASK) >> _FPUSW_SHIFT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif	/* !_FENV_H_ */

+ 0 - 226
include/openlibm_fenv_amd64.h

@@ -1,226 +0,0 @@
-/*-
- * Copyright (c) 2004-2005 David Schultz <[email protected]>
- * 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: src/lib/msun/amd64/fenv.h,v 1.8 2011/10/10 15:43:09 das Exp $
- */
-
-#ifndef	_FENV_H_
-#define	_FENV_H_
-
-#include "cdefs-compat.h"
-#include "types-compat.h"
-
-#include "math_private.h"
-
-#ifndef	__fenv_static
-//VBS
-//#define	__fenv_static	static
-#define	__fenv_static
-#endif
-
-typedef struct {
-	struct {
-		uint32_t	__control;
-		uint32_t	__status;
-		uint32_t	__tag;
-		char		__other[16];
-	} __x87;
-	uint32_t		__mxcsr;
-} fenv_t;
-
-typedef	uint16_t	fexcept_t;
-
-/* Exception flags */
-#define	FE_INVALID	0x01
-#define	FE_DENORMAL	0x02
-#define	FE_DIVBYZERO	0x04
-#define	FE_OVERFLOW	0x08
-#define	FE_UNDERFLOW	0x10
-#define	FE_INEXACT	0x20
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
-
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_DOWNWARD	0x0400
-#define	FE_UPWARD	0x0800
-#define	FE_TOWARDZERO	0x0c00
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
-/*
- * As compared to the x87 control word, the SSE unit's control word
- * has the rounding control bits offset by 3 and the exception mask
- * bits offset by 7.
- */
-#define	_SSE_ROUND_SHIFT	3
-#define	_SSE_EMASK_SHIFT	7
-
-__BEGIN_DECLS
-
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
-
-#define	__fldcw(__cw)		__asm __volatile("fldcw %0" : : "m" (__cw))
-#define	__fldenv(__env)		__asm __volatile("fldenv %0" : : "m" (__env))
-#define	__fldenvx(__env)	__asm __volatile("fldenv %0" : : "m" (__env)  \
-				: "st", "st(1)", "st(2)", "st(3)", "st(4)",   \
-				"st(5)", "st(6)", "st(7)")
-#define	__fnclex()		__asm __volatile("fnclex")
-#define	__fnstenv(__env)	__asm __volatile("fnstenv %0" : "=m" (*(__env)))
-#define	__fnstcw(__cw)		__asm __volatile("fnstcw %0" : "=m" (*(__cw)))
-#define	__fnstsw(__sw)		__asm __volatile("fnstsw %0" : "=am" (*(__sw)))
-#define	__fwait()		__asm __volatile("fwait")
-#define	__ldmxcsr(__csr)	__asm __volatile("ldmxcsr %0" : : "m" (__csr))
-#define	__stmxcsr(__csr)	__asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
-
-__fenv_static __attribute__((always_inline)) DLLEXPORT inline int
-feclearexcept(int __excepts)
-{
-	fenv_t __env;
-
-	if (__excepts == FE_ALL_EXCEPT) {
-		__fnclex();
-	} else {
-		__fnstenv(&__env.__x87);
-		__env.__x87.__status &= ~__excepts;
-		__fldenv(__env.__x87);
-	}
-	__stmxcsr(&__env.__mxcsr);
-	__env.__mxcsr &= ~__excepts;
-	__ldmxcsr(__env.__mxcsr);
-	return (0);
-}
-
-__fenv_static DLLEXPORT inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	uint32_t __mxcsr;
-	uint16_t __status;
-
-	__stmxcsr(&__mxcsr);
-	__fnstsw(&__status);
-	*__flagp = (__mxcsr | __status) & __excepts;
-	return (0);
-}
-
-DLLEXPORT int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-DLLEXPORT int feraiseexcept(int __excepts);
-
-__fenv_static __attribute__((always_inline)) DLLEXPORT inline int
-fetestexcept(int __excepts)
-{
-	uint32_t __mxcsr;
-	uint16_t __status;
-
-	__stmxcsr(&__mxcsr);
-	__fnstsw(&__status);
-	return ((__status | __mxcsr) & __excepts);
-}
-
-__fenv_static DLLEXPORT inline int
-fegetround(void)
-{
-	uint16_t __control;
-
-	/*
-	 * We assume that the x87 and the SSE unit agree on the
-	 * rounding mode.  Reading the control word on the x87 turns
-	 * out to be about 5 times faster than reading it on the SSE
-	 * unit on an Opteron 244.
-	 */
-	__fnstcw(&__control);
-	return (__control & _ROUND_MASK);
-}
-
-__fenv_static DLLEXPORT inline int
-fesetround(int __round)
-{
-	uint32_t __mxcsr;
-	uint16_t __control;
-
-	if (__round & ~_ROUND_MASK)
-		return (-1);
-
-	__fnstcw(&__control);
-	__control &= ~_ROUND_MASK;
-	__control |= __round;
-	__fldcw(__control);
-
-	__stmxcsr(&__mxcsr);
-	__mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
-	__mxcsr |= __round << _SSE_ROUND_SHIFT;
-	__ldmxcsr(__mxcsr);
-
-	return (0);
-}
-
-DLLEXPORT int fegetenv(fenv_t *__envp);
-DLLEXPORT int feholdexcept(fenv_t *__envp);
-
-__fenv_static DLLEXPORT inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	/*
-	 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
-	 * instruction clobbers the i387 register stack.  This happens because
-	 * we restore the tag word from the saved environment.  Normally, this
-	 * would happen anyway and we wouldn't care, because the ABI allows
-	 * function calls to clobber the i387 regs.  However, fesetenv() is
-	 * inlined, so we need to be more careful.
-	 */
-	__fldenvx(__envp->__x87);
-	__ldmxcsr(__envp->__mxcsr);
-	return (0);
-}
-
-DLLEXPORT int feupdateenv(const fenv_t *__envp);
-
-#if __BSD_VISIBLE
-
-DLLEXPORT int feenableexcept(int __mask);
-DLLEXPORT int fedisableexcept(int __mask);
-
-/* We currently provide no external definition of fegetexcept(). */
-DLLEXPORT int
-fegetexcept(void)
-{
-	uint16_t __control;
-
-	/*
-	 * We assume that the masks for the x87 and the SSE unit are
-	 * the same.
-	 */
-	__fnstcw(&__control);
-	return (~__control & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
-__END_DECLS
-
-#endif	/* !_FENV_H_ */

+ 177 - 80
include/openlibm_fenv_i387.h → include/openlibm_fenv_x86.h

@@ -23,40 +23,21 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/msun/i387/fenv.h,v 1.8 2011/10/10 15:43:09 das Exp $
+ * $FreeBSD$
  */
 
-#ifndef	_FENV_H_
-#define	_FENV_H_
+#ifndef	_OPENLIBM_FENV_AMD64_H_
+#define	_OPENLIBM_FENV_AMD64_H_
 
-#include "cdefs-compat.h"
-#include "types-compat.h"
+#include <openlibm_compat.h>
+#include <sys/cdefs.h>
+//#include <sys/_types.h>
 
 #ifndef	__fenv_static
 #define	__fenv_static	static
 #endif
 
-/*                   
- * To preserve binary compatibility with FreeBSD 5.3, we pack the
- * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
- */
-typedef struct {
-	uint16_t	__control;
-	uint16_t      __mxcsr_hi;
-	uint16_t	__status;
-	uint16_t      __mxcsr_lo;
-	uint32_t	__tag;
-	char		__other[16];
-} fenv_t;
-
-#define	__get_mxcsr(env)	(((env).__mxcsr_hi << 16) |	\
-				 ((env).__mxcsr_lo))
-#define	__set_mxcsr(env, x)	do {				\
-	(env).__mxcsr_hi = (uint32_t)(x) >> 16;		\
-	(env).__mxcsr_lo = (uint16_t)(x);			\
-} while (0)
-
-typedef	uint16_t	fexcept_t;
+typedef	__uint16_t	fexcept_t;
 
 /* Exception flags */
 #define	FE_INVALID	0x01
@@ -84,18 +65,32 @@ typedef	uint16_t	fexcept_t;
 #define	_SSE_ROUND_SHIFT	3
 #define	_SSE_EMASK_SHIFT	7
 
-__BEGIN_DECLS
+#ifdef __i386__
+/*
+ * To preserve binary compatibility with FreeBSD 5.3, we pack the
+ * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
+ */
+typedef struct {
+	__uint16_t	__control;
+	__uint16_t      __mxcsr_hi;
+	__uint16_t	__status;
+	__uint16_t      __mxcsr_lo;
+	__uint32_t	__tag;
+	char		__other[16];
+} fenv_t;
+#else /* __amd64__ */
+typedef struct {
+	struct {
+		__uint32_t	__control;
+		__uint32_t	__status;
+		__uint32_t	__tag;
+		char		__other[16];
+	} __x87;
+	__uint32_t		__mxcsr;
+} fenv_t;
+#endif /* __i386__ */
 
-/* After testing for SSE support once, we cache the result in __has_sse. */
-enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
-extern enum __sse_support __has_sse;
-int __test_sse(void);
-#ifdef __SSE__
-#define	__HAS_SSE()	1
-#else
-#define	__HAS_SSE()	(__has_sse == __SSE_YES ||			\
-			 (__has_sse == __SSE_UNK && __test_sse()))
-#endif
+__BEGIN_DECLS
 
 /* Default floating-point environment */
 extern const fenv_t	__fe_dfl_env;
@@ -114,11 +109,73 @@ 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)))
 
+int fegetenv(fenv_t *__envp);
+int feholdexcept(fenv_t *__envp);
+int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+int feraiseexcept(int __excepts);
+int feupdateenv(const fenv_t *__envp);
+
+__fenv_static inline int
+fegetround(void)
+{
+	__uint16_t __control;
+
+	/*
+	 * We assume that the x87 and the SSE unit agree on the
+	 * rounding mode.  Reading the control word on the x87 turns
+	 * out to be about 5 times faster than reading it on the SSE
+	 * unit on an Opteron 244.
+	 */
+	__fnstcw(&__control);
+	return (__control & _ROUND_MASK);
+}
+
+#if __BSD_VISIBLE
+
+int feenableexcept(int __mask);
+int fedisableexcept(int __mask);
+
+/* We currently provide no external definition of fegetexcept(). */
+static inline int
+fegetexcept(void)
+{
+	__uint16_t __control;
+
+	/*
+	 * We assume that the masks for the x87 and the SSE unit are
+	 * the same.
+	 */
+	__fnstcw(&__control);
+	return (~__control & FE_ALL_EXCEPT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+#ifdef __i386__
+
+/* After testing for SSE support once, we cache the result in __has_sse. */
+enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
+extern enum __sse_support __has_sse;
+int __test_sse(void);
+#ifdef __SSE__
+#define	__HAS_SSE()	1
+#else
+#define	__HAS_SSE()	(__has_sse == __SSE_YES ||			\
+			 (__has_sse == __SSE_UNK && __test_sse()))
+#endif
+
+#define	__get_mxcsr(env)	(((env).__mxcsr_hi << 16) |	\
+				 ((env).__mxcsr_lo))
+#define	__set_mxcsr(env, x)	do {				\
+	(env).__mxcsr_hi = (__uint32_t)(x) >> 16;		\
+	(env).__mxcsr_lo = (__uint16_t)(x);			\
+} while (0)
+
 __fenv_static inline int
 feclearexcept(int __excepts)
 {
 	fenv_t __env;
-	uint32_t __mxcsr;
+	__uint32_t __mxcsr;
 
 	if (__excepts == FE_ALL_EXCEPT) {
 		__fnclex();
@@ -138,8 +195,8 @@ feclearexcept(int __excepts)
 __fenv_static inline int
 fegetexceptflag(fexcept_t *__flagp, int __excepts)
 {
-	uint32_t __mxcsr;
-	uint16_t __status;
+	__uint32_t __mxcsr;
+	__uint16_t __status;
 
 	__fnstsw(&__status);
 	if (__HAS_SSE())
@@ -150,14 +207,11 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
 	return (0);
 }
 
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
-
 __fenv_static inline int
 fetestexcept(int __excepts)
 {
-	uint32_t __mxcsr;
-	uint16_t __status;
+	__uint32_t __mxcsr;
+	__uint16_t __status;
 
 	__fnstsw(&__status);
 	if (__HAS_SSE())
@@ -167,26 +221,11 @@ fetestexcept(int __excepts)
 	return ((__status | __mxcsr) & __excepts);
 }
 
-__fenv_static inline int
-fegetround(void)
-{
-	uint16_t __control;
-
-	/*
-	 * We assume that the x87 and the SSE unit agree on the
-	 * rounding mode.  Reading the control word on the x87 turns
-	 * out to be about 5 times faster than reading it on the SSE
-	 * unit on an Opteron 244.
-	 */
-	__fnstcw(&__control);
-	return (__control & _ROUND_MASK);
-}
-
 __fenv_static inline int
 fesetround(int __round)
 {
-	uint32_t __mxcsr;
-	uint16_t __control;
+	__uint32_t __mxcsr;
+	__uint16_t __control;
 
 	if (__round & ~_ROUND_MASK)
 		return (-1);
@@ -206,14 +245,11 @@ fesetround(int __round)
 	return (0);
 }
 
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
-
 __fenv_static inline int
 fesetenv(const fenv_t *__envp)
 {
 	fenv_t __env = *__envp;
-	uint32_t __mxcsr;
+	__uint32_t __mxcsr;
 
 	__mxcsr = __get_mxcsr(__env);
 	__set_mxcsr(__env, 0xffffffff);
@@ -231,29 +267,90 @@ fesetenv(const fenv_t *__envp)
 	return (0);
 }
 
-int feupdateenv(const fenv_t *__envp);
+#else /* __amd64__ */
 
-#if __BSD_VISIBLE
+__fenv_static inline int
+feclearexcept(int __excepts)
+{
+	fenv_t __env;
 
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
+	if (__excepts == FE_ALL_EXCEPT) {
+		__fnclex();
+	} else {
+		__fnstenv(&__env.__x87);
+		__env.__x87.__status &= ~__excepts;
+		__fldenv(__env.__x87);
+	}
+	__stmxcsr(&__env.__mxcsr);
+	__env.__mxcsr &= ~__excepts;
+	__ldmxcsr(__env.__mxcsr);
+	return (0);
+}
 
-/* We currently provide no external definition of fegetexcept(). */
-static inline int
-fegetexcept(void)
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+	__uint32_t __mxcsr;
+	__uint16_t __status;
+
+	__stmxcsr(&__mxcsr);
+	__fnstsw(&__status);
+	*__flagp = (__mxcsr | __status) & __excepts;
+	return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+	__uint32_t __mxcsr;
+	__uint16_t __status;
+
+	__stmxcsr(&__mxcsr);
+	__fnstsw(&__status);
+	return ((__status | __mxcsr) & __excepts);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+	__uint32_t __mxcsr;
+	__uint16_t __control;
+
+	if (__round & ~_ROUND_MASK)
+		return (-1);
+
+	__fnstcw(&__control);
+	__control &= ~_ROUND_MASK;
+	__control |= __round;
+	__fldcw(__control);
+
+	__stmxcsr(&__mxcsr);
+	__mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
+	__mxcsr |= __round << _SSE_ROUND_SHIFT;
+	__ldmxcsr(__mxcsr);
+
+	return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
 {
-	uint16_t __control;
 
 	/*
-	 * We assume that the masks for the x87 and the SSE unit are
-	 * the same.
+	 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
+	 * instruction clobbers the i387 register stack.  This happens because
+	 * we restore the tag word from the saved environment.  Normally, this
+	 * would happen anyway and we wouldn't care, because the ABI allows
+	 * function calls to clobber the i387 regs.  However, fesetenv() is
+	 * inlined, so we need to be more careful.
 	 */
-	__fnstcw(&__control);
-	return (~__control & FE_ALL_EXCEPT);
+	__fldenvx(__envp->__x87);
+	__ldmxcsr(__envp->__mxcsr);
+	return (0);
 }
 
-#endif /* __BSD_VISIBLE */
+#endif /* __i386__ */
 
 __END_DECLS
 
-#endif	/* !_FENV_H_ */
+#endif	/* !OPENLIBM_FENV_AMD64_H_ */

+ 25 - 11
include/openlibm_math.h

@@ -14,12 +14,14 @@
  * $FreeBSD$
  */
 
-#ifndef _MATH_H_
-#define	_MATH_H_
+#ifndef _OPENLIBM_MATH_H_
+#define	_OPENLIBM_MATH_H_
 
 #include <sys/cdefs.h>
-#include <sys/_types.h>
-#include <machine/_limits.h>
+//#include <sys/_types.h>
+//#include <machine/_limits.h>
+#include <limits.h>
+#include <openlibm_compat.h>
 
 /*
  * ANSI/POSIX
@@ -46,6 +48,13 @@ extern const union __nan_un {
 
 */
 
+//VBS begin
+#define __MATH_BUILTIN_CONSTANTS
+#define __MATH_BUILTIN_RELOPS
+#define __ISO_C_VISIBLE 1999
+//VBS end
+
+
 #ifdef __MATH_BUILTIN_CONSTANTS
 #define	HUGE_VAL	__builtin_huge_val()
 #else
@@ -53,8 +62,10 @@ extern const union __nan_un {
 #endif
 
 #if __ISO_C_VISIBLE >= 1999
-#define	FP_ILOGB0	(-__INT_MAX)
-#define	FP_ILOGBNAN	__INT_MAX
+//#define	FP_ILOGB0	(-__INT_MAX)
+//#define	FP_ILOGBNAN	__INT_MAX
+#define	FP_ILOGB0	(-INT_MAX)
+#define	FP_ILOGBNAN	INT_MAX
 
 #ifdef __MATH_BUILTIN_CONSTANTS
 #define	HUGE_VALF	__builtin_huge_valf()
@@ -81,8 +92,7 @@ extern const union __nan_un {
 #define	FP_SUBNORMAL	0x08
 #define	FP_ZERO		0x10
 
-#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \
-    __has_extension(c_generic_selections)
+#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) 
 #define	__fp_type_select(x, f, d, ld) _Generic((x),			\
     float: f(x),							\
     double: d(x),							\
@@ -96,6 +106,7 @@ extern const union __nan_un {
     const float: f(x),							\
     const double: d(x),							\
     const long double: ld(x))
+/*
 #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
 #define	__fp_type_select(x, f, d, ld) __builtin_choose_expr(		\
     __builtin_types_compatible_p(__typeof(x), long double), ld(x),	\
@@ -104,6 +115,8 @@ extern const union __nan_un {
     __builtin_choose_expr(						\
     __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
 #else
+*/
+#else
 #define	 __fp_type_select(x, f, d, ld)					\
     ((sizeof(x) == sizeof(float)) ? f(x)				\
     : (sizeof(x) == sizeof(double)) ? d(x)				\
@@ -137,8 +150,9 @@ extern const union __nan_un {
 
 #define	signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
 
-typedef	__double_t	double_t;
-typedef	__float_t	float_t;
+//VBS
+//typedef	__double_t	double_t;
+//typedef	__float_t	float_t;
 #endif /* __ISO_C_VISIBLE >= 1999 */
 
 /*
@@ -508,4 +522,4 @@ long double	lgammal_r(long double, int *);
 
 __END_DECLS
 
-#endif /* !_MATH_H_ */
+#endif /* !_OPENLIBM_MATH_H_ */

+ 9 - 9
ld128/e_rem_pio2l.h

@@ -6,7 +6,7 @@
  *
  * Developed at SunSoft, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  *
@@ -17,8 +17,8 @@
 //__FBSDID("$FreeBSD: src/lib/msun/ld128/e_rem_pio2l.h,v 1.2 2011/05/30 19:41:28 kargl Exp $");
 
 /* ld128 version of __ieee754_rem_pio2l(x,y)
- * 
- * return the remainder of x rem pi/2 in y[0]+y[1] 
+ *
+ * return the remainder of x rem pi/2 in y[0]+y[1]
  * use __kernel_rem_pio2()
  */
 
@@ -92,24 +92,24 @@ __ieee754_rem_pio2l(long double x, long double *y)
 		union IEEEl2bits u2;
 	        int ex1;
 	        j  = ex;
-	        y[0] = r-w; 
+	        y[0] = r-w;
 		u2.e = y[0];
 		ex1 = u2.xbits.expsign & 0x7fff;
 	        i = j-ex1;
 	        if(i>51) {  /* 2nd iteration needed, good to 248 */
 		    t  = r;
-		    w  = fn*pio2_2;	
+		    w  = fn*pio2_2;
 		    r  = t-w;
-		    w  = fn*pio2_2t-((t-r)-w);	
+		    w  = fn*pio2_2t-((t-r)-w);
 		    y[0] = r-w;
 		    u2.e = y[0];
 		    ex1 = u2.xbits.expsign & 0x7fff;
 		    i = j-ex1;
 		    if(i>119) {	/* 3rd iteration need, 316 bits acc */
 		    	t  = r;	/* will cover all possible cases */
-		    	w  = fn*pio2_3;	
+		    	w  = fn*pio2_3;
 		    	r  = t-w;
-		    	w  = fn*pio2_3t-((t-r)-w);	
+		    	w  = fn*pio2_3t-((t-r)-w);
 		    	y[0] = r-w;
 		    }
 		}
@@ -117,7 +117,7 @@ __ieee754_rem_pio2l(long double x, long double *y)
 	    y[1] = (r-y[0])-w;
 	    return n;
 	}
-    /* 
+    /*
      * all other (large) arguments
      */
 	if(ex==0x7fff) {		/* x is inf or NaN */

+ 1 - 0
ld80/e_acoshl.c

@@ -27,6 +27,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 static const long double
 one	= 1.0,

+ 1 - 0
ld80/e_atanhl.c

@@ -31,6 +31,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 static const long double one = 1.0, huge = 1e4900L;
 

+ 1 - 0
ld80/e_coshl.c

@@ -34,6 +34,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 static const long double one = 1.0, half=0.5, huge = 1.0e4900L;
 

+ 1 - 0
ld80/e_hypotl.c

@@ -45,6 +45,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 long double
 hypotl(long double x, long double y)

+ 2 - 2
ld80/e_lgammal_r.c

@@ -10,7 +10,7 @@
  * ====================================================
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /*
@@ -24,7 +24,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const volatile double vzero = 0;

+ 1 - 1
ld80/e_rem_pio2l.h

@@ -13,7 +13,7 @@
  * Optimized by Bruce D. Evans.
  */
 
-#include "cdefs-compat.h"
+#include "openlibm_compat.h"
 //__FBSDID("$FreeBSD: src/lib/msun/ld80/e_rem_pio2l.h,v 1.3 2011/06/18 13:56:33 benl Exp $");
 
 /* ld80 version of __ieee754_rem_pio2l(x,y)

+ 1 - 0
ld80/e_sinhl.c

@@ -31,6 +31,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 static const long double one = 1.0, shuge = 1.0e4931L;
 

+ 1 - 1
ld80/invtrig.c

@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 #include "invtrig.h"

+ 1 - 1
ld80/k_cosl.c

@@ -11,7 +11,7 @@
  * ====================================================
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /*

+ 1 - 1
ld80/k_sinl.c

@@ -11,7 +11,7 @@
  * ====================================================
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /*

+ 2 - 2
ld80/k_tanl.c

@@ -11,14 +11,14 @@
  * ====================================================
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /*
  * ld80 version of k_tan.c.  See ../src/k_tan.c for most comments.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 /*

+ 1 - 0
ld80/s_asinhl.c

@@ -24,6 +24,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 static const long double
 one =  1.000000000000000000000e+00L, /* 0x3FFF, 0x00000000, 0x00000000 */

+ 2 - 2
ld80/s_erfl.c

@@ -10,7 +10,7 @@
  * ====================================================
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /*
@@ -24,7 +24,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 /* XXX Prevent compilers from erroneously constant folding: */

+ 3 - 3
ld80/s_exp2l.c

@@ -24,18 +24,18 @@
  * SUCH DAMAGE.
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 #include <float.h>
 #include <stdint.h>
 
 #ifdef __i386__
-#include <ieeefp.h>
+#include <i387/bsd_ieeefp.h>
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #define	TBLBITS	7

+ 2 - 2
ld80/s_expl.c

@@ -26,7 +26,7 @@
  * Optimized by Bruce D. Evans.
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /**
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 #include "k_expl.h"
 

+ 3 - 3
ld80/s_logl.c

@@ -24,7 +24,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <cdefs-compat.h>
+#include <openlibm_compat.h>
 __FBSDID("$FreeBSD$");
 
 /**
@@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$");
 
 #ifdef DEBUG
 #include <assert.h>
-#include <fenv.h>
+#include <openlibm_fenv.h>
 #endif
 
 #ifdef __i386__
@@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #define	i386_SSE_GOOD
 #ifndef NO_STRUCT_RETURN
 #define	STRUCT_RETURN

+ 1 - 1
ld80/s_nanl.c

@@ -26,7 +26,7 @@
  * $FreeBSD$
  */
 
-#include <math.h>
+#include <openlibm_math.h>
 
 #include "fpmath.h"
 #include "../src/math_private.h"

+ 1 - 0
ld80/s_tanhl.c

@@ -37,6 +37,7 @@
 #include <openlibm_math.h>
 
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 static const long double one=1.0, two=2.0, tiny = 1.0e-4900L;
 

+ 0 - 0
src/powerpc_fpmath.h → powerpc/_fpmath.h


+ 1 - 1
src/Make.files

@@ -39,7 +39,7 @@ endif
 ifneq ($(ARCH), arm)
 ifneq ($(ARCH), powerpc)
 # C99 long double functions
-$(CUR_SRCS) +=	s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c s_roundl.c
+$(CUR_SRCS) +=	s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c # s_roundl.c
 
 # If long double != double use these; otherwise, we alias the double versions.
 $(CUR_SRCS) +=	e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \

+ 3 - 3
src/catrig.c

@@ -25,12 +25,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include <complex.h>
+#include <openlibm_complex.h>
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #undef isinf

+ 3 - 3
src/catrigf.c

@@ -39,12 +39,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include <complex.h>
+#include <openlibm_complex.h>
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #undef isinf

+ 3 - 2
src/e_acos.c

@@ -12,7 +12,8 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+#include <openlibm_compat.h>
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_acos(x)
  * Method :                  
@@ -40,7 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double

+ 2 - 2
src/e_acosf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float

+ 2 - 2
src/e_acosh.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_acosh(x)
  * Method :
@@ -31,7 +31,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double

+ 2 - 2
src/e_acoshf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float

+ 5 - 4
src/e_acoshl.c

@@ -7,14 +7,14 @@
  *
  * Developed at SunSoft, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  *
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See e_acosh.c for complete comments.
@@ -29,8 +29,9 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 /* EXP_LARGE is the threshold above which we use acosh(x) ~= log(2x). */
 #if LDBL_MANT_DIG == 64
@@ -75,7 +76,7 @@ acoshl(long double x)
 	} else if (hx >= BIAS + EXP_LARGE) { /* x >= LARGE */
 	    if (hx >= 0x7fff) {		/* x is inf, NaN or misnormal */
 	        RETURNI(x+x);
-	    } else 
+	    } else
 		RETURNI(logl(x)+ln2);	/* acosh(huge)=log(2x), or misnormal */
 	} else if (hx == 0x3fff && x == 1) {
 	    RETURNI(0.0);		/* acosh(1) = 0 */

+ 2 - 2
src/e_acosl.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See comments in e_acos.c.
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
 #include <float.h>
 
 #include "invtrig.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const long double

+ 2 - 2
src/e_asin.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_asin(x)
  * Method :                  
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double

+ 2 - 2
src/e_asinf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float

+ 2 - 2
src/e_asinl.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See comments in e_asin.c.
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
 #include <float.h>
 
 #include "invtrig.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const long double

+ 2 - 2
src/e_atan2.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_atan2(y,x)
  * Method :
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static volatile double

+ 2 - 2
src/e_atan2f.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static volatile float

+ 2 - 2
src/e_atan2l.c

@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See comments in e_atan2.c.
@@ -24,7 +24,7 @@ __FBSDID("$FreeBSD$");
 #include <float.h>
 
 #include "invtrig.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static volatile long double

+ 2 - 2
src/e_atanh.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_atanh(x)
  * Method :
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double one = 1.0, huge = 1e300;

+ 2 - 2
src/e_atanhf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float one = 1.0, huge = 1e30;

+ 5 - 4
src/e_atanhl.c

@@ -7,14 +7,14 @@
  *
  * Developed at SunSoft, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  *
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See e_atanh.c for complete comments.
@@ -29,8 +29,9 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
+#include "math_private_openbsd.h"
 
 /* EXP_TINY is the threshold below which we use atanh(x) ~= x. */
 #if LDBL_MANT_DIG == 64
@@ -68,7 +69,7 @@ atanhl(long double x)
 	if (ix < 0x3ffe) {		/* |x| < 0.5, or misnormal */
 	    t = x+x;
 	    t = 0.5*log1pl(t+t*x/(one-x));
-	} else 
+	} else
 	    t = 0.5*log1pl((x+x)/(one-x));
 	RETURNI((hx & 0x8000) == 0 ? t : -t);
 }

+ 2 - 2
src/e_cosh.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_cosh(x)
  * Method : 
@@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double one = 1.0, half=0.5, huge = 1.0e300;

+ 2 - 2
src/e_coshf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float one = 1.0, half=0.5, huge = 1.0e30;

+ 3 - 2
src/e_coshl.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See e_cosh.c for complete comments.
@@ -26,8 +26,9 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
+#include "math_private_openbsd.h"
 #include "k_expl.h"
 
 #if LDBL_MAX_EXP != 0x4000

+ 2 - 2
src/e_exp.c

@@ -11,7 +11,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_exp(x)
  * Returns the exponential of x.
@@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double

+ 2 - 2
src/e_expf.c

@@ -14,11 +14,11 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float

+ 2 - 2
src/e_fmod.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* 
  * __ieee754_fmod(x,y)
@@ -20,7 +20,7 @@ __FBSDID("$FreeBSD$");
  * Method: shift and subtract
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double one = 1.0, Zero[] = {0.0, -0.0,};

+ 2 - 2
src/e_fmodf.c

@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * __ieee754_fmodf(x,y)
@@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$");
  * Method: shift and subtract
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float one = 1.0, Zero[] = {0.0, -0.0,};

+ 2 - 2
src/e_fmodl.c

@@ -11,13 +11,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 #include <float.h>
 #include <stdint.h>
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #define	BIAS (LDBL_MAX_EXP - 1)

+ 2 - 2
src/e_gamma.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_gamma(x)
  * Return the logarithm of the Gamma function of x.
@@ -21,7 +21,7 @@ __FBSDID("$FreeBSD$");
  * Method: call __ieee754_gamma_r
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 extern int signgam;

+ 2 - 2
src/e_gamma_r.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_gamma_r(x, signgamp)
  * Reentrant version of the logarithm of the Gamma function 
@@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$");
  * Method: See __ieee754_lgamma_r
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 double

+ 2 - 2
src/e_gammaf.c

@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_gammaf(x)
  * Return the logarithm of the Gamma function of x.
@@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$");
  * Method: call __ieee754_gammaf_r
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 extern int signgam;

+ 2 - 2
src/e_gammaf_r.c

@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_gammaf_r(x, signgamp)
  * Reentrant version of the logarithm of the Gamma function
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
  * Method: See __ieee754_lgammaf_r
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 float

+ 2 - 2
src/e_hypot.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_hypot(x,y)
  *
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 double

+ 2 - 2
src/e_hypotf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 float

+ 2 - 2
src/e_hypotl.c

@@ -11,14 +11,14 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* long double version of hypot().  See e_hypot.c for most comments. */
 
 #include <float.h>
 
 #include "fpmath.h"
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #define	GET_LDBL_MAN(h, l, v) do {	\

+ 2 - 2
src/e_j0.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_j0(x), __ieee754_y0(x)
  * Bessel function of the first and second kinds of order zero.
@@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
  *	3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static __inline double pzero(double), qzero(double);

+ 2 - 2
src/e_j0f.c

@@ -14,13 +14,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See e_j0.c for complete comments.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static __inline float pzerof(float), qzerof(float);

+ 2 - 2
src/e_j1.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_j1(x), __ieee754_y1(x)
  * Bessel function of the first and second kinds of order zero.
@@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
  *	   by method mentioned above.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static __inline double pone(double), qone(double);

+ 2 - 2
src/e_j1f.c

@@ -14,13 +14,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See e_j1.c for complete comments.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static __inline float ponef(float), qonef(float);

+ 2 - 2
src/e_jn.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * __ieee754_jn(n, x), __ieee754_yn(n, x)
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
  *	
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const volatile double vone = 1, vzero = 0;

+ 2 - 2
src/e_jnf.c

@@ -14,13 +14,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * See e_jn.c for complete comments.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const volatile float vone = 1, vzero = 0;

+ 2 - 2
src/e_lgamma.c

@@ -13,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_lgamma(x)
  * Return the logarithm of the Gamma function of x.
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 extern int signgam;

+ 2 - 2
src/e_lgamma_r.c

@@ -11,7 +11,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_lgamma_r(x, signgamp)
  * Reentrant version of the logarithm of the Gamma function
@@ -82,7 +82,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const volatile double vzero = 0;

+ 2 - 2
src/e_lgammaf.c

@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_lgammaf(x)
  * Return the logarithm of the Gamma function of x.
@@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$");
  * Method: call __ieee754_lgammaf_r
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 extern int signgam;

+ 2 - 2
src/e_lgammaf_r.c

@@ -15,9 +15,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const volatile float vzero = 0;

+ 2 - 2
src/e_lgammal.c

@@ -11,9 +11,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 extern int signgam;

+ 2 - 2
src/e_log.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_log(x)
  * Return the logrithm of x
@@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double

+ 2 - 2
src/e_log10.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * Return the base 10 logarithm of x.  See e_log.c and k_log.h for most
@@ -24,7 +24,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 #include "k_log.h"
 

+ 2 - 2
src/e_log10f.c

@@ -10,13 +10,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * Float version of e_log10.c.  See the latter for most comments.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 #include "k_logf.h"
 

+ 2 - 2
src/e_log2.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * Return the base 2 logarithm of x.  See e_log.c and k_log.h for most
@@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 #include "k_log.h"
 

+ 2 - 2
src/e_log2f.c

@@ -10,13 +10,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * Float version of e_log2.c.  See the latter for most comments.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 #include "k_logf.h"
 

+ 2 - 2
src/e_logf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float

+ 2 - 2
src/e_pow.c

@@ -10,7 +10,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_pow(x,y) return x**y
  *
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
  * to produce the hexadecimal values shown.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double

+ 2 - 2
src/e_powf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float

+ 2 - 2
src/e_rem_pio2.c

@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_rem_pio2(x,y)
  * 
@@ -24,7 +24,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 /*

+ 2 - 2
src/e_rem_pio2f.c

@@ -15,7 +15,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_rem_pio2f(x,y)
  *
@@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 /*

+ 2 - 2
src/e_remainder.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_remainder(x,p)
  * Return :                  
@@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double zero = 0.0;

+ 2 - 2
src/e_remainderf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const float zero = 0.0;

+ 2 - 2
src/e_remainderl.c

@@ -25,9 +25,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include <math.h>
+#include <openlibm_math.h>
 
 long double
 remainderl(long double x, long double y)

+ 2 - 2
src/e_scalb.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /*
  * __ieee754_scalb(x, fn) is provide for
@@ -20,7 +20,7 @@ __FBSDID("$FreeBSD$");
  * should use scalbn() instead.
  */
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #ifdef _SCALB_INT

+ 2 - 2
src/e_scalbf.c

@@ -14,9 +14,9 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 #ifdef _SCALB_INT

+ 2 - 2
src/e_sinh.c

@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+//__FBSDID("$FreeBSD$");
 
 /* __ieee754_sinh(x)
  * Method : 
@@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$");
 
 #include <float.h>
 
-#include "math.h"
+#include <openlibm_math.h>
 #include "math_private.h"
 
 static const double one = 1.0, shuge = 1.0e307;

Some files were not shown because too many files changed in this diff