summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2010-10-22 00:19:23 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2010-10-22 00:19:23 +0000
commit362c8265449ccbe244cf34c4a55d9bf2e6d36d64 (patch)
treec1856abcbb0288fd55e5b66a2628dac9f839460a
parent9a13037b9f1354b7405124e83087b72c4c44d388 (diff)
Merge changes between r11760 and r11842 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@11843 7b3dc134-2b1b-0410-93df-9e9f96275f8d
-rw-r--r--libc/ChangeLog88
-rw-r--r--libc/NEWS5
-rw-r--r--libc/bits/mathdef.h16
-rw-r--r--libc/math/libm-test.inc68
-rw-r--r--libc/nptl/ChangeLog7
-rw-r--r--libc/nptl/sysdeps/x86_64/pthreaddef.h5
-rw-r--r--libc/nptl/sysdeps/x86_64/tls.h7
-rw-r--r--libc/scripts/data/localplt-s390-linux-gnu.data7
-rw-r--r--libc/scripts/data/localplt-s390x-linux-gnu.data7
-rw-r--r--libc/sysdeps/i386/bits/mathdef.h16
-rw-r--r--libc/sysdeps/i386/fpu/bits/mathinline.h6
-rw-r--r--libc/sysdeps/i386/i686/multiarch/s_fma.c2
-rw-r--r--libc/sysdeps/ieee754/dbl-64/s_fma.c227
-rw-r--r--libc/sysdeps/ieee754/dbl-64/s_fmaf.c2
-rw-r--r--libc/sysdeps/ieee754/ldbl-128/s_fma.c50
-rw-r--r--libc/sysdeps/ieee754/ldbl-128/s_fmal.c223
-rw-r--r--libc/sysdeps/ieee754/ldbl-64-128/s_fmal.c5
-rw-r--r--libc/sysdeps/ieee754/ldbl-96/s_fma.c79
-rw-r--r--libc/sysdeps/ieee754/ldbl-96/s_fmal.c221
-rw-r--r--libc/sysdeps/ieee754/ldbl-opt/s_fma.c2
-rw-r--r--libc/sysdeps/powerpc/bits/mathdef.h6
-rw-r--r--libc/sysdeps/powerpc/fpu/s_fma.S (renamed from libc/sysdeps/i386/fpu/s_fma.S)22
-rw-r--r--libc/sysdeps/powerpc/fpu/s_fmaf.S (renamed from libc/sysdeps/i386/fpu/s_fmaf.S)17
-rw-r--r--libc/sysdeps/powerpc/powerpc32/fpu/s_fma.S5
-rw-r--r--libc/sysdeps/powerpc/powerpc64/fpu/s_fma.S5
-rw-r--r--libc/sysdeps/s390/fpu/s_fma.c37
-rw-r--r--libc/sysdeps/s390/fpu/s_fmaf.c (renamed from libc/sysdeps/i386/fpu/s_fmal.S)28
-rw-r--r--libc/sysdeps/unix/sysv/linux/s390/fpu/s_fma.c5
-rw-r--r--libc/sysdeps/x86_64/bits/mathdef.h16
-rw-r--r--libc/sysdeps/x86_64/multiarch/s_fma.c4
-rw-r--r--ports/ChangeLog.arm5
-rw-r--r--ports/ChangeLog.mips7
-rw-r--r--ports/sysdeps/arm/bits/mathdef.h16
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list2
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list2
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list2
36 files changed, 1163 insertions, 59 deletions
diff --git a/libc/ChangeLog b/libc/ChangeLog
index e2a4a7051..e162666af 100644
--- a/libc/ChangeLog
+++ b/libc/ChangeLog
@@ -1,3 +1,91 @@
+2010-10-19 Ulrich Drepper <drepper@gmail.com>
+
+ * sysdeps/i386/bits/mathdef.h (FP_FAST_FMA): If the GCC 4.6 port has
+ fast fma builtins, define the macros in the C99 standard.
+ (FP_FAST_FMAF): Likewise.
+ (FP_FAST_FMAL): Likewise.
+ * sysdeps/x86_64/bits/mathdef.h: Likewise.
+
+ * bits/mathdef.h: Update copyright year.
+ * sysdeps/powerpc/bits/mathdef.h: Likewise.
+
+2010-10-19 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ * bits/mathdef.h (FP_FAST_FMA): If the GCC 4.6 port has fast fma
+ builtins, define the macros in the C99 standard.
+ (FP_FAST_FMAF): Likewise.
+ (FP_FAST_FMAL): Likewise.
+ * sysdeps/powerpc/bits/mathdef.h (FP_FAST_FMA): Define, ppc as
+ multiply/add.
+ (FP_FAST_FMAF): Likewise.
+
+2010-10-15 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #3268]
+ * math/libm-test.inc (fma_test): Some new testcases.
+ * sysdeps/ieee754/ldbl-128/s_fmal.c: New file.
+ * sysdeps/ieee754/ldbl-96/s_fma.c (__fma): Fix fma with finite x and
+ y and infinite z. Do multiplication by C already in long double.
+ * sysdeps/ieee754/ldbl-96/s_fmal.c: New file.
+ * sysdeps/ieee754/dbl-64/s_fma.c (__fma): Fix fma with finite x and
+ y and infinite z. Do bitwise or of inexact bit into u.d.
+ * sysdeps/ieee754/ldbl-64-128/s_fmal.c: New file.
+ * sysdeps/i386/fpu/s_fmaf.S: Removed.
+ * sysdeps/i386/fpu/s_fma.S: Removed.
+ * sysdeps/i386/fpu/s_fmal.S: Removed.
+
+2010-10-16 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #3268]
+ * math/libm-test.inc (fma_test): Add IEEE quad long double fmal tests.
+ * sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Ensure a1 + u.d
+ computation is not scheduled after fetestexcept. Fix value
+ of minimum denormal long double.
+
+2010-10-14 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #3268]
+ * math/libm-test.inc (fma_test): Add some more tests.
+ * sysdeps/ieee754/dbl-64/s_fma.c (__fma): Handle underflows
+ correctly.
+
+2010-10-15 Andreas Schwab <schwab@redhat.com>
+
+ * scripts/data/localplt-s390-linux-gnu.data: New file.
+ * scripts/data/localplt-s390x-linux-gnu.data: New file.
+
+2010-10-13 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #3268]
+ * math/libm-test.inc (fma_test): Some more fmaf and fma tests.
+ * sysdeps/i386/i686/multiarch/s_fma.c: Include ldbl-96 version
+ instead of dbl-64.
+ * sysdeps/i386/fpu/bits/mathinline.h (fma, fmaf, fmal): Remove
+ inlines.
+ * sysdeps/ieee754/ldbl-96/s_fma.c: New file.
+ * sysdeps/ieee754/dbl-64/s_fma.c (__fma): Fix exponent adjustment
+ if one of x and y is very large and the other is subnormal.
+ * sysdeps/s390/fpu/s_fmaf.c: New file.
+ * sysdeps/s390/fpu/s_fma.c: New file.
+ * sysdeps/powerpc/fpu/s_fmaf.S: New file.
+ * sysdeps/powerpc/fpu/s_fma.S: New file.
+ * sysdeps/powerpc/powerpc32/fpu/s_fma.S: New file.
+ * sysdeps/powerpc/powerpc64/fpu/s_fma.S: New file.
+ * sysdeps/unix/sysv/linux/s390/fpu/s_fma.c: New file.
+
+2010-10-12 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #3268]
+ * math/libm-test.inc (fma_test): Add some more fmaf tests, add
+ fma tests.
+ * sysdeps/ieee754/dbl-64/s_fmaf.c (__fmaf): Fix Inf/Nan check.
+ * sysdeps/ieee754/dbl-64/s_fma.c: New file.
+ * sysdeps/i386/i686/multiarch/s_fma.c: Include
+ sysdeps/ieee754/dbl-64/s_fma.c instead of math/s_fma.c.
+ * sysdeps/x86_64/multiarch/s_fma.c: Likewise.
+ * sysdeps/ieee754/ldbl-opt/s_fma.c: Likewise.
+ * sysdeps/ieee754/ldbl-128/s_fma.c: New file.
+
2010-10-12 Ulrich Drepper <drepper@redhat.com>
[BZ #12078]
diff --git a/libc/NEWS b/libc/NEWS
index bd0f21c45..48efcbd52 100644
--- a/libc/NEWS
+++ b/libc/NEWS
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes. 2010-10-11
+GNU C Library NEWS -- history of user-visible changes. 2010-10-13
Copyright (C) 1992-2009, 2010 Free Software Foundation, Inc.
See the end for copying conditions.
@@ -10,7 +10,8 @@ Version 2.13
* The following bugs are resolved with this release:
3268, 7066, 10851, 11611, 11640, 11701, 11840, 11856, 11883, 11903, 11904,
- 11968, 11979, 12005, 12037, 12067, 12077, 12078, 12092, 12093, 12107, 12108
+ 11968, 11979, 12005, 12037, 12067, 12077, 12078, 12092, 12093, 12107, 12108,
+ 12113
* New Linux interfaces: prlimit, prlimit64, fanotify_init, fanotify_mark
diff --git a/libc/bits/mathdef.h b/libc/bits/mathdef.h
index 00c67241a..3cea5847c 100644
--- a/libc/bits/mathdef.h
+++ b/libc/bits/mathdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,1999,2000,2004,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -34,6 +34,20 @@ typedef double double_t; /* `double' expressions are evaluated as
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN 2147483647
+/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
+ builtins are supported. */
+#if __FP_FAST_FMA
+# define FP_FAST_FMA 1
+#endif
+
+#if __FP_FAST_FMAF
+# define FP_FAST_FMAF 1
+#endif
+
+#if __FP_FAST_FMAL
+# define FP_FAST_FMAL 1
+#endif
+
#endif /* ISO C99 */
#ifndef __NO_LONG_DOUBLE_MATH
diff --git a/libc/math/libm-test.inc b/libc/math/libm-test.inc
index 784cdb6e4..453088528 100644
--- a/libc/math/libm-test.inc
+++ b/libc/math/libm-test.inc
@@ -2800,11 +2800,77 @@ fma_test (void)
TEST_fff_f (fma, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
TEST_fff_f (fma, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
TEST_fff_f (fma, minus_infty, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, plus_infty, 3.5L, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, minus_infty, -7.5L, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, -13.5L, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, minus_infty, 7.5L, plus_infty, nan_value, INVALID_EXCEPTION);
TEST_fff_f (fma, 1.25L, 0.75L, 0.0625L, 1.0L);
-#ifdef TEST_FLOAT
+
+ FLOAT fltmax = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX,
+ LDBL_MAX, DBL_MAX, FLT_MAX);
+ TEST_fff_f (fma, -fltmax, -fltmax, minus_infty, minus_infty);
+ TEST_fff_f (fma, fltmax / 2, fltmax / 2, minus_infty, minus_infty);
+ TEST_fff_f (fma, -fltmax, fltmax, plus_infty, plus_infty);
+ TEST_fff_f (fma, fltmax / 2, -fltmax / 4, plus_infty, plus_infty);
+ TEST_fff_f (fma, plus_infty, 4, plus_infty, plus_infty);
+ TEST_fff_f (fma, 2, minus_infty, minus_infty, minus_infty);
+ TEST_fff_f (fma, minus_infty, minus_infty, plus_infty, plus_infty);
+ TEST_fff_f (fma, plus_infty, minus_infty, minus_infty, minus_infty);
+
+#if defined (TEST_FLOAT) && FLT_MANT_DIG == 24
TEST_fff_f (fma, 0x1.7ff8p+13, 0x1.000002p+0, 0x1.ffffp-24, 0x1.7ff802p+13);
TEST_fff_f (fma, 0x1.fffp+0, 0x1.00001p+0, -0x1.fffp+0, 0x1.fffp-20);
+ TEST_fff_f (fma, 0x1.9abcdep+127, 0x0.9abcdep-126, -0x1.f08948p+0, 0x1.bb421p-25);
+ TEST_fff_f (fma, 0x1.9abcdep+100, 0x0.9abcdep-126, -0x1.f08948p-27, 0x1.bb421p-52);
+ TEST_fff_f (fma, 0x1.fffffep+127, 0x1.001p+0, -0x1.fffffep+127, 0x1.fffffep+115);
+ TEST_fff_f (fma, -0x1.fffffep+127, 0x1.fffffep+0, 0x1.fffffep+127, -0x1.fffffap+127);
+ TEST_fff_f (fma, 0x1.fffffep+127, 2.0, -0x1.fffffep+127, 0x1.fffffep+127);
+#endif
+#if defined (TEST_DOUBLE) && DBL_MANT_DIG == 53
+ TEST_fff_f (fma, 0x1.7fp+13, 0x1.0000000000001p+0, 0x1.ffep-48, 0x1.7f00000000001p+13);
+ TEST_fff_f (fma, 0x1.fffp+0, 0x1.0000000000001p+0, -0x1.fffp+0, 0x1.fffp-52);
+ TEST_fff_f (fma, 0x1.0000002p+0, 0x1.ffffffcp-1, 0x1p-300, 1.0);
+ TEST_fff_f (fma, 0x1.0000002p+0, 0x1.ffffffcp-1, -0x1p-300, 0x1.fffffffffffffp-1);
+ TEST_fff_f (fma, 0x1.deadbeef2feedp+1023, 0x0.deadbeef2feedp-1022, -0x1.a05f8c01a4bfbp+1, 0x1.0989687bc9da4p-53);
+ TEST_fff_f (fma, 0x1.deadbeef2feedp+900, 0x0.deadbeef2feedp-1022, -0x1.a05f8c01a4bfbp-122, 0x1.0989687bc9da4p-176);
+ TEST_fff_f (fma, 0x1.fffffffffffffp+1023, 0x1.001p+0, -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1011);
+ TEST_fff_f (fma, -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+0, 0x1.fffffffffffffp+1023, -0x1.ffffffffffffdp+1023);
+ TEST_fff_f (fma, 0x1.fffffffffffffp+1023, 2.0, -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023);
+ TEST_fff_f (fma, 0x1.6a09e667f3bccp-538, 0x1.6a09e667f3bccp-538, 0.0, 0.0);
+ TEST_fff_f (fma, 0x1.deadbeef2feedp-495, 0x1.deadbeef2feedp-495, -0x1.bf86a5786a574p-989, 0x0.0000042625a1fp-1022);
+ TEST_fff_f (fma, 0x1.deadbeef2feedp-503, 0x1.deadbeef2feedp-503, -0x1.bf86a5786a574p-1005, 0x0.0000000004262p-1022);
+ TEST_fff_f (fma, 0x1p-537, 0x1p-538, 0x1p-1074, 0x0.0000000000002p-1022);
+ TEST_fff_f (fma, 0x1.7fffff8p-968, 0x1p-106, 0x0.000001p-1022, 0x0.0000010000001p-1022);
+ TEST_fff_f (fma, 0x1.4000004p-967, 0x1p-106, 0x0.000001p-1022, 0x0.0000010000003p-1022);
+ TEST_fff_f (fma, 0x1.4p-967, -0x1p-106, -0x0.000001p-1022, -0x0.0000010000002p-1022);
+ TEST_fff_f (fma, -0x1.19cab66d73e17p-959, 0x1.c7108a8c5ff51p-107, -0x0.80b0ad65d9b64p-1022, -0x0.80b0ad65d9d59p-1022);
+ TEST_fff_f (fma, -0x1.d2eaed6e8e9d3p-979, -0x1.4e066c62ac9ddp-63, -0x0.9245e6b003454p-1022, -0x0.9245c09c5fb5dp-1022);
+ TEST_fff_f (fma, 0x1.153d650bb9f06p-907, 0x1.2d01230d48407p-125, -0x0.b278d5acfc3cp-1022, -0x0.b22757123bbe9p-1022);
+ TEST_fff_f (fma, -0x1.fffffffffffffp-711, 0x1.fffffffffffffp-275, 0x1.fffffe00007ffp-983, 0x1.7ffffe00007ffp-983);
+#endif
+#if defined (TEST_LDOUBLE) && LDBL_MANT_DIG == 64
+ TEST_fff_f (fma, -0x8.03fcp+3696L, 0xf.fffffffffffffffp-6140L, 0x8.3ffffffffffffffp-2450L, -0x8.01ecp-2440L);
+ TEST_fff_f (fma, 0x9.fcp+2033L, -0x8.000e1f000ff800fp-3613L, -0xf.fffffffffffc0ffp-1579L, -0xd.fc119fb093ed092p-1577L);
+ TEST_fff_f (fma, 0xc.7fc000003ffffffp-1194L, 0x8.1e0003fffffffffp+15327L, -0x8.fffep+14072L, 0xc.ae9f164020effffp+14136L);
+ TEST_fff_f (fma, -0x8.0001fc000000003p+1798L, 0xcp-2230L, 0x8.f7e000000000007p-468L, -0xc.0002f9ffee10404p-429L);
+ TEST_fff_f (fma, 0xc.0000000000007ffp+10130L, -0x8.000000000000001p+4430L, 0xc.07000000001ffffp+14513L, -0xb.fffffffffffd7e4p+14563L);
+ TEST_fff_f (fma, 0xb.ffffp-4777L, 0x8.000000fffffffffp-11612L, -0x0.3800fff8p-16385L, 0x5.c7fe80c7ffeffffp-16385L);
+#endif
+#if defined (TEST_LDOUBLE) && LDBL_MANT_DIG == 113
+ TEST_fff_f (fma, 0x1.bb2de33e02ccbbfa6e245a7c1f71p-2584L, -0x1.6b500daf0580d987f1bc0cadfcddp-13777L, 0x1.613cd91d9fed34b33820e5ab9d8dp-16378L, -0x1.3a79fb50eb9ce887cffa0f09bd9fp-16360L);
+ TEST_fff_f (fma, -0x1.f949b880cacb0f0c61540105321dp-5954L, -0x1.3876cec84b4140f3bd6198731b7ep-10525L, -0x0.a5dc1c6cfbc498c54fb0b504bf19p-16382L, -0x0.a5dc1c6cfbc498c54fb0b5038abbp-16382L);
+ TEST_fff_f (fma, -0x1.0000fffffffffp-16221L, 0x1.0000001fffff8007fep-239L, 0x0.ff87ffffffffffffe000003fffffp-16382L, 0x0.ff87ffffffffffffdffc003bff7fp-16382L);
+ TEST_fff_f (fma, -0x1.ac79c9376ef447f3827c9e9de008p-2228L, -0x1.5ba830022b6139e21fbe7270cad8p-6314L, 0x1.e8282b6a26bb6a9daf5c8e73e9f9p-8616L, 0x1.22f14a0253878a730cd1aee373adp-8541L);
+ TEST_fff_f (fma, -0x1.c69749ec574caaa2ab8e97ddb9f3p+2652L, 0x1.f34235ff9d095449c29b4831b62dp+3311L, 0x1.fbe4302df23354dbd0c4d3cfe606p+5879L, -0x1.bb473bfdfb7a6e18886ce6e57eafp+5964L);
+ TEST_fff_f (fma, -0x1.ca8835fc6ecfb5398625fc891be5p-1686L, 0x1.621e1972bbe2180e5be9dd7d8df5p-7671L, -0x1.7d2d21b73b52cf20dec2a83902a4p-9395L, -0x1.3d2322191c9c88bc68a62ab8042cp-9356L);
+ TEST_fff_f (fma, -0x1.55cff679ec49c2541fab41fc843ep-11819L, 0x1.e60e9f464f9e8df0509647c7c971p+12325L, 0x1.eaa2a7649d765c2f564f7a5beca7p+454L, -0x1.447e29fa7e406a285f4e350fcf86p+507L);
+ TEST_fff_f (fma, 0x1.f0e7b1454908576f2537d863cf9bp+11432L, 0x1.cdce52f09d4ca76e68706f34b5d5p-1417L, -0x1.2e986187c70f146235ea2066e486p+9979L, 0x1.c030dad3cc5643f3dd0f5619f661p+10016L);
+ TEST_fff_f (fma, 0x1.f102f7da4a57a3a4aab620e29452p-3098L, -0x1.cc06a4ff40248f9e2dcc4b6afd84p-11727L, 0x1.d512a11126b5ac8ed8973b8580c8p-14849L, -0x1.be8f1cf737ab4d1c31c54f5ec23bp-14824L);
+ TEST_fff_f (fma, -0x1.fc47ac7434b993cd8dcb2b431f25p-3816L, 0x1.fbc9750da8468852d84558e1db6dp-5773L, -0x1.00a98abf783f75c40fe5b7a37d86p-9607L, -0x1.f81917b166f45e763cfcc057e2adp-9588L);
+ TEST_fff_f (fma, 0x1.00000000000007ffffffffffffffp-9045L, -0x1.ffffffffffff80000001ffffffffp+4773L, -0x1.f8p-4316L, -0x1.00000000000f88000000fffffdffp-4271L);
+ TEST_fff_f (fma, 0x1.4e922764c90701d4a2f21d01893dp-8683L, -0x1.955a12e2d7c9447c27fa022fc865p+212L, -0x1.e9634462eaef96528b90b6944578p-8521L, -0x1.08e1783184a371943d3598e10865p-8470L);
+ TEST_fff_f (fma, 0x1.801181509c03bdbef10d6165588cp-15131L, 0x1.ad86f8e57d3d40bfa8007780af63p-368L, -0x1.6e9df0dab1c9f1d7a6043c390741p-15507L, 0x1.417c9b2b15e2ad57dc9e0e920844p-15498L);
#endif
END (fma);
diff --git a/libc/nptl/ChangeLog b/libc/nptl/ChangeLog
index dcb94b220..e3bfd0000 100644
--- a/libc/nptl/ChangeLog
+++ b/libc/nptl/ChangeLog
@@ -1,3 +1,10 @@
+2010-10-13 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #12113]
+ * sysdeps/x86_64/pthreaddef.h (TCB_ALIGNMENT): Changed to 32.
+ * sysdeps/x86_64/tls.h (TLS_TCB_ALIGN): Defined with alignment
+ of "struct pthread".
+
2010-09-21 Andreas Schwab <schwab@redhat.com>
* sysdeps/pthread/pthread.h (pthread_cleanup_push)
diff --git a/libc/nptl/sysdeps/x86_64/pthreaddef.h b/libc/nptl/sysdeps/x86_64/pthreaddef.h
index be63a8c74..8ec135c04 100644
--- a/libc/nptl/sysdeps/x86_64/pthreaddef.h
+++ b/libc/nptl/sysdeps/x86_64/pthreaddef.h
@@ -27,8 +27,9 @@
/* Minimal stack size after allocating thread descriptor and guard size. */
#define MINIMAL_REST_STACK 2048
-/* Alignment requirement for TCB. */
-#define TCB_ALIGNMENT 16
+/* Alignment requirement for TCB. Need to store post-AVX vector registers
+ in the TCB and we want the storage to be aligned at 32-byte. */
+#define TCB_ALIGNMENT 32
/* Location of current stack frame. The frame pointer is not usable. */
diff --git a/libc/nptl/sysdeps/x86_64/tls.h b/libc/nptl/sysdeps/x86_64/tls.h
index e39eb5f69..41b5e6daa 100644
--- a/libc/nptl/sysdeps/x86_64/tls.h
+++ b/libc/nptl/sysdeps/x86_64/tls.h
@@ -117,12 +117,7 @@ typedef struct
# define TLS_TCB_SIZE sizeof (struct pthread)
/* Alignment requirements for the TCB. */
-//# define TLS_TCB_ALIGN __alignof__ (struct pthread)
-// Normally the above would be correct But we have to store post-AVX
-// vector registers in the TCB and we want the storage to be aligned.
-// unfortunately there isn't yet a type for these values and hence no
-// 32-byte alignment requirement. Make this explicit, for now.
-# define TLS_TCB_ALIGN 32
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
/* The TCB can have any size and the memory following the address the
thread pointer points to is unspecified. Allocate the TCB there. */
diff --git a/libc/scripts/data/localplt-s390-linux-gnu.data b/libc/scripts/data/localplt-s390-linux-gnu.data
new file mode 100644
index 000000000..8fb56b608
--- /dev/null
+++ b/libc/scripts/data/localplt-s390-linux-gnu.data
@@ -0,0 +1,7 @@
+libc.so: _Unwind_Find_FDE
+libc.so: calloc
+libc.so: free
+libc.so: malloc
+libc.so: memalign
+libc.so: realloc
+libm.so: matherr
diff --git a/libc/scripts/data/localplt-s390x-linux-gnu.data b/libc/scripts/data/localplt-s390x-linux-gnu.data
new file mode 100644
index 000000000..8fb56b608
--- /dev/null
+++ b/libc/scripts/data/localplt-s390x-linux-gnu.data
@@ -0,0 +1,7 @@
+libc.so: _Unwind_Find_FDE
+libc.so: calloc
+libc.so: free
+libc.so: malloc
+libc.so: memalign
+libc.so: realloc
+libm.so: matherr
diff --git a/libc/sysdeps/i386/bits/mathdef.h b/libc/sysdeps/i386/bits/mathdef.h
index ec42ed5df..479eb96f9 100644
--- a/libc/sysdeps/i386/bits/mathdef.h
+++ b/libc/sysdeps/i386/bits/mathdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000, 2004, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -43,4 +43,18 @@ typedef long double double_t; /* `double' expressions are evaluated as
# define FP_ILOGB0 (-2147483647 - 1)
# define FP_ILOGBNAN (-2147483647 - 1)
+/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
+ builtins are supported. */
+# if __FP_FAST_FMA
+# define FP_FAST_FMA 1
+# endif
+
+# if __FP_FAST_FMAF
+# define FP_FAST_FMAF 1
+# endif
+
+# if __FP_FAST_FMAL
+# define FP_FAST_FMAL 1
+# endif
+
#endif /* ISO C99 */
diff --git a/libc/sysdeps/i386/fpu/bits/mathinline.h b/libc/sysdeps/i386/fpu/bits/mathinline.h
index 800599752..666ec2bc2 100644
--- a/libc/sysdeps/i386/fpu/bits/mathinline.h
+++ b/libc/sysdeps/i386/fpu/bits/mathinline.h
@@ -1,6 +1,6 @@
/* Inline math functions for i387.
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2003,2004,2006,2007,2009
- Free Software Foundation, Inc.
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2003,2004,2006,2007,2009,
+ 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by John C. Bowman <bowman@math.ualberta.ca>, 1995.
@@ -657,8 +657,6 @@ __NTH (ldexpl (long double __x, int __y))
__ldexp_code;
}
-__inline_mathcodeNP3 (fma, __x, __y, __z, return (__x * __y) + __z)
-
__inline_mathopNP (rint, "frndint")
# endif /* __FAST_MATH__ */
diff --git a/libc/sysdeps/i386/i686/multiarch/s_fma.c b/libc/sysdeps/i386/i686/multiarch/s_fma.c
index d9291b0be..2373caabc 100644
--- a/libc/sysdeps/i386/i686/multiarch/s_fma.c
+++ b/libc/sysdeps/i386/i686/multiarch/s_fma.c
@@ -33,4 +33,4 @@ weak_alias (__fma, fma)
# define __fma __fma_ia32
#endif
-#include <math/s_fma.c>
+#include <sysdeps/ieee754/ldbl-96/s_fma.c>
diff --git a/libc/sysdeps/ieee754/dbl-64/s_fma.c b/libc/sysdeps/ieee754/dbl-64/s_fma.c
new file mode 100644
index 000000000..3b0bfd5ce
--- /dev/null
+++ b/libc/sysdeps/ieee754/dbl-64/s_fma.c
@@ -0,0 +1,227 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <float.h>
+#include <math.h>
+#include <fenv.h>
+#include <ieee754.h>
+
+/* This implementation uses rounding to odd to avoid problems with
+ double rounding. See a paper by Boldo and Melquiond:
+ http://www.lri.fr/~melquion/doc/08-tc.pdf */
+
+double
+__fma (double x, double y, double z)
+{
+ union ieee754_double u, v, w;
+ int adjust = 0;
+ u.d = x;
+ v.d = y;
+ w.d = z;
+ if (__builtin_expect (u.ieee.exponent + v.ieee.exponent
+ >= 0x7ff + IEEE754_DOUBLE_BIAS - DBL_MANT_DIG, 0)
+ || __builtin_expect (u.ieee.exponent >= 0x7ff - DBL_MANT_DIG, 0)
+ || __builtin_expect (v.ieee.exponent >= 0x7ff - DBL_MANT_DIG, 0)
+ || __builtin_expect (w.ieee.exponent >= 0x7ff - DBL_MANT_DIG, 0)
+ || __builtin_expect (u.ieee.exponent + v.ieee.exponent
+ <= IEEE754_DOUBLE_BIAS + DBL_MANT_DIG, 0))
+ {
+ /* If z is Inf, but x and y are finite, the result should be
+ z rather than NaN. */
+ if (w.ieee.exponent == 0x7ff
+ && u.ieee.exponent != 0x7ff
+ && v.ieee.exponent != 0x7ff)
+ return (z + x) + y;
+ /* If x or y or z is Inf/NaN, or if fma will certainly overflow,
+ or if x * y is less than half of DBL_DENORM_MIN,
+ compute as x * y + z. */
+ if (u.ieee.exponent == 0x7ff
+ || v.ieee.exponent == 0x7ff
+ || w.ieee.exponent == 0x7ff
+ || u.ieee.exponent + v.ieee.exponent
+ > 0x7ff + IEEE754_DOUBLE_BIAS
+ || u.ieee.exponent + v.ieee.exponent
+ < IEEE754_DOUBLE_BIAS - DBL_MANT_DIG - 2)
+ return x * y + z;
+ if (u.ieee.exponent + v.ieee.exponent
+ >= 0x7ff + IEEE754_DOUBLE_BIAS - DBL_MANT_DIG)
+ {
+ /* Compute 1p-53 times smaller result and multiply
+ at the end. */
+ if (u.ieee.exponent > v.ieee.exponent)
+ u.ieee.exponent -= DBL_MANT_DIG;
+ else
+ v.ieee.exponent -= DBL_MANT_DIG;
+ /* If x + y exponent is very large and z exponent is very small,
+ it doesn't matter if we don't adjust it. */
+ if (w.ieee.exponent > DBL_MANT_DIG)
+ w.ieee.exponent -= DBL_MANT_DIG;
+ adjust = 1;
+ }
+ else if (w.ieee.exponent >= 0x7ff - DBL_MANT_DIG)
+ {
+ /* Similarly.
+ If z exponent is very large and x and y exponents are
+ very small, it doesn't matter if we don't adjust it. */
+ if (u.ieee.exponent > v.ieee.exponent)
+ {
+ if (u.ieee.exponent > DBL_MANT_DIG)
+ u.ieee.exponent -= DBL_MANT_DIG;
+ }
+ else if (v.ieee.exponent > DBL_MANT_DIG)
+ v.ieee.exponent -= DBL_MANT_DIG;
+ w.ieee.exponent -= DBL_MANT_DIG;
+ adjust = 1;
+ }
+ else if (u.ieee.exponent >= 0x7ff - DBL_MANT_DIG)
+ {
+ u.ieee.exponent -= DBL_MANT_DIG;
+ if (v.ieee.exponent)
+ v.ieee.exponent += DBL_MANT_DIG;
+ else
+ v.d *= 0x1p53;
+ }
+ else if (v.ieee.exponent >= 0x7ff - DBL_MANT_DIG)
+ {
+ v.ieee.exponent -= DBL_MANT_DIG;
+ if (u.ieee.exponent)
+ u.ieee.exponent += DBL_MANT_DIG;
+ else
+ u.d *= 0x1p53;
+ }
+ else /* if (u.ieee.exponent + v.ieee.exponent
+ <= IEEE754_DOUBLE_BIAS + DBL_MANT_DIG) */
+ {
+ if (u.ieee.exponent > v.ieee.exponent)
+ u.ieee.exponent += 2 * DBL_MANT_DIG;
+ else
+ v.ieee.exponent += 2 * DBL_MANT_DIG;
+ if (w.ieee.exponent <= 4 * DBL_MANT_DIG + 4)
+ {
+ if (w.ieee.exponent)
+ w.ieee.exponent += 2 * DBL_MANT_DIG;
+ else
+ w.d *= 0x1p106;
+ adjust = -1;
+ }
+ /* Otherwise x * y should just affect inexact
+ and nothing else. */
+ }
+ x = u.d;
+ y = v.d;
+ z = w.d;
+ }
+ /* Multiplication m1 + m2 = x * y using Dekker's algorithm. */
+#define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
+ double x1 = x * C;
+ double y1 = y * C;
+ double m1 = x * y;
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ double x2 = x - x1;
+ double y2 = y - y1;
+ double m2 = (((x1 * y1 - m1) + x1 * y2) + x2 * y1) + x2 * y2;
+
+ /* Addition a1 + a2 = z + m1 using Knuth's algorithm. */
+ double a1 = z + m1;
+ double t1 = a1 - z;
+ double t2 = a1 - t1;
+ t1 = m1 - t1;
+ t2 = z - t2;
+ double a2 = t1 + t2;
+
+ fenv_t env;
+ feholdexcept (&env);
+ fesetround (FE_TOWARDZERO);
+ /* Perform m2 + a2 addition with round to odd. */
+ u.d = a2 + m2;
+
+ if (__builtin_expect (adjust == 0, 1))
+ {
+ if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Result is a1 + u.d. */
+ return a1 + u.d;
+ }
+ else if (__builtin_expect (adjust > 0, 1))
+ {
+ if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Result is a1 + u.d, scaled up. */
+ return (a1 + u.d) * 0x1p53;
+ }
+ else
+ {
+ if ((u.ieee.mantissa1 & 1) == 0)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ v.d = a1 + u.d;
+ int j = fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Ensure the following computations are performed in default rounding
+ mode instead of just reusing the round to zero computation. */
+ asm volatile ("" : "=m" (u) : "m" (u));
+ /* If a1 + u.d is exact, the only rounding happens during
+ scaling down. */
+ if (j == 0)
+ return v.d * 0x1p-106;
+ /* If result rounded to zero is not subnormal, no double
+ rounding will occur. */
+ if (v.ieee.exponent > 106)
+ return (a1 + u.d) * 0x1p-106;
+ /* If v.d * 0x1p-106 with round to zero is a subnormal above
+ or equal to DBL_MIN / 2, then v.d * 0x1p-106 shifts mantissa
+ down just by 1 bit, which means v.ieee.mantissa1 |= j would
+ change the round bit, not sticky or guard bit.
+ v.d * 0x1p-106 never normalizes by shifting up,
+ so round bit plus sticky bit should be already enough
+ for proper rounding. */
+ if (v.ieee.exponent == 106)
+ {
+ /* v.ieee.mantissa1 & 2 is LSB bit of the result before rounding,
+ v.ieee.mantissa1 & 1 is the round bit and j is our sticky
+ bit. In round-to-nearest 001 rounds down like 00,
+ 011 rounds up, even though 01 rounds down (thus we need
+ to adjust), 101 rounds down like 10 and 111 rounds up
+ like 11. */
+ if ((v.ieee.mantissa1 & 3) == 1)
+ {
+ v.d *= 0x1p-106;
+ if (v.ieee.negative)
+ return v.d - 0x1p-1074 /* __DBL_DENORM_MIN__ */;
+ else
+ return v.d + 0x1p-1074 /* __DBL_DENORM_MIN__ */;
+ }
+ else
+ return v.d * 0x1p-106;
+ }
+ v.ieee.mantissa1 |= j;
+ return v.d * 0x1p-106;
+ }
+}
+#ifndef __fma
+weak_alias (__fma, fma)
+#endif
+
+#ifdef NO_LONG_DOUBLE
+strong_alias (__fma, __fmal)
+weak_alias (__fmal, fmal)
+#endif
diff --git a/libc/sysdeps/ieee754/dbl-64/s_fmaf.c b/libc/sysdeps/ieee754/dbl-64/s_fmaf.c
index 972187660..cd16cd1dc 100644
--- a/libc/sysdeps/ieee754/dbl-64/s_fmaf.c
+++ b/libc/sysdeps/ieee754/dbl-64/s_fmaf.c
@@ -39,7 +39,7 @@ __fmaf (float x, float y, float z)
fesetround (FE_TOWARDZERO);
/* Perform addition with round to odd. */
u.d = temp + (double) z;
- if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0xff)
+ if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff)
u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
feupdateenv (&env);
/* And finally truncation with round to nearest. */
diff --git a/libc/sysdeps/ieee754/ldbl-128/s_fma.c b/libc/sysdeps/ieee754/ldbl-128/s_fma.c
new file mode 100644
index 000000000..78055e5c6
--- /dev/null
+++ b/libc/sysdeps/ieee754/ldbl-128/s_fma.c
@@ -0,0 +1,50 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include <fenv.h>
+#include <ieee754.h>
+
+/* This implementation relies on long double being more than twice as
+ precise as double and uses rounding to odd in order to avoid problems
+ with double rounding.
+ See a paper by Boldo and Melquiond:
+ http://www.lri.fr/~melquion/doc/08-tc.pdf */
+
+double
+__fma (double x, double y, double z)
+{
+ fenv_t env;
+ /* Multiplication is always exact. */
+ long double temp = (long double) x * (long double) y;
+ union ieee854_long_double u;
+ feholdexcept (&env);
+ fesetround (FE_TOWARDZERO);
+ /* Perform addition with round to odd. */
+ u.d = temp + (long double) z;
+ if ((u.ieee.mantissa3 & 1) == 0 && u.ieee.exponent != 0x7fff)
+ u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* And finally truncation with round to nearest. */
+ return (double) u.d;
+}
+#ifndef __fma
+weak_alias (__fma, fma)
+#endif
diff --git a/libc/sysdeps/ieee754/ldbl-128/s_fmal.c b/libc/sysdeps/ieee754/ldbl-128/s_fmal.c
new file mode 100644
index 000000000..b750538b8
--- /dev/null
+++ b/libc/sysdeps/ieee754/ldbl-128/s_fmal.c
@@ -0,0 +1,223 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <float.h>
+#include <math.h>
+#include <fenv.h>
+#include <ieee754.h>
+
+/* This implementation uses rounding to odd to avoid problems with
+ double rounding. See a paper by Boldo and Melquiond:
+ http://www.lri.fr/~melquion/doc/08-tc.pdf */
+
+long double
+__fmal (long double x, long double y, long double z)
+{
+ union ieee854_long_double u, v, w;
+ int adjust = 0;
+ u.d = x;
+ v.d = y;
+ w.d = z;
+ if (__builtin_expect (u.ieee.exponent + v.ieee.exponent
+ >= 0x7fff + IEEE854_LONG_DOUBLE_BIAS
+ - LDBL_MANT_DIG, 0)
+ || __builtin_expect (u.ieee.exponent >= 0x7fff - LDBL_MANT_DIG, 0)
+ || __builtin_expect (v.ieee.exponent >= 0x7fff - LDBL_MANT_DIG, 0)
+ || __builtin_expect (w.ieee.exponent >= 0x7fff - LDBL_MANT_DIG, 0)
+ || __builtin_expect (u.ieee.exponent + v.ieee.exponent
+ <= IEEE854_LONG_DOUBLE_BIAS + LDBL_MANT_DIG, 0))
+ {
+ /* If z is Inf, but x and y are finite, the result should be
+ z rather than NaN. */
+ if (w.ieee.exponent == 0x7fff
+ && u.ieee.exponent != 0x7fff
+ && v.ieee.exponent != 0x7fff)
+ return (z + x) + y;
+ /* If x or y or z is Inf/NaN, or if fma will certainly overflow,
+ or if x * y is less than half of LDBL_DENORM_MIN,
+ compute as x * y + z. */
+ if (u.ieee.exponent == 0x7fff
+ || v.ieee.exponent == 0x7fff
+ || w.ieee.exponent == 0x7fff
+ || u.ieee.exponent + v.ieee.exponent
+ > 0x7fff + IEEE854_LONG_DOUBLE_BIAS
+ || u.ieee.exponent + v.ieee.exponent
+ < IEEE854_LONG_DOUBLE_BIAS - LDBL_MANT_DIG - 2)
+ return x * y + z;
+ if (u.ieee.exponent + v.ieee.exponent
+ >= 0x7fff + IEEE854_LONG_DOUBLE_BIAS - LDBL_MANT_DIG)
+ {
+ /* Compute 1p-113 times smaller result and multiply
+ at the end. */
+ if (u.ieee.exponent > v.ieee.exponent)
+ u.ieee.exponent -= LDBL_MANT_DIG;
+ else
+ v.ieee.exponent -= LDBL_MANT_DIG;
+ /* If x + y exponent is very large and z exponent is very small,
+ it doesn't matter if we don't adjust it. */
+ if (w.ieee.exponent > LDBL_MANT_DIG)
+ w.ieee.exponent -= LDBL_MANT_DIG;
+ adjust = 1;
+ }
+ else if (w.ieee.exponent >= 0x7fff - LDBL_MANT_DIG)
+ {
+ /* Similarly.
+ If z exponent is very large and x and y exponents are
+ very small, it doesn't matter if we don't adjust it. */
+ if (u.ieee.exponent > v.ieee.exponent)
+ {
+ if (u.ieee.exponent > LDBL_MANT_DIG)
+ u.ieee.exponent -= LDBL_MANT_DIG;
+ }
+ else if (v.ieee.exponent > LDBL_MANT_DIG)
+ v.ieee.exponent -= LDBL_MANT_DIG;
+ w.ieee.exponent -= LDBL_MANT_DIG;
+ adjust = 1;
+ }
+ else if (u.ieee.exponent >= 0x7fff - LDBL_MANT_DIG)
+ {
+ u.ieee.exponent -= LDBL_MANT_DIG;
+ if (v.ieee.exponent)
+ v.ieee.exponent += LDBL_MANT_DIG;
+ else
+ v.d *= 0x1p113L;
+ }
+ else if (v.ieee.exponent >= 0x7fff - LDBL_MANT_DIG)
+ {
+ v.ieee.exponent -= LDBL_MANT_DIG;
+ if (u.ieee.exponent)
+ u.ieee.exponent += LDBL_MANT_DIG;
+ else
+ u.d *= 0x1p113L;
+ }
+ else /* if (u.ieee.exponent + v.ieee.exponent
+ <= IEEE854_LONG_DOUBLE_BIAS + LDBL_MANT_DIG) */
+ {
+ if (u.ieee.exponent > v.ieee.exponent)
+ u.ieee.exponent += 2 * LDBL_MANT_DIG;
+ else
+ v.ieee.exponent += 2 * LDBL_MANT_DIG;
+ if (w.ieee.exponent <= 4 * LDBL_MANT_DIG + 4)
+ {
+ if (w.ieee.exponent)
+ w.ieee.exponent += 2 * LDBL_MANT_DIG;
+ else
+ w.d *= 0x1p226L;
+ adjust = -1;
+ }
+ /* Otherwise x * y should just affect inexact
+ and nothing else. */
+ }
+ x = u.d;
+ y = v.d;
+ z = w.d;
+ }
+ /* Multiplication m1 + m2 = x * y using Dekker's algorithm. */
+#define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
+ long double x1 = x * C;
+ long double y1 = y * C;
+ long double m1 = x * y;
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ long double x2 = x - x1;
+ long double y2 = y - y1;
+ long double m2 = (((x1 * y1 - m1) + x1 * y2) + x2 * y1) + x2 * y2;
+
+ /* Addition a1 + a2 = z + m1 using Knuth's algorithm. */
+ long double a1 = z + m1;
+ long double t1 = a1 - z;
+ long double t2 = a1 - t1;
+ t1 = m1 - t1;
+ t2 = z - t2;
+ long double a2 = t1 + t2;
+
+ fenv_t env;
+ feholdexcept (&env);
+ fesetround (FE_TOWARDZERO);
+ /* Perform m2 + a2 addition with round to odd. */
+ u.d = a2 + m2;
+
+ if (__builtin_expect (adjust == 0, 1))
+ {
+ if ((u.ieee.mantissa3 & 1) == 0 && u.ieee.exponent != 0x7fff)
+ u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Result is a1 + u.d. */
+ return a1 + u.d;
+ }
+ else if (__builtin_expect (adjust > 0, 1))
+ {
+ if ((u.ieee.mantissa3 & 1) == 0 && u.ieee.exponent != 0x7fff)
+ u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Result is a1 + u.d, scaled up. */
+ return (a1 + u.d) * 0x1p113L;
+ }
+ else
+ {
+ if ((u.ieee.mantissa3 & 1) == 0)
+ u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0;
+ v.d = a1 + u.d;
+ /* Ensure the addition is not scheduled after fetestexcept call. */
+ asm volatile ("" : "m" (v));
+ int j = fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Ensure the following computations are performed in default rounding
+ mode instead of just reusing the round to zero computation. */
+ asm volatile ("" : "=m" (u) : "m" (u));
+ /* If a1 + u.d is exact, the only rounding happens during
+ scaling down. */
+ if (j == 0)
+ return v.d * 0x1p-226L;
+ /* If result rounded to zero is not subnormal, no double
+ rounding will occur. */
+ if (v.ieee.exponent > 226)
+ return (a1 + u.d) * 0x1p-226L;
+ /* If v.d * 0x1p-226L with round to zero is a subnormal above
+ or equal to LDBL_MIN / 2, then v.d * 0x1p-226L shifts mantissa
+ down just by 1 bit, which means v.ieee.mantissa3 |= j would
+ change the round bit, not sticky or guard bit.
+ v.d * 0x1p-226L never normalizes by shifting up,
+ so round bit plus sticky bit should be already enough
+ for proper rounding. */
+ if (v.ieee.exponent == 226)
+ {
+ /* v.ieee.mantissa3 & 2 is LSB bit of the result before rounding,
+ v.ieee.mantissa3 & 1 is the round bit and j is our sticky
+ bit. In round-to-nearest 001 rounds down like 00,
+ 011 rounds up, even though 01 rounds down (thus we need
+ to adjust), 101 rounds down like 10 and 111 rounds up
+ like 11. */
+ if ((v.ieee.mantissa3 & 3) == 1)
+ {
+ v.d *= 0x1p-226L;
+ if (v.ieee.negative)
+ return v.d - 0x1p-16494L /* __LDBL_DENORM_MIN__ */;
+ else
+ return v.d + 0x1p-16494L /* __LDBL_DENORM_MIN__ */;
+ }
+ else
+ return v.d * 0x1p-226L;
+ }
+ v.ieee.mantissa3 |= j;
+ return v.d * 0x1p-226L;
+ }
+}
+weak_alias (__fmal, fmal)
diff --git a/libc/sysdeps/ieee754/ldbl-64-128/s_fmal.c b/libc/sysdeps/ieee754/ldbl-64-128/s_fmal.c
new file mode 100644
index 000000000..218aa52b3
--- /dev/null
+++ b/libc/sysdeps/ieee754/ldbl-64-128/s_fmal.c
@@ -0,0 +1,5 @@
+#include <math_ldbl_opt.h>
+#undef weak_alias
+#define weak_alias(n,a)
+#include <sysdeps/ieee754/ldbl-128/s_fmal.c>
+long_double_symbol (libm, __fmal, fmal);
diff --git a/libc/sysdeps/ieee754/ldbl-96/s_fma.c b/libc/sysdeps/ieee754/ldbl-96/s_fma.c
new file mode 100644
index 000000000..6c7e9d0d3
--- /dev/null
+++ b/libc/sysdeps/ieee754/ldbl-96/s_fma.c
@@ -0,0 +1,79 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <float.h>
+#include <math.h>
+#include <fenv.h>
+#include <ieee754.h>
+
+/* This implementation uses rounding to odd to avoid problems with
+ double rounding. See a paper by Boldo and Melquiond:
+ http://www.lri.fr/~melquion/doc/08-tc.pdf */
+
+double
+__fma (double x, double y, double z)
+{
+ if (__builtin_expect (isinf (z), 0))
+ {
+ /* If z is Inf, but x and y are finite, the result should be
+ z rather than NaN. */
+ if (finite (x) && finite (y))
+ return (z + x) + y;
+ return (x * y) + z;
+ }
+
+ /* Multiplication m1 + m2 = x * y using Dekker's algorithm. */
+#define C ((1ULL << (LDBL_MANT_DIG + 1) / 2) + 1)
+ long double x1 = (long double) x * C;
+ long double y1 = (long double) y * C;
+ long double m1 = (long double) x * y;
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ long double x2 = x - x1;
+ long double y2 = y - y1;
+ long double m2 = (((x1 * y1 - m1) + x1 * y2) + x2 * y1) + x2 * y2;
+
+ /* Addition a1 + a2 = z + m1 using Knuth's algorithm. */
+ long double a1 = z + m1;
+ long double t1 = a1 - z;
+ long double t2 = a1 - t1;
+ t1 = m1 - t1;
+ t2 = z - t2;
+ long double a2 = t1 + t2;
+
+ fenv_t env;
+ feholdexcept (&env);
+ fesetround (FE_TOWARDZERO);
+ /* Perform m2 + a2 addition with round to odd. */
+ a2 = a2 + m2;
+
+ /* Add that to a1 again using rounding to odd. */
+ union ieee854_long_double u;
+ u.d = a1 + a2;
+ if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7fff)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+
+ /* Add finally round to double precision. */
+ return u.d;
+}
+#ifndef __fma
+weak_alias (__fma, fma)
+#endif
diff --git a/libc/sysdeps/ieee754/ldbl-96/s_fmal.c b/libc/sysdeps/ieee754/ldbl-96/s_fmal.c
new file mode 100644
index 000000000..340f02536
--- /dev/null
+++ b/libc/sysdeps/ieee754/ldbl-96/s_fmal.c
@@ -0,0 +1,221 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <float.h>
+#include <math.h>
+#include <fenv.h>
+#include <ieee754.h>
+
+/* This implementation uses rounding to odd to avoid problems with
+ double rounding. See a paper by Boldo and Melquiond:
+ http://www.lri.fr/~melquion/doc/08-tc.pdf */
+
+long double
+__fmal (long double x, long double y, long double z)
+{
+ union ieee854_long_double u, v, w;
+ int adjust = 0;
+ u.d = x;
+ v.d = y;
+ w.d = z;
+ if (__builtin_expect (u.ieee.exponent + v.ieee.exponent
+ >= 0x7fff + IEEE854_LONG_DOUBLE_BIAS
+ - LDBL_MANT_DIG, 0)
+ || __builtin_expect (u.ieee.exponent >= 0x7fff - LDBL_MANT_DIG, 0)
+ || __builtin_expect (v.ieee.exponent >= 0x7fff - LDBL_MANT_DIG, 0)
+ || __builtin_expect (w.ieee.exponent >= 0x7fff - LDBL_MANT_DIG, 0)
+ || __builtin_expect (u.ieee.exponent + v.ieee.exponent
+ <= IEEE854_LONG_DOUBLE_BIAS + LDBL_MANT_DIG, 0))
+ {
+ /* If z is Inf, but x and y are finite, the result should be
+ z rather than NaN. */
+ if (w.ieee.exponent == 0x7fff
+ && u.ieee.exponent != 0x7fff
+ && v.ieee.exponent != 0x7fff)
+ return (z + x) + y;
+ /* If x or y or z is Inf/NaN, or if fma will certainly overflow,
+ or if x * y is less than half of LDBL_DENORM_MIN,
+ compute as x * y + z. */
+ if (u.ieee.exponent == 0x7fff
+ || v.ieee.exponent == 0x7fff
+ || w.ieee.exponent == 0x7fff
+ || u.ieee.exponent + v.ieee.exponent
+ > 0x7fff + IEEE854_LONG_DOUBLE_BIAS
+ || u.ieee.exponent + v.ieee.exponent
+ < IEEE854_LONG_DOUBLE_BIAS - LDBL_MANT_DIG - 2)
+ return x * y + z;
+ if (u.ieee.exponent + v.ieee.exponent
+ >= 0x7fff + IEEE854_LONG_DOUBLE_BIAS - LDBL_MANT_DIG)
+ {
+ /* Compute 1p-64 times smaller result and multiply
+ at the end. */
+ if (u.ieee.exponent > v.ieee.exponent)
+ u.ieee.exponent -= LDBL_MANT_DIG;
+ else
+ v.ieee.exponent -= LDBL_MANT_DIG;
+ /* If x + y exponent is very large and z exponent is very small,
+ it doesn't matter if we don't adjust it. */
+ if (w.ieee.exponent > LDBL_MANT_DIG)
+ w.ieee.exponent -= LDBL_MANT_DIG;
+ adjust = 1;
+ }
+ else if (w.ieee.exponent >= 0x7fff - LDBL_MANT_DIG)
+ {
+ /* Similarly.
+ If z exponent is very large and x and y exponents are
+ very small, it doesn't matter if we don't adjust it. */
+ if (u.ieee.exponent > v.ieee.exponent)
+ {
+ if (u.ieee.exponent > LDBL_MANT_DIG)
+ u.ieee.exponent -= LDBL_MANT_DIG;
+ }
+ else if (v.ieee.exponent > LDBL_MANT_DIG)
+ v.ieee.exponent -= LDBL_MANT_DIG;
+ w.ieee.exponent -= LDBL_MANT_DIG;
+ adjust = 1;
+ }
+ else if (u.ieee.exponent >= 0x7fff - LDBL_MANT_DIG)
+ {
+ u.ieee.exponent -= LDBL_MANT_DIG;
+ if (v.ieee.exponent)
+ v.ieee.exponent += LDBL_MANT_DIG;
+ else
+ v.d *= 0x1p64L;
+ }
+ else if (v.ieee.exponent >= 0x7fff - LDBL_MANT_DIG)
+ {
+ v.ieee.exponent -= LDBL_MANT_DIG;
+ if (u.ieee.exponent)
+ u.ieee.exponent += LDBL_MANT_DIG;
+ else
+ u.d *= 0x1p64L;
+ }
+ else /* if (u.ieee.exponent + v.ieee.exponent
+ <= IEEE854_LONG_DOUBLE_BIAS + LDBL_MANT_DIG) */
+ {
+ if (u.ieee.exponent > v.ieee.exponent)
+ u.ieee.exponent += 2 * LDBL_MANT_DIG;
+ else
+ v.ieee.exponent += 2 * LDBL_MANT_DIG;
+ if (w.ieee.exponent <= 4 * LDBL_MANT_DIG + 4)
+ {
+ if (w.ieee.exponent)
+ w.ieee.exponent += 2 * LDBL_MANT_DIG;
+ else
+ w.d *= 0x1p128L;
+ adjust = -1;
+ }
+ /* Otherwise x * y should just affect inexact
+ and nothing else. */
+ }
+ x = u.d;
+ y = v.d;
+ z = w.d;
+ }
+ /* Multiplication m1 + m2 = x * y using Dekker's algorithm. */
+#define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
+ long double x1 = x * C;
+ long double y1 = y * C;
+ long double m1 = x * y;
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ long double x2 = x - x1;
+ long double y2 = y - y1;
+ long double m2 = (((x1 * y1 - m1) + x1 * y2) + x2 * y1) + x2 * y2;
+
+ /* Addition a1 + a2 = z + m1 using Knuth's algorithm. */
+ long double a1 = z + m1;
+ long double t1 = a1 - z;
+ long double t2 = a1 - t1;
+ t1 = m1 - t1;
+ t2 = z - t2;
+ long double a2 = t1 + t2;
+
+ fenv_t env;
+ feholdexcept (&env);
+ fesetround (FE_TOWARDZERO);
+ /* Perform m2 + a2 addition with round to odd. */
+ u.d = a2 + m2;
+
+ if (__builtin_expect (adjust == 0, 1))
+ {
+ if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7fff)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Result is a1 + u.d. */
+ return a1 + u.d;
+ }
+ else if (__builtin_expect (adjust > 0, 1))
+ {
+ if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7fff)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Result is a1 + u.d, scaled up. */
+ return (a1 + u.d) * 0x1p64L;
+ }
+ else
+ {
+ if ((u.ieee.mantissa1 & 1) == 0)
+ u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
+ v.d = a1 + u.d;
+ int j = fetestexcept (FE_INEXACT) != 0;
+ feupdateenv (&env);
+ /* Ensure the following computations are performed in default rounding
+ mode instead of just reusing the round to zero computation. */
+ asm volatile ("" : "=m" (u) : "m" (u));
+ /* If a1 + u.d is exact, the only rounding happens during
+ scaling down. */
+ if (j == 0)
+ return v.d * 0x1p-128L;
+ /* If result rounded to zero is not subnormal, no double
+ rounding will occur. */
+ if (v.ieee.exponent > 128)
+ return (a1 + u.d) * 0x1p-128L;
+ /* If v.d * 0x1p-128L with round to zero is a subnormal above
+ or equal to LDBL_MIN / 2, then v.d * 0x1p-128L shifts mantissa
+ down just by 1 bit, which means v.ieee.mantissa1 |= j would
+ change the round bit, not sticky or guard bit.
+ v.d * 0x1p-128L never normalizes by shifting up,
+ so round bit plus sticky bit should be already enough
+ for proper rounding. */
+ if (v.ieee.exponent == 128)
+ {
+ /* v.ieee.mantissa1 & 2 is LSB bit of the result before rounding,
+ v.ieee.mantissa1 & 1 is the round bit and j is our sticky
+ bit. In round-to-nearest 001 rounds down like 00,
+ 011 rounds up, even though 01 rounds down (thus we need
+ to adjust), 101 rounds down like 10 and 111 rounds up
+ like 11. */
+ if ((v.ieee.mantissa1 & 3) == 1)
+ {
+ v.d *= 0x1p-128L;
+ if (v.ieee.negative)
+ return v.d - 0x1p-16445L /* __LDBL_DENORM_MIN__ */;
+ else
+ return v.d + 0x1p-16445L /* __LDBL_DENORM_MIN__ */;
+ }
+ else
+ return v.d * 0x1p-128L;
+ }
+ v.ieee.mantissa1 |= j;
+ return v.d * 0x1p-128L;
+ }
+}
+weak_alias (__fmal, fmal)
diff --git a/libc/sysdeps/ieee754/ldbl-opt/s_fma.c b/libc/sysdeps/ieee754/ldbl-opt/s_fma.c
index 2ee721413..1723c5c30 100644
--- a/libc/sysdeps/ieee754/ldbl-opt/s_fma.c
+++ b/libc/sysdeps/ieee754/ldbl-opt/s_fma.c
@@ -1,5 +1,5 @@
#include <math_ldbl_opt.h>
-#include <math/s_fma.c>
+#include <sysdeps/ieee754/dbl-64/s_fma.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __fma, fmal, GLIBC_2_1);
#endif
diff --git a/libc/sysdeps/powerpc/bits/mathdef.h b/libc/sysdeps/powerpc/bits/mathdef.h
index e3d53922c..5207062ee 100644
--- a/libc/sysdeps/powerpc/bits/mathdef.h
+++ b/libc/sysdeps/powerpc/bits/mathdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,1998,1999,2000,2003,2004,2006
+/* Copyright (C) 1997,1998,1999,2000,2003,2004,2006,2010
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -39,4 +39,8 @@ typedef double double_t;
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN (2147483647)
+/* The powerpc has a combined multiply/add instruction. */
+# define FP_FAST_FMA 1
+# define FP_FAST_FMAF 1
+
#endif /* ISO C99 */
diff --git a/libc/sysdeps/i386/fpu/s_fma.S b/libc/sysdeps/powerpc/fpu/s_fma.S
index db4959ccf..9c650eab0 100644
--- a/libc/sysdeps/i386/fpu/s_fma.S
+++ b/libc/sysdeps/powerpc/fpu/s_fma.S
@@ -1,7 +1,6 @@
-/* Compute (X * Y) + Z as ternary operation.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Compute x * y + z as ternary operation. PowerPC version.
+ Copyright (C) 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -20,12 +19,15 @@
#include <sysdep.h>
- .text
ENTRY(__fma)
- fldl 4(%esp) // x
- fmull 12(%esp) // x * y
- fldl 20(%esp) // z : x * y
- faddp // (x * y) + z
- ret
+/* double [f1] fma (double [f1] x, double [f2] y, double [f3] z); */
+ fmadd fp1,fp1,fp2,fp3
+ blr
END(__fma)
-weak_alias (__fma, fma)
+
+weak_alias (__fma,fma)
+
+#ifdef NO_LONG_DOUBLE
+weak_alias (__fma,__fmal)
+weak_alias (__fma,fmal)
+#endif
diff --git a/libc/sysdeps/i386/fpu/s_fmaf.S b/libc/sysdeps/powerpc/fpu/s_fmaf.S
index 5f875532a..1a755fe2d 100644
--- a/libc/sysdeps/i386/fpu/s_fmaf.S
+++ b/libc/sysdeps/powerpc/fpu/s_fmaf.S
@@ -1,7 +1,6 @@
-/* Compute (X * Y) + Z as ternary operation.
- Copyright (C) 1997 Free Software Foundation, Inc.
+/* Compute x * y + z as ternary operation. PowerPC version.
+ Copyright (C) 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -20,12 +19,10 @@
#include <sysdep.h>
- .text
ENTRY(__fmaf)
- flds 4(%esp) // x
- fmuls 8(%esp) // x * y
- flds 12(%esp) // z : x * y
- faddp // (x * y) + z
- ret
+/* float [f1] fmaf (float [f1] x, float [f2] y, float [f3] z); */
+ fmadds fp1,fp1,fp2,fp3
+ blr
END(__fmaf)
-weak_alias (__fmaf, fmaf)
+
+weak_alias (__fmaf,fmaf)
diff --git a/libc/sysdeps/powerpc/powerpc32/fpu/s_fma.S b/libc/sysdeps/powerpc/powerpc32/fpu/s_fma.S
new file mode 100644
index 000000000..d40695c63
--- /dev/null
+++ b/libc/sysdeps/powerpc/powerpc32/fpu/s_fma.S
@@ -0,0 +1,5 @@
+#include <math_ldbl_opt.h>
+#include <sysdeps/powerpc/fpu/s_fma.S>
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
+compat_symbol (libm, __fma, fmal, GLIBC_2_1)
+#endif
diff --git a/libc/sysdeps/powerpc/powerpc64/fpu/s_fma.S b/libc/sysdeps/powerpc/powerpc64/fpu/s_fma.S
new file mode 100644
index 000000000..d40695c63
--- /dev/null
+++ b/libc/sysdeps/powerpc/powerpc64/fpu/s_fma.S
@@ -0,0 +1,5 @@
+#include <math_ldbl_opt.h>
+#include <sysdeps/powerpc/fpu/s_fma.S>
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
+compat_symbol (libm, __fma, fmal, GLIBC_2_1)
+#endif
diff --git a/libc/sysdeps/s390/fpu/s_fma.c b/libc/sysdeps/s390/fpu/s_fma.c
new file mode 100644
index 000000000..f68236231
--- /dev/null
+++ b/libc/sysdeps/s390/fpu/s_fma.c
@@ -0,0 +1,37 @@
+/* Compute x * y + z as ternary operation. S/390 version.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+double
+__fma (double x, double y, double z)
+{
+ double r;
+ asm ("madbr %0,%1,%2" : "=f" (r) : "%f" (x), "fR" (y), "0" (z));
+ return r;
+}
+#ifndef __fma
+weak_alias (__fma, fma)
+#endif
+
+#ifdef NO_LONG_DOUBLE
+strong_alias (__fma, __fmal)
+weak_alias (__fmal, fmal)
+#endif
diff --git a/libc/sysdeps/i386/fpu/s_fmal.S b/libc/sysdeps/s390/fpu/s_fmaf.c
index 1837f848c..030d7b229 100644
--- a/libc/sysdeps/i386/fpu/s_fmal.S
+++ b/libc/sysdeps/s390/fpu/s_fmaf.c
@@ -1,7 +1,7 @@
-/* Compute (X * Y) + Z as ternary operation.
- Copyright (C) 1997 Free Software Foundation, Inc.
+/* Compute x * y + z as ternary operation. S/390 version.
+ Copyright (C) 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,15 +18,15 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <sysdep.h>
+#include <math.h>
- .text
-ENTRY(__fmal)
- fldt 4(%esp) // x
- fldt 16(%esp) // x : y
- fmulp // x * y
- fldt 28(%esp) // z : x * y
- faddp // (x * y) + z
- ret
-END(__fmal)
-weak_alias (__fmal, fmal)
+float
+__fmaf (float x, float y, float z)
+{
+ float r;
+ asm ("maebr %0,%1,%2" : "=f" (r) : "%f" (x), "fR" (y), "0" (z));
+ return r;
+}
+#ifndef __fmaf
+weak_alias (__fmaf, fmaf)
+#endif
diff --git a/libc/sysdeps/unix/sysv/linux/s390/fpu/s_fma.c b/libc/sysdeps/unix/sysv/linux/s390/fpu/s_fma.c
new file mode 100644
index 000000000..2b2d50503
--- /dev/null
+++ b/libc/sysdeps/unix/sysv/linux/s390/fpu/s_fma.c
@@ -0,0 +1,5 @@
+#include <math_ldbl_opt.h>
+#include <sysdeps/s390/fpu/s_fma.c>
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
+compat_symbol (libm, __fma, fmal, GLIBC_2_1);
+#endif
diff --git a/libc/sysdeps/x86_64/bits/mathdef.h b/libc/sysdeps/x86_64/bits/mathdef.h
index 7b1618959..91463921b 100644
--- a/libc/sysdeps/x86_64/bits/mathdef.h
+++ b/libc/sysdeps/x86_64/bits/mathdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2004, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -45,4 +45,18 @@ typedef long double double_t; /* `double' expressions are evaluated as
# define FP_ILOGB0 (-2147483647 - 1)
# define FP_ILOGBNAN (-2147483647 - 1)
+/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
+ builtins are supported. */
+# if __FP_FAST_FMA
+# define FP_FAST_FMA 1
+# endif
+
+# if __FP_FAST_FMAF
+# define FP_FAST_FMAF 1
+# endif
+
+# if __FP_FAST_FMAL
+# define FP_FAST_FMAL 1
+# endif
+
#endif /* ISO C99 */
diff --git a/libc/sysdeps/x86_64/multiarch/s_fma.c b/libc/sysdeps/x86_64/multiarch/s_fma.c
index cfecf9b41..9a680c68f 100644
--- a/libc/sysdeps/x86_64/multiarch/s_fma.c
+++ b/libc/sysdeps/x86_64/multiarch/s_fma.c
@@ -1,5 +1,5 @@
/* FMA version of fma.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Contributed by Intel Corporation.
This file is part of the GNU C Library.
@@ -40,4 +40,4 @@ weak_alias (__fma, fma)
# define __fma __fma_sse2
#endif
-#include <math/s_fma.c>
+#include <sysdeps/ieee754/dbl-64/s_fma.c>
diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm
index 02affa8ce..69a28c6ba 100644
--- a/ports/ChangeLog.arm
+++ b/ports/ChangeLog.arm
@@ -1,3 +1,8 @@
+2010-10-19 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/arm/bits/mathdef.h (FP_FAST_FMA, FP_FAST_FMAF,
+ FP_FAST_FMAL): Define if associated GCC macros are defined.
+
2010-10-11 Joseph Myers <joseph@codesourcery.com>
* sysdeps/arm/eabi/feupdateenv.c (feupdateenv): Add
diff --git a/ports/ChangeLog.mips b/ports/ChangeLog.mips
index 8daa71c15..8ea85cce9 100644
--- a/ports/ChangeLog.mips
+++ b/ports/ChangeLog.mips
@@ -1,3 +1,10 @@
+2010-10-21 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/mips32/syscalls.list,
+ sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list,
+ sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list: Add entries
+ for fanotify_mark.
+
2010-10-11 Joseph Myers <joseph@codesourcery.com>
* sysdeps/mips/fpu/feupdateenv.c (feupdateenv): Add
diff --git a/ports/sysdeps/arm/bits/mathdef.h b/ports/sysdeps/arm/bits/mathdef.h
index daca1102f..97f5d4d22 100644
--- a/ports/sysdeps/arm/bits/mathdef.h
+++ b/ports/sysdeps/arm/bits/mathdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2004, 2006, 2007
+/* Copyright (C) 1999, 2000, 2004, 2006, 2007, 2010
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -34,6 +34,20 @@ typedef double double_t; /* `double' expressions are evaluated as
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN (2147483647)
+/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
+ builtins are supported. */
+# if __FP_FAST_FMA
+# define FP_FAST_FMA 1
+# endif
+
+# if __FP_FAST_FMAF
+# define FP_FAST_FMAF 1
+# endif
+
+# if __FP_FAST_FMAL
+# define FP_FAST_FMAL 1
+# endif
+
#endif /* ISO C99 */
#ifndef __NO_LONG_DOUBLE_MATH
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/ports/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
index dbeb184d7..f357b5c91 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
@@ -1,3 +1,5 @@
# File name Caller Syscall name # args Strong name Weak names
prlimit64 EXTRA prlimit64 i:iipp prlimit64
+
+fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
index 7a6a77779..87c194990 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
@@ -6,3 +6,5 @@ ftruncate - ftruncate i:ii __ftruncate ftruncate ftruncate64 __ftruncate64
truncate - truncate i:si truncate truncate64
prlimit64 EXTRA prlimit64 i:iipp prlimit64
+
+fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index a7bccdd37..2c8c4d484 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -1,3 +1,5 @@
# File name Caller Syscall name # args Strong name Weak names
prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
+
+fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark