This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, hjl/pr14117, created. glibc-2.15-1154-gd153c6f
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 4 Jun 2012 20:39:49 -0000
- Subject: GNU C Library master sources branch, hjl/pr14117, created. glibc-2.15-1154-gd153c6f
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/pr14117 has been created
at d153c6f554590a2976359765a793494c155b6234 (commit)
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d153c6f554590a2976359765a793494c155b6234
commit d153c6f554590a2976359765a793494c155b6234
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jun 4 13:38:57 2012 -0700
Use i486 bits/string.h for i386 and x86_64
diff --git a/ChangeLog.pr14117 b/ChangeLog.pr14117
index 4cdc2f9..df2c363 100644
--- a/ChangeLog.pr14117
+++ b/ChangeLog.pr14117
@@ -1,6 +1,10 @@
2012-06-04 H.J. Lu <hongjiu.lu@intel.com>
[BZ #14117]
+ * sysdeps/i386/i486/bits/string.h: Renamed to ...
+ * sysdeps/x86/bits/string.h: This.
+ * sysdeps/x86_64/bits/string.h: Removed.
+
* sysdeps/i386/i486/bits/string.h: Define inline functions only
if not compiling for x86-64, but compiling for >= i486.
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/x86/bits/string.h
similarity index 100%
rename from sysdeps/i386/i486/bits/string.h
rename to sysdeps/x86/bits/string.h
diff --git a/sysdeps/x86_64/bits/string.h b/sysdeps/x86_64/bits/string.h
deleted file mode 100644
index 0ca5fe2..0000000
--- a/sysdeps/x86_64/bits/string.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Optimized, inlined string functions. AMD x86-64 version.
- Copyright (C) 2001 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
- 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, see
- <http://www.gnu.org/licenses/>. */
-
-#ifndef _STRING_H
-# error "Never use <bits/string.h> directly; include <string.h> instead."
-#endif
-
-/* Currently the only purpose of this file is to tell the generic inline
- macros that unaligned memory access is possible for x86-64. */
-#define _STRING_ARCH_unaligned 1
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f2f8becc07c2f02f1cb40285b224ee006f43c93d
commit f2f8becc07c2f02f1cb40285b224ee006f43c93d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jun 4 13:37:42 2012 -0700
Provide 32-bit inline string functions for >= i486
diff --git a/ChangeLog.pr14117 b/ChangeLog.pr14117
index 8fc5950..4cdc2f9 100644
--- a/ChangeLog.pr14117
+++ b/ChangeLog.pr14117
@@ -1,6 +1,9 @@
2012-06-04 H.J. Lu <hongjiu.lu@intel.com>
[BZ #14117]
+ * sysdeps/i386/i486/bits/string.h: Define inline functions only
+ if not compiling for x86-64, but compiling for >= i486.
+
* sysdeps/i386/fpu/bits/mathinline.h: Removed.
* sysdeps/x86_64/fpu/bits/mathinline.h: Renamed to ...
* sysdeps/x86/fpu/bits/mathinline.h: This.
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h
index a5edf51..d47a31c 100644
--- a/sysdeps/i386/i486/bits/string.h
+++ b/sysdeps/i386/i486/bits/string.h
@@ -1,6 +1,5 @@
-/* Optimized, inlined string functions. i486 version.
- Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2004,2007,2011,2012
- Free Software Foundation, Inc.
+/* Optimized, inlined string functions. i486/x86-64 version.
+ Copyright (C) 2001-2012 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
@@ -24,25 +23,34 @@
/* The ix86 processors can access unaligned multi-byte variables. */
#define _STRING_ARCH_unaligned 1
+/* Enable inline functions only for i486 or bette when compiling for
+ ia32. */
+#if !defined __x86_64__ && (defined __i486__ || defined __pentium__ \
+ || defined __pentiumpro__ || defined __pentium4__ \
+ || defined __nocona__ || defined __atom__ \
+ || defined __core2__ || defined __corei7__ \
+ || defined __k6__ || defined __geode__ \
+ || defined __k8__ || defined __athlon__ \
+ || defined __amdfam10__)
/* We only provide optimizations if the user selects them and if
GNU CC is used. */
-#if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \
+# if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \
&& defined __GNUC__ && __GNUC__ >= 2 && !__BOUNDED_POINTERS__
-#ifndef __STRING_INLINE
-# ifndef __extern_inline
-# define __STRING_INLINE inline
-# else
-# define __STRING_INLINE __extern_inline
+# ifndef __STRING_INLINE
+# ifndef __extern_inline
+# define __STRING_INLINE inline
+# else
+# define __STRING_INLINE __extern_inline
+# endif
# endif
-#endif
/* The macros are used in some of the optimized implementations below. */
-#define __STRING_SMALL_GET16(src, idx) \
+# define __STRING_SMALL_GET16(src, idx) \
((((const unsigned char *) (src))[idx + 1] << 8) \
| ((const unsigned char *) (src))[idx])
-#define __STRING_SMALL_GET32(src, idx) \
+# define __STRING_SMALL_GET32(src, idx) \
(((((const unsigned char *) (src))[idx + 3] << 8 \
| ((const unsigned char *) (src))[idx + 2]) << 8 \
| ((const unsigned char *) (src))[idx + 1]) << 8 \
@@ -50,12 +58,12 @@
/* Copy N bytes of SRC to DEST. */
-#define _HAVE_STRING_ARCH_memcpy 1
-#define memcpy(dest, src, n) \
+# define _HAVE_STRING_ARCH_memcpy 1
+# define memcpy(dest, src, n) \
(__extension__ (__builtin_constant_p (n) \
? __memcpy_c ((dest), (src), (n)) \
: __memcpy_g ((dest), (src), (n))))
-#define __memcpy_c(dest, src, n) \
+# define __memcpy_c(dest, src, n) \
((n) == 0 \
? (dest) \
: (((n) % 4 == 0) \
@@ -139,11 +147,11 @@ __memcpy_g (void *__dest, const void *__src, size_t __n)
return __dest;
}
-#define _HAVE_STRING_ARCH_memmove 1
-#ifndef _FORCE_INLINES
+# define _HAVE_STRING_ARCH_memmove 1
+# ifndef _FORCE_INLINES
/* Copy N bytes of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
-#define memmove(dest, src, n) __memmove_g (dest, src, n)
+# define memmove(dest, src, n) __memmove_g (dest, src, n)
__STRING_INLINE void *__memmove_g (void *, const void *, size_t)
__asm__ ("memmove");
@@ -173,12 +181,12 @@ __memmove_g (void *__dest, const void *__src, size_t __n)
"m" ( *(struct { __extension__ char __x[__n]; } *)__src));
return __dest;
}
-#endif
+# endif
/* Compare N bytes of S1 and S2. */
-#define _HAVE_STRING_ARCH_memcmp 1
-#ifndef _FORCE_INLINES
-# ifndef __PIC__
+# define _HAVE_STRING_ARCH_memcmp 1
+# ifndef _FORCE_INLINES
+# ifndef __PIC__
/* gcc has problems to spill registers when using PIC. */
__STRING_INLINE int
memcmp (const void *__s1, const void *__s2, size_t __n)
@@ -200,13 +208,13 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
: "cc");
return __res;
}
+# endif
# endif
-#endif
/* Set N bytes of S to C. */
-#define _HAVE_STRING_ARCH_memset 1
-#define _USE_STRING_ARCH_memset 1
-#define memset(s, c, n) \
+# define _HAVE_STRING_ARCH_memset 1
+# define _USE_STRING_ARCH_memset 1
+# define memset(s, c, n) \
(__extension__ (__builtin_constant_p (n) && (n) <= 16 \
? ((n) == 1 \
? __memset_c1 ((s), (c)) \
@@ -219,11 +227,11 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
? __memset_gcn ((s), (c), (n)) \
: memset ((s), (c), (n))))))
-#define __memset_c1(s, c) ({ void *__s = (s); \
- *((unsigned char *) __s) = (unsigned char) (c); \
- __s; })
+# define __memset_c1(s, c) ({ void *__s = (s); \
+ *((unsigned char *) __s) = (unsigned char) (c); \
+ __s; })
-#define __memset_gc(s, c, n) \
+# define __memset_gc(s, c, n) \
({ void *__s = (s); \
union { \
unsigned int __ui; \
@@ -300,7 +308,7 @@ memcmp (const void *__s1, const void *__s2, size_t __n)
\
__s; })
-#define __memset_ccn(s, c, n) \
+# define __memset_ccn(s, c, n) \
(((n) % 4 == 0) \
? __memset_ccn_by4 (s, ((unsigned int) ((unsigned char) (c))) * 0x01010101,\
n) \
@@ -318,7 +326,7 @@ __memset_ccn_by4 (void *__s, unsigned int __c, size_t __n)
{
register void *__tmp = __s;
register unsigned long int __d0;
-#ifdef __i686__
+# ifdef __i686__
__asm__ __volatile__
("cld\n\t"
"rep; stosl"
@@ -326,7 +334,7 @@ __memset_ccn_by4 (void *__s, unsigned int __c, size_t __n)
"=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
: "cc");
-#else
+# else
__asm__ __volatile__
("1:\n\t"
"movl %0,(%1)\n\t"
@@ -337,7 +345,7 @@ __memset_ccn_by4 (void *__s, unsigned int __c, size_t __n)
"=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
: "cc");
-#endif
+# endif
return __s;
}
@@ -349,7 +357,7 @@ __memset_ccn_by2 (void *__s, unsigned int __c, size_t __n)
{
register unsigned long int __d0, __d1;
register void *__tmp = __s;
-#ifdef __i686__
+# ifdef __i686__
__asm__ __volatile__
("cld\n\t"
"rep; stosl\n"
@@ -358,7 +366,7 @@ __memset_ccn_by2 (void *__s, unsigned int __c, size_t __n)
"=m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "0" ((unsigned int) __c), "1" (__tmp), "2" (__n / 4)
: "cc");
-#else
+# else
__asm__ __volatile__
("1:\tmovl %0,(%1)\n\t"
"leal 4(%1),%1\n\t"
@@ -373,7 +381,7 @@ __memset_ccn_by2 (void *__s, unsigned int __c, size_t __n)
return __s;
}
-#define __memset_gcn(s, c, n) \
+# define __memset_gcn(s, c, n) \
(((n) % 4 == 0) \
? __memset_gcn_by4 (s, c, n) \
: (((n) % 2 == 0) \
@@ -431,19 +439,19 @@ __memset_gcn_by2 (void *__s, int __c, size_t __n)
/* Search N bytes of S for C. */
-#define _HAVE_STRING_ARCH_memchr 1
-#ifndef _FORCE_INLINES
+# define _HAVE_STRING_ARCH_memchr 1
+# ifndef _FORCE_INLINES
__STRING_INLINE void *
memchr (const void *__s, int __c, size_t __n)
{
register unsigned long int __d0;
-#ifdef __i686__
+# ifdef __i686__
register unsigned long int __d1;
-#endif
+# endif
register unsigned char *__res;
if (__n == 0)
return NULL;
-#ifdef __i686__
+# ifdef __i686__
__asm__ __volatile__
("cld\n\t"
"repne; scasb\n\t"
@@ -452,7 +460,7 @@ memchr (const void *__s, int __c, size_t __n)
: "a" (__c), "0" (__s), "1" (__n), "2" (1),
"m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "cc");
-#else
+# else
__asm__ __volatile__
("cld\n\t"
"repne; scasb\n\t"
@@ -463,26 +471,26 @@ memchr (const void *__s, int __c, size_t __n)
: "a" (__c), "0" (__s), "1" (__n),
"m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "cc");
-#endif
+# endif
return __res - 1;
}
-#endif
+# endif
-#define _HAVE_STRING_ARCH_memrchr 1
-#ifndef _FORCE_INLINES
+# define _HAVE_STRING_ARCH_memrchr 1
+# ifndef _FORCE_INLINES
__STRING_INLINE void *__memrchr (const void *__s, int __c, size_t __n);
__STRING_INLINE void *
__memrchr (const void *__s, int __c, size_t __n)
{
register unsigned long int __d0;
-# ifdef __i686__
+# ifdef __i686__
register unsigned long int __d1;
-# endif
+# endif
register void *__res;
if (__n == 0)
return NULL;
-# ifdef __i686__
+# ifdef __i686__
__asm__ __volatile__
("std\n\t"
"repne; scasb\n\t"
@@ -493,7 +501,7 @@ __memrchr (const void *__s, int __c, size_t __n)
: "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1),
"m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "cc");
-# else
+# else
__asm__ __volatile__
("std\n\t"
"repne; scasb\n\t"
@@ -505,19 +513,19 @@ __memrchr (const void *__s, int __c, size_t __n)
: "a" (__c), "0" (__s + __n - 1), "1" (__n),
"m" ( *(struct { __extension__ char __x[__n]; } *)__s)
: "cc");
-# endif
+# endif
return __res;
}
-# ifdef __USE_GNU
-# define memrchr(s, c, n) __memrchr ((s), (c), (n))
+# ifdef __USE_GNU
+# define memrchr(s, c, n) __memrchr ((s), (c), (n))
+# endif
# endif
-#endif
/* Return pointer to C in S. */
-#define _HAVE_STRING_ARCH_rawmemchr 1
+# define _HAVE_STRING_ARCH_rawmemchr 1
__STRING_INLINE void *__rawmemchr (const void *__s, int __c);
-#ifndef _FORCE_INLINES
+# ifndef _FORCE_INLINES
__STRING_INLINE void *
__rawmemchr (const void *__s, int __c)
{
@@ -532,19 +540,19 @@ __rawmemchr (const void *__s, int __c)
: "cc");
return __res - 1;
}
-# ifdef __USE_GNU
+# ifdef __USE_GNU
__STRING_INLINE void *
rawmemchr (const void *__s, int __c)
{
return __rawmemchr (__s, __c);
}
-# endif /* use GNU */
-#endif
+# endif /* use GNU */
+# endif
/* Return the length of S. */
-#define _HAVE_STRING_ARCH_strlen 1
-#define strlen(str) \
+# define _HAVE_STRING_ARCH_strlen 1
+# define strlen(str) \
(__extension__ (__builtin_constant_p (str) \
? __builtin_strlen (str) \
: __strlen_g (str)))
@@ -570,8 +578,8 @@ __strlen_g (const char *__str)
/* Copy SRC to DEST. */
-#define _HAVE_STRING_ARCH_strcpy 1
-#define strcpy(dest, src) \
+# define _HAVE_STRING_ARCH_strcpy 1
+# define strcpy(dest, src) \
(__extension__ (__builtin_constant_p (src) \
? (sizeof ((src)[0]) == 1 && strlen (src) + 1 <= 8 \
? __strcpy_a_small ((dest), (src), strlen (src) + 1) \
@@ -580,7 +588,7 @@ __strlen_g (const char *__str)
strlen (src) + 1)) \
: __strcpy_g ((dest), (src))))
-#define __strcpy_a_small(dest, src, srclen) \
+# define __strcpy_a_small(dest, src, srclen) \
(__extension__ ({ char *__dest = (dest); \
union { \
unsigned int __ui; \
@@ -654,16 +662,16 @@ __strcpy_g (char *__dest, const char *__src)
}
-#ifdef __USE_GNU
-# define _HAVE_STRING_ARCH_stpcpy 1
+# ifdef __USE_GNU
+# define _HAVE_STRING_ARCH_stpcpy 1
/* Copy SRC to DEST. */
-# define __stpcpy(dest, src) \
+# define __stpcpy(dest, src) \
(__extension__ (__builtin_constant_p (src) \
? (strlen (src) + 1 <= 8 \
? __stpcpy_a_small ((dest), (src), strlen (src) + 1) \
: __stpcpy_c ((dest), (src), strlen (src) + 1)) \
: __stpcpy_g ((dest), (src))))
-# define __stpcpy_c(dest, src, srclen) \
+# define __stpcpy_c(dest, src, srclen) \
((srclen) % 4 == 0 \
? __mempcpy_by4 (dest, src, srclen) - 1 \
: ((srclen) % 2 == 0 \
@@ -671,9 +679,9 @@ __strcpy_g (char *__dest, const char *__src)
: __mempcpy_byn (dest, src, srclen) - 1))
/* In glibc itself we use this symbol for namespace reasons. */
-# define stpcpy(dest, src) __stpcpy ((dest), (src))
+# define stpcpy(dest, src) __stpcpy ((dest), (src))
-# define __stpcpy_a_small(dest, src, srclen) \
+# define __stpcpy_a_small(dest, src, srclen) \
(__extension__ ({ union { \
unsigned int __ui; \
unsigned short int __usi; \
@@ -826,19 +834,19 @@ __stpcpy_g (char *__dest, const char *__src)
: "cc");
return __tmp - 1;
}
-#endif
+# endif
/* Copy no more than N characters of SRC to DEST. */
-#define _HAVE_STRING_ARCH_strncpy 1
-#define strncpy(dest, src, n) \
+# define _HAVE_STRING_ARCH_strncpy 1
+# define strncpy(dest, src, n) \
(__extension__ (__builtin_constant_p (src) \
? ((strlen (src) + 1 >= ((size_t) (n)) \
? (char *) memcpy ((char *) (dest), \
(const char *) (src), n) \
: __strncpy_cg ((dest), (src), strlen (src) + 1, n))) \
: __strncpy_gg ((dest), (src), n)))
-#define __strncpy_cg(dest, src, srclen, n) \
+# define __strncpy_cg(dest, src, srclen, n) \
(((srclen) % 4 == 0) \
? __strncpy_by4 (dest, src, srclen, n) \
: (((srclen) % 2 == 0) \
@@ -962,8 +970,8 @@ __strncpy_gg (char *__dest, const char *__src, size_t __n)
/* Append SRC onto DEST. */
-#define _HAVE_STRING_ARCH_strcat 1
-#define strcat(dest, src) \
+# define _HAVE_STRING_ARCH_strcat 1
+# define strcat(dest, src) \
(__extension__ (__builtin_constant_p (src) \
? __strcat_c ((dest), (src), strlen (src) + 1) \
: __strcat_g ((dest), (src))))
@@ -974,7 +982,7 @@ __STRING_INLINE char *__strcat_c (char *__dest, const char __src[],
__STRING_INLINE char *
__strcat_c (char *__dest, const char __src[], size_t __srclen)
{
-#ifdef __i686__
+# ifdef __i686__
register unsigned long int __d0;
register char *__tmp;
__asm__ __volatile__
@@ -985,7 +993,7 @@ __strcat_c (char *__dest, const char __src[], size_t __srclen)
"m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
: "cc");
--__tmp;
-#else
+# else
register char *__tmp = __dest - 1;
__asm__ __volatile__
("1:\n\t"
@@ -997,7 +1005,7 @@ __strcat_c (char *__dest, const char __src[], size_t __srclen)
: "0" (__tmp),
"m" ( *(struct { __extension__ char __x[__srclen]; } *)__src)
: "cc");
-#endif
+# endif
(void) memcpy (__tmp, __src, __srclen);
return __dest;
}
@@ -1031,8 +1039,8 @@ __strcat_g (char *__dest, const char *__src)
/* Append no more than N characters from SRC onto DEST. */
-#define _HAVE_STRING_ARCH_strncat 1
-#define strncat(dest, src, n) \
+# define _HAVE_STRING_ARCH_strncat 1
+# define strncat(dest, src, n) \
(__extension__ ({ char *__dest = (dest); \
__builtin_constant_p (src) && __builtin_constant_p (n) \
? (strlen (src) < ((size_t) (n)) \
@@ -1050,7 +1058,7 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
{
register char *__tmp = __dest;
register char __dummy;
-#ifdef __i686__
+# ifdef __i686__
__asm__ __volatile__
("repne; scasb\n"
"movl %4, %3\n\t"
@@ -1068,7 +1076,7 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
: "=&a" (__dummy), "=&D" (__tmp), "=&S" (__src), "=&c" (__n)
: "g" (__n), "0" (0), "1" (__tmp), "2" (__src), "3" (0xffffffff)
: "memory", "cc");
-#else
+# else
--__tmp;
__asm__ __volatile__
("1:\n\t"
@@ -1096,8 +1104,8 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
/* Compare S1 and S2. */
-#define _HAVE_STRING_ARCH_strcmp 1
-#define strcmp(s1, s2) \
+# define _HAVE_STRING_ARCH_strcmp 1
+# define strcmp(s1, s2) \
(__extension__ (__builtin_constant_p (s1) && __builtin_constant_p (s2) \
&& (sizeof ((s1)[0]) != 1 || strlen (s1) >= 4) \
&& (sizeof ((s2)[0]) != 1 || strlen (s2) >= 4) \
@@ -1124,7 +1132,7 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
strlen (s2))) \
: __strcmp_gg ((s1), (s2))))))
-#define __strcmp_cc(s1, s2, l) \
+# define __strcmp_cc(s1, s2, l) \
(__extension__ ({ register int __result = (s1)[0] - (s2)[0]; \
if (l > 0 && __result == 0) \
{ \
@@ -1138,7 +1146,7 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
} \
__result; }))
-#define __strcmp_cg(s1, s2, l1) \
+# define __strcmp_cg(s1, s2, l1) \
(__extension__ ({ const unsigned char *__s2 = (s2); \
register int __result = (s1)[0] - __s2[0]; \
if (l1 > 0 && __result == 0) \
@@ -1153,7 +1161,7 @@ __strncat_g (char *__dest, const char __src[], size_t __n)
} \
__result; }))
-#define __strcmp_gc(s1, s2, l2) \
+# define __strcmp_gc(s1, s2, l2) \
(__extension__ ({ const unsigned char *__s1 = (s1); \
register int __result = __s1[0] - (s2)[0]; \
if (l2 > 0 && __result == 0) \
@@ -1200,8 +1208,8 @@ __strcmp_gg (const char *__s1, const char *__s2)
/* Compare N characters of S1 and S2. */
-#define _HAVE_STRING_ARCH_strncmp 1
-#define strncmp(s1, s2, n) \
+# define _HAVE_STRING_ARCH_strncmp 1
+# define strncmp(s1, s2, n) \
(__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n)) \
? strcmp ((s1), (s2)) \
: (__builtin_constant_p (s2) && strlen (s2) < ((size_t) (n))\
@@ -1244,9 +1252,9 @@ __strncmp_g (const char *__s1, const char *__s2, size_t __n)
/* Find the first occurrence of C in S. */
-#define _HAVE_STRING_ARCH_strchr 1
-#define _USE_STRING_ARCH_strchr 1
-#define strchr(s, c) \
+# define _HAVE_STRING_ARCH_strchr 1
+# define _USE_STRING_ARCH_strchr 1
+# define strchr(s, c) \
(__extension__ (__builtin_constant_p (c) \
? ((c) == '\0' \
? (char *) __rawmemchr ((s), (c)) \
@@ -1304,8 +1312,8 @@ __strchr_g (const char *__s, int __c)
/* Find the first occurrence of C in S or the final NUL byte. */
-#define _HAVE_STRING_ARCH_strchrnul 1
-#define __strchrnul(s, c) \
+# define _HAVE_STRING_ARCH_strchrnul 1
+# define __strchrnul(s, c) \
(__extension__ (__builtin_constant_p (c) \
? ((c) == '\0' \
? (char *) __rawmemchr ((s), c) \
@@ -1360,29 +1368,29 @@ __strchrnul_g (const char *__s, int __c)
: "cc");
return __res;
}
-#ifdef __USE_GNU
-# define strchrnul(s, c) __strchrnul ((s), (c))
-#endif
+# ifdef __USE_GNU
+# define strchrnul(s, c) __strchrnul ((s), (c))
+# endif
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+# if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Find the first occurrence of C in S. This is the BSD name. */
-# define _HAVE_STRING_ARCH_index 1
-# define index(s, c) \
+# define _HAVE_STRING_ARCH_index 1
+# define index(s, c) \
(__extension__ (__builtin_constant_p (c) \
? __strchr_c ((s), ((c) & 0xff) << 8) \
: __strchr_g ((s), (c))))
-#endif
+# endif
/* Find the last occurrence of C in S. */
-#define _HAVE_STRING_ARCH_strrchr 1
-#define strrchr(s, c) \
+# define _HAVE_STRING_ARCH_strrchr 1
+# define strrchr(s, c) \
(__extension__ (__builtin_constant_p (c) \
? __strrchr_c ((s), ((c) & 0xff) << 8) \
: __strrchr_g ((s), (c))))
-#ifdef __i686__
+# ifdef __i686__
__STRING_INLINE char *__strrchr_c (const char *__s, int __c);
__STRING_INLINE char *
@@ -1427,7 +1435,7 @@ __strrchr_g (const char *__s, int __c)
: "cc");
return __res - 1;
}
-#else
+# else
__STRING_INLINE char *__strrchr_c (const char *__s, int __c);
__STRING_INLINE char *
@@ -1476,23 +1484,23 @@ __strrchr_g (const char *__s, int __c)
: "cc");
return __res;
}
-#endif
+# endif
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+# if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Find the last occurrence of C in S. This is the BSD name. */
-# define _HAVE_STRING_ARCH_rindex 1
-# define rindex(s, c) \
+# define _HAVE_STRING_ARCH_rindex 1
+# define rindex(s, c) \
(__extension__ (__builtin_constant_p (c) \
? __strrchr_c ((s), ((c) & 0xff) << 8) \
: __strrchr_g ((s), (c))))
-#endif
+# endif
/* Return the length of the initial segment of S which
consists entirely of characters not in REJECT. */
-#define _HAVE_STRING_ARCH_strcspn 1
-#define strcspn(s, reject) \
+# define _HAVE_STRING_ARCH_strcspn 1
+# define strcspn(s, reject) \
(__extension__ (__builtin_constant_p (reject) && sizeof ((reject)[0]) == 1 \
? ((reject)[0] == '\0' \
? strlen (s) \
@@ -1503,7 +1511,7 @@ __strrchr_g (const char *__s, int __c)
__STRING_INLINE size_t __strcspn_c1 (const char *__s, int __reject);
-#ifndef _FORCE_INLINES
+# ifndef _FORCE_INLINES
__STRING_INLINE size_t
__strcspn_c1 (const char *__s, int __reject)
{
@@ -1524,7 +1532,7 @@ __strcspn_c1 (const char *__s, int __reject)
: "cc");
return (__res - 1) - __s;
}
-#endif
+# endif
__STRING_INLINE size_t __strcspn_cg (const char *__s, const char __reject[],
size_t __reject_len);
@@ -1552,7 +1560,7 @@ __strcspn_cg (const char *__s, const char __reject[], size_t __reject_len)
}
__STRING_INLINE size_t __strcspn_g (const char *__s, const char *__reject);
-#ifdef __PIC__
+# ifdef __PIC__
__STRING_INLINE size_t
__strcspn_g (const char *__s, const char *__reject)
@@ -1581,7 +1589,7 @@ __strcspn_g (const char *__s, const char *__reject)
: "memory", "cc");
return (__res - 1) - __s;
}
-#else
+# else
__STRING_INLINE size_t
__strcspn_g (const char *__s, const char *__reject)
{
@@ -1607,13 +1615,13 @@ __strcspn_g (const char *__s, const char *__reject)
: "memory", "cc");
return (__res - 1) - __s;
}
-#endif
+# endif
/* Return the length of the initial segment of S which
consists entirely of characters in ACCEPT. */
-#define _HAVE_STRING_ARCH_strspn 1
-#define strspn(s, accept) \
+# define _HAVE_STRING_ARCH_strspn 1
+# define strspn(s, accept) \
(__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1 \
? ((accept)[0] == '\0' \
? ((void) (s), 0) \
@@ -1622,7 +1630,7 @@ __strcspn_g (const char *__s, const char *__reject)
: __strspn_cg ((s), (accept), strlen (accept)))) \
: __strspn_g ((s), (accept))))
-#ifndef _FORCE_INLINES
+# ifndef _FORCE_INLINES
__STRING_INLINE size_t __strspn_c1 (const char *__s, int __accept);
__STRING_INLINE size_t
@@ -1643,7 +1651,7 @@ __strspn_c1 (const char *__s, int __accept)
: "cc");
return (__res - 1) - __s;
}
-#endif
+# endif
__STRING_INLINE size_t __strspn_cg (const char *__s, const char __accept[],
size_t __accept_len);
@@ -1675,7 +1683,7 @@ __strspn_cg (const char *__s, const char __accept[], size_t __accept_len)
}
__STRING_INLINE size_t __strspn_g (const char *__s, const char *__accept);
-#ifdef __PIC__
+# ifdef __PIC__
__STRING_INLINE size_t
__strspn_g (const char *__s, const char *__accept)
@@ -1703,7 +1711,7 @@ __strspn_g (const char *__s, const char *__accept)
: "memory", "cc");
return (__res - 1) - __s;
}
-#else
+# else
__STRING_INLINE size_t
__strspn_g (const char *__s, const char *__accept)
{
@@ -1728,12 +1736,12 @@ __strspn_g (const char *__s, const char *__accept)
: "memory", "cc");
return (__res - 1) - __s;
}
-#endif
+# endif
/* Find the first occurrence in S of any character in ACCEPT. */
-#define _HAVE_STRING_ARCH_strpbrk 1
-#define strpbrk(s, accept) \
+# define _HAVE_STRING_ARCH_strpbrk 1
+# define strpbrk(s, accept) \
(__extension__ (__builtin_constant_p (accept) && sizeof ((accept)[0]) == 1 \
? ((accept)[0] == '\0' \
? ((void) (s), (char *) 0) \
@@ -1772,7 +1780,7 @@ __strpbrk_cg (const char *__s, const char __accept[], size_t __accept_len)
}
__STRING_INLINE char *__strpbrk_g (const char *__s, const char *__accept);
-#ifdef __PIC__
+# ifdef __PIC__
__STRING_INLINE char *
__strpbrk_g (const char *__s, const char *__accept)
@@ -1805,7 +1813,7 @@ __strpbrk_g (const char *__s, const char *__accept)
: "memory", "cc");
return __res;
}
-#else
+# else
__STRING_INLINE char *
__strpbrk_g (const char *__s, const char *__accept)
{
@@ -1835,12 +1843,12 @@ __strpbrk_g (const char *__s, const char *__accept)
: "memory", "cc");
return __res;
}
-#endif
+# endif
/* Find the first occurrence of NEEDLE in HAYSTACK. */
-#define _HAVE_STRING_ARCH_strstr 1
-#define strstr(haystack, needle) \
+# define _HAVE_STRING_ARCH_strstr 1
+# define strstr(haystack, needle) \
(__extension__ (__builtin_constant_p (needle) && sizeof ((needle)[0]) == 1 \
? ((needle)[0] == '\0' \
? (haystack) \
@@ -1883,7 +1891,7 @@ __strstr_cg (const char *__haystack, const char __needle[],
__STRING_INLINE char *__strstr_g (const char *__haystack,
const char *__needle);
-#ifdef __PIC__
+# ifdef __PIC__
__STRING_INLINE char *
__strstr_g (const char *__haystack, const char *__needle)
@@ -1915,7 +1923,7 @@ __strstr_g (const char *__haystack, const char *__needle)
: "memory", "cc");
return __res;
}
-#else
+# else
__STRING_INLINE char *
__strstr_g (const char *__haystack, const char *__needle)
{
@@ -1944,32 +1952,34 @@ __strstr_g (const char *__haystack, const char *__needle)
: "memory", "cc");
return __res;
}
-#endif
+# endif
/* Bit find functions. We define only the i686 version since for the other
processors gcc generates good code. */
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
-# ifdef __i686__
-# define _HAVE_STRING_ARCH_ffs 1
-# define ffs(word) (__builtin_constant_p (word) \
- ? __builtin_ffs (word) \
- : ({ int __cnt, __tmp; \
- __asm__ __volatile__ \
- ("bsfl %2,%0\n\t" \
- "cmovel %1,%0" \
- : "=&r" (__cnt), "=r" (__tmp) \
- : "rm" (word), "1" (-1)); \
- __cnt + 1; }))
-
-# ifndef ffsl
-# define ffsl(word) ffs(word)
-# endif
-# endif /* i686 */
-#endif /* BSD || X/Open */
+# if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+# ifdef __i686__
+# define _HAVE_STRING_ARCH_ffs 1
+# define ffs(word) (__builtin_constant_p (word) \
+ ? __builtin_ffs (word) \
+ : ({ int __cnt, __tmp; \
+ __asm__ __volatile__ \
+ ("bsfl %2,%0\n\t" \
+ "cmovel %1,%0" \
+ : "=&r" (__cnt), "=r" (__tmp) \
+ : "rm" (word), "1" (-1)); \
+ __cnt + 1; }))
+
+# ifndef ffsl
+# define ffsl(word) ffs(word)
+# endif
+# endif /* i686 */
+# endif /* BSD || X/Open */
+
+# ifndef _FORCE_INLINES
+# undef __STRING_INLINE
+# endif
-#ifndef _FORCE_INLINES
-# undef __STRING_INLINE
-#endif
+# endif /* use string inlines && GNU CC */
-#endif /* use string inlines && GNU CC */
+#endif
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=fe8a7e8501da54a6f7d9a0ecc964ada488718c0c
commit fe8a7e8501da54a6f7d9a0ecc964ada488718c0c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jun 4 13:33:50 2012 -0700
Use x86_64 fpu/bits/mathinline.h for i386 and x86-64
diff --git a/ChangeLog.pr14117 b/ChangeLog.pr14117
index a46cdb6..8fc5950 100644
--- a/ChangeLog.pr14117
+++ b/ChangeLog.pr14117
@@ -1,5 +1,10 @@
2012-06-04 H.J. Lu <hongjiu.lu@intel.com>
+ [BZ #14117]
+ * sysdeps/i386/fpu/bits/mathinline.h: Removed.
+ * sysdeps/x86_64/fpu/bits/mathinline.h: Renamed to ...
+ * sysdeps/x86/fpu/bits/mathinline.h: This.
+
[BZ #14050]
[BZ #14117]
* sysdeps/i386/fpu/bits/mathinline.h: Merged with ...
diff --git a/sysdeps/i386/fpu/bits/mathinline.h b/sysdeps/i386/fpu/bits/mathinline.h
deleted file mode 100644
index 2a7e96b..0000000
--- a/sysdeps/i386/fpu/bits/mathinline.h
+++ /dev/null
@@ -1,733 +0,0 @@
-/* Inline math functions for i387.
- Copyright (C) 1995-2012 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by John C. Bowman <bowman@math.ualberta.ca>, 1995.
-
- 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, see
- <http://www.gnu.org/licenses/>. */
-
-#ifndef _MATH_H
-# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
-#endif
-
-#ifndef __extern_inline
-# define __MATH_INLINE __inline
-#else
-# define __MATH_INLINE __extern_inline
-#endif
-
-
-#if defined __USE_ISOC99 && defined __GNUC__ && __GNUC__ >= 2
-/* GCC 2.97 and up have builtins that actually can be used. */
-# if !__GNUC_PREREQ (2,97)
-/* ISO C99 defines some macros to perform unordered comparisons. The
- ix87 FPU supports this with special opcodes and we should use them.
- These must not be inline functions since we have to be able to handle
- all floating-point types. */
-# undef isgreater
-# undef isgreaterequal
-# undef isless
-# undef islessequal
-# undef islessgreater
-# undef isunordered
-# ifdef __i686__
-/* For the PentiumPro and more recent processors we can provide
- better code. */
-# define isgreater(x, y) \
- ({ register char __result; \
- __asm__ ("fucomip %%st(1), %%st; seta %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
- __result; })
-# define isgreaterequal(x, y) \
- ({ register char __result; \
- __asm__ ("fucomip %%st(1), %%st; setae %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
- __result; })
-
-# define isless(x, y) \
- ({ register char __result; \
- __asm__ ("fucomip %%st(1), %%st; seta %%al" \
- : "=a" (__result) : "u" (x), "t" (y) : "cc", "st"); \
- __result; })
-
-# define islessequal(x, y) \
- ({ register char __result; \
- __asm__ ("fucomip %%st(1), %%st; setae %%al" \
- : "=a" (__result) : "u" (x), "t" (y) : "cc", "st"); \
- __result; })
-
-# define islessgreater(x, y) \
- ({ register char __result; \
- __asm__ ("fucomip %%st(1), %%st; setne %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
- __result; })
-
-# define isunordered(x, y) \
- ({ register char __result; \
- __asm__ ("fucomip %%st(1), %%st; setp %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
- __result; })
-# else
-/* This is the dumb, portable code for i386 and above. */
-# define isgreater(x, y) \
- ({ register char __result; \
- __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
- __result; })
-
-# define isgreaterequal(x, y) \
- ({ register char __result; \
- __asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
- __result; })
-
-# define isless(x, y) \
- ({ register char __result; \
- __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \
- : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \
- __result; })
-
-# define islessequal(x, y) \
- ({ register char __result; \
- __asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al" \
- : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \
- __result; })
-
-# define islessgreater(x, y) \
- ({ register char __result; \
- __asm__ ("fucompp; fnstsw; testb $0x44, %%ah; setz %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
- __result; })
-
-# define isunordered(x, y) \
- ({ register char __result; \
- __asm__ ("fucompp; fnstsw; sahf; setp %%al" \
- : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
- __result; })
-# endif /* __i686__ */
-# endif /* GCC 2.97 */
-
-/* The gcc, version 2.7 or below, has problems with all this inlining
- code. So disable it for this version of the compiler. */
-# if __GNUC_PREREQ (2, 8)
-/* Test for negative number. Used in the signbit() macro. */
-__MATH_INLINE int
-__NTH (__signbitf (float __x))
-{
- __extension__ union { float __f; int __i; } __u = { __f: __x };
- return __u.__i < 0;
-}
-__MATH_INLINE int
-__NTH (__signbit (double __x))
-{
- __extension__ union { double __d; int __i[2]; } __u = { __d: __x };
- return __u.__i[1] < 0;
-}
-__MATH_INLINE int
-__NTH (__signbitl (long double __x))
-{
- __extension__ union { long double __l; int __i[3]; } __u = { __l: __x };
- return (__u.__i[2] & 0x8000) != 0;
-}
-# endif
-#endif
-
-
-/* The gcc, version 2.7 or below, has problems with all this inlining
- code. So disable it for this version of the compiler. */
-#if __GNUC_PREREQ (2, 8)
-
-#if ((!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) \
- && defined __OPTIMIZE__)
-
-/* The inline functions do not set errno or raise necessarily the
- correct exceptions. */
-# undef math_errhandling
-
-/* A macro to define float, double, and long double versions of various
- math functions for the ix87 FPU. FUNC is the function name (which will
- be suffixed with f and l for the float and long double version,
- respectively). OP is the name of the FPU operation.
- We define two sets of macros. The set with the additional NP
- doesn't add a prototype declaration. */
-
-#if defined __USE_MISC || defined __USE_ISOC99
-# define __inline_mathop(func, op) \
- __inline_mathop_ (double, func, op) \
- __inline_mathop_ (float, __CONCAT(func,f), op) \
- __inline_mathop_ (long double, __CONCAT(func,l), op)
-# define __inline_mathopNP(func, op) \
- __inline_mathopNP_ (double, func, op) \
- __inline_mathopNP_ (float, __CONCAT(func,f), op) \
- __inline_mathopNP_ (long double, __CONCAT(func,l), op)
-#else
-# define __inline_mathop(func, op) \
- __inline_mathop_ (double, func, op)
-# define __inline_mathopNP(func, op) \
- __inline_mathopNP_ (double, func, op)
-#endif
-
-#define __inline_mathop_(float_type, func, op) \
- __inline_mathop_decl_ (float_type, func, op, "0" (__x))
-#define __inline_mathopNP_(float_type, func, op) \
- __inline_mathop_declNP_ (float_type, func, op, "0" (__x))
-
-
-#if defined __USE_MISC || defined __USE_ISOC99
-# define __inline_mathop_decl(func, op, params...) \
- __inline_mathop_decl_ (double, func, op, params) \
- __inline_mathop_decl_ (float, __CONCAT(func,f), op, params) \
- __inline_mathop_decl_ (long double, __CONCAT(func,l), op, params)
-# define __inline_mathop_declNP(func, op, params...) \
- __inline_mathop_declNP_ (double, func, op, params) \
- __inline_mathop_declNP_ (float, __CONCAT(func,f), op, params) \
- __inline_mathop_declNP_ (long double, __CONCAT(func,l), op, params)
-#else
-# define __inline_mathop_decl(func, op, params...) \
- __inline_mathop_decl_ (double, func, op, params)
-# define __inline_mathop_declNP(func, op, params...) \
- __inline_mathop_declNP_ (double, func, op, params)
-#endif
-
-#define __inline_mathop_decl_(float_type, func, op, params...) \
- __MATH_INLINE float_type func (float_type) __THROW; \
- __inline_mathop_declNP_ (float_type, func, op, params)
-
-#define __inline_mathop_declNP_(float_type, func, op, params...) \
- __MATH_INLINE float_type __NTH (func (float_type __x)) \
- { \
- register float_type __result; \
- __asm __volatile__ (op : "=t" (__result) : params); \
- return __result; \
- }
-
-
-#if defined __USE_MISC || defined __USE_ISOC99
-# define __inline_mathcode(func, arg, code) \
- __inline_mathcode_ (double, func, arg, code) \
- __inline_mathcode_ (float, __CONCAT(func,f), arg, code) \
- __inline_mathcode_ (long double, __CONCAT(func,l), arg, code)
-# define __inline_mathcodeNP(func, arg, code) \
- __inline_mathcodeNP_ (double, func, arg, code) \
- __inline_mathcodeNP_ (float, __CONCAT(func,f), arg, code) \
- __inline_mathcodeNP_ (long double, __CONCAT(func,l), arg, code)
-# define __inline_mathcode2(func, arg1, arg2, code) \
- __inline_mathcode2_ (double, func, arg1, arg2, code) \
- __inline_mathcode2_ (float, __CONCAT(func,f), arg1, arg2, code) \
- __inline_mathcode2_ (long double, __CONCAT(func,l), arg1, arg2, code)
-# define __inline_mathcodeNP2(func, arg1, arg2, code) \
- __inline_mathcodeNP2_ (double, func, arg1, arg2, code) \
- __inline_mathcodeNP2_ (float, __CONCAT(func,f), arg1, arg2, code) \
- __inline_mathcodeNP2_ (long double, __CONCAT(func,l), arg1, arg2, code)
-# define __inline_mathcode3(func, arg1, arg2, arg3, code) \
- __inline_mathcode3_ (double, func, arg1, arg2, arg3, code) \
- __inline_mathcode3_ (float, __CONCAT(func,f), arg1, arg2, arg3, code) \
- __inline_mathcode3_ (long double, __CONCAT(func,l), arg1, arg2, arg3, code)
-# define __inline_mathcodeNP3(func, arg1, arg2, arg3, code) \
- __inline_mathcodeNP3_ (double, func, arg1, arg2, arg3, code) \
- __inline_mathcodeNP3_ (float, __CONCAT(func,f), arg1, arg2, arg3, code) \
- __inline_mathcodeNP3_ (long double, __CONCAT(func,l), arg1, arg2, arg3, code)
-#else
-# define __inline_mathcode(func, arg, code) \
- __inline_mathcode_ (double, func, (arg), code)
-# define __inline_mathcodeNP(func, arg, code) \
- __inline_mathcodeNP_ (double, func, (arg), code)
-# define __inline_mathcode2(func, arg1, arg2, code) \
- __inline_mathcode2_ (double, func, arg1, arg2, code)
-# define __inline_mathcodeNP2(func, arg1, arg2, code) \
- __inline_mathcodeNP2_ (double, func, arg1, arg2, code)
-# define __inline_mathcode3(func, arg1, arg2, arg3, code) \
- __inline_mathcode3_ (double, func, arg1, arg2, arg3, code)
-# define __inline_mathcodeNP3(func, arg1, arg2, arg3, code) \
- __inline_mathcodeNP3_ (double, func, arg1, arg2, arg3, code)
-#endif
-
-#define __inline_mathcode_(float_type, func, arg, code) \
- __MATH_INLINE float_type func (float_type) __THROW; \
- __inline_mathcodeNP_(float_type, func, arg, code)
-
-#define __inline_mathcodeNP_(float_type, func, arg, code) \
- __MATH_INLINE float_type __NTH (func (float_type arg)) \
- { \
- code; \
- }
-
-
-#define __inline_mathcode2_(float_type, func, arg1, arg2, code) \
- __MATH_INLINE float_type func (float_type, float_type) __THROW; \
- __inline_mathcodeNP2_ (float_type, func, arg1, arg2, code)
-
-#define __inline_mathcodeNP2_(float_type, func, arg1, arg2, code) \
- __MATH_INLINE float_type __NTH (func (float_type arg1, float_type arg2)) \
- { \
- code; \
- }
-
-#define __inline_mathcode3_(float_type, func, arg1, arg2, arg3, code) \
- __MATH_INLINE float_type func (float_type, float_type, float_type) __THROW; \
- __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code)
-
-#define __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code) \
- __MATH_INLINE float_type __NTH (func (float_type arg1, float_type arg2, \
- float_type arg3)) \
- { \
- code; \
- }
-#endif
-
-
-#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
-/* Miscellaneous functions */
-
-/* __FAST_MATH__ is defined by gcc -ffast-math. */
-#ifdef __FAST_MATH__
-# ifdef __USE_GNU
-# define __sincos_code \
- register long double __cosr; \
- register long double __sinr; \
- register unsigned int __swtmp; \
- __asm __volatile__ \
- ("fsincos\n\t" \
- "fnstsw %w2\n\t" \
- "testl $0x400, %2\n\t" \
- "jz 1f\n\t" \
- "fldpi\n\t" \
- "fadd %%st(0)\n\t" \
- "fxch %%st(1)\n\t" \
- "2: fprem1\n\t" \
- "fnstsw %w2\n\t" \
- "testl $0x400, %2\n\t" \
- "jnz 2b\n\t" \
- "fstp %%st(1)\n\t" \
- "fsincos\n\t" \
- "1:" \
- : "=t" (__cosr), "=u" (__sinr), "=a" (__swtmp) : "0" (__x)); \
- *__sinx = __sinr; \
- *__cosx = __cosr
-
-__MATH_INLINE void
-__NTH (__sincos (double __x, double *__sinx, double *__cosx))
-{
- __sincos_code;
-}
-
-__MATH_INLINE void
-__NTH (__sincosf (float __x, float *__sinx, float *__cosx))
-{
- __sincos_code;
-}
-
-__MATH_INLINE void
-__NTH (__sincosl (long double __x, long double *__sinx, long double *__cosx))
-{
- __sincos_code;
-}
-# endif
-
-
-/* Optimized inline implementation, sometimes with reduced precision
- and/or argument range. */
-
-# if __GNUC_PREREQ (3, 5)
-# define __expm1_code \
- register long double __temp; \
- __temp = __builtin_expm1l (__x); \
- return __temp ? __temp : __x
-# else
-# define __expm1_code \
- register long double __value; \
- register long double __exponent; \
- register long double __temp; \
- __asm __volatile__ \
- ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" \
- "fmul %%st(1) # x * log2(e)\n\t" \
- "fst %%st(1)\n\t" \
- "frndint # int(x * log2(e))\n\t" \
- "fxch\n\t" \
- "fsub %%st(1) # fract(x * log2(e))\n\t" \
- "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" \
- "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" \
- : "=t" (__value), "=u" (__exponent) : "0" (__x)); \
- __asm __volatile__ \
- ("fscale # 2^int(x * log2(e))\n\t" \
- : "=t" (__temp) : "0" (1.0), "u" (__exponent)); \
- __temp -= 1.0; \
- __temp += __value; \
- return __temp ? __temp : __x
-# endif
-__inline_mathcodeNP_ (long double, __expm1l, __x, __expm1_code)
-
-# if __GNUC_PREREQ (3, 4)
-__inline_mathcodeNP_ (long double, __expl, __x, return __builtin_expl (__x))
-# else
-# define __exp_code \
- register long double __value; \
- register long double __exponent; \
- __asm __volatile__ \
- ("fldl2e # e^x = 2^(x * log2(e))\n\t" \
- "fmul %%st(1) # x * log2(e)\n\t" \
- "fst %%st(1)\n\t" \
- "frndint # int(x * log2(e))\n\t" \
- "fxch\n\t" \
- "fsub %%st(1) # fract(x * log2(e))\n\t" \
- "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" \
- : "=t" (__value), "=u" (__exponent) : "0" (__x)); \
- __value += 1.0; \
- __asm __volatile__ \
- ("fscale" \
- : "=t" (__value) : "0" (__value), "u" (__exponent)); \
- return __value
-__inline_mathcodeNP (exp, __x, __exp_code)
-__inline_mathcodeNP_ (long double, __expl, __x, __exp_code)
-# endif
-
-
-# if !__GNUC_PREREQ (3, 5)
-__inline_mathcodeNP (tan, __x, \
- register long double __value; \
- register long double __value2 __attribute__ ((__unused__)); \
- __asm __volatile__ \
- ("fptan" \
- : "=t" (__value2), "=u" (__value) : "0" (__x)); \
- return __value)
-# endif
-#endif /* __FAST_MATH__ */
-
-
-#if __GNUC_PREREQ (3, 4)
-__inline_mathcodeNP2_ (long double, __atan2l, __y, __x,
- return __builtin_atan2l (__y, __x))
-#else
-# define __atan2_code \
- register long double __value; \
- __asm __volatile__ \
- ("fpatan" \
- : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); \
- return __value
-# ifdef __FAST_MATH__
-__inline_mathcodeNP2 (atan2, __y, __x, __atan2_code)
-# endif
-__inline_mathcodeNP2_ (long double, __atan2l, __y, __x, __atan2_code)
-#endif
-
-
-#if defined __FAST_MATH__ && !__GNUC_PREREQ (3, 5)
-__inline_mathcodeNP2 (fmod, __x, __y, \
- register long double __value; \
- __asm __volatile__ \
- ("1: fprem\n\t" \
- "fnstsw %%ax\n\t" \
- "sahf\n\t" \
- "jp 1b" \
- : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); \
- return __value)
-#endif
-
-
-#ifdef __FAST_MATH__
-# if !__GNUC_PREREQ (3,3)
-__inline_mathopNP (sqrt, "fsqrt")
-__inline_mathopNP_ (long double, __sqrtl, "fsqrt")
-# define __libc_sqrtl(n) __sqrtl (n)
-# else
-# define __libc_sqrtl(n) __builtin_sqrtl (n)
-# endif
-#endif
-
-#if __GNUC_PREREQ (2, 8)
-__inline_mathcodeNP_ (double, fabs, __x, return __builtin_fabs (__x))
-# if defined __USE_MISC || defined __USE_ISOC99
-__inline_mathcodeNP_ (float, fabsf, __x, return __builtin_fabsf (__x))
-__inline_mathcodeNP_ (long double, fabsl, __x, return __builtin_fabsl (__x))
-# endif
-__inline_mathcodeNP_ (long double, __fabsl, __x, return __builtin_fabsl (__x))
-#else
-__inline_mathop (fabs, "fabs")
-__inline_mathop_ (long double, __fabsl, "fabs")
-#endif
-
-#ifdef __FAST_MATH__
-# if !__GNUC_PREREQ (3, 4)
-/* The argument range of this inline version is reduced. */
-__inline_mathopNP (sin, "fsin")
-/* The argument range of this inline version is reduced. */
-__inline_mathopNP (cos, "fcos")
-
-__inline_mathop_declNP (log, "fldln2; fxch; fyl2x", "0" (__x) : "st(1)")
-# endif
-
-# if !__GNUC_PREREQ (3, 5)
-__inline_mathop_declNP (log10, "fldlg2; fxch; fyl2x", "0" (__x) : "st(1)")
-
-__inline_mathcodeNP (asin, __x, return __atan2l (__x, __libc_sqrtl (1.0 - __x * __x)))
-__inline_mathcodeNP (acos, __x, return __atan2l (__libc_sqrtl (1.0 - __x * __x), __x))
-# endif
-
-# if !__GNUC_PREREQ (3, 4)
-__inline_mathop_declNP (atan, "fld1; fpatan", "0" (__x) : "st(1)")
-# endif
-#endif /* __FAST_MATH__ */
-
-__inline_mathcode_ (long double, __sgn1l, __x, \
- __extension__ union { long double __xld; unsigned int __xi[3]; } __n = \
- { __xld: __x }; \
- __n.__xi[2] = (__n.__xi[2] & 0x8000) | 0x3fff; \
- __n.__xi[1] = 0x80000000; \
- __n.__xi[0] = 0; \
- return __n.__xld)
-
-
-#ifdef __FAST_MATH__
-/* The argument range of the inline version of sinhl is slightly reduced. */
-__inline_mathcodeNP (sinh, __x, \
- register long double __exm1 = __expm1l (__fabsl (__x)); \
- return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x))
-
-__inline_mathcodeNP (cosh, __x, \
- register long double __ex = __expl (__x); \
- return 0.5 * (__ex + 1.0 / __ex))
-
-__inline_mathcodeNP (tanh, __x, \
- register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \
- return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x))
-#endif
-
-__inline_mathcodeNP (floor, __x, \
- register long double __value; \
- register int __ignore; \
- unsigned short int __cw; \
- unsigned short int __cwtmp; \
- __asm __volatile ("fnstcw %3\n\t" \
- "movzwl %3, %1\n\t" \
- "andl $0xf3ff, %1\n\t" \
- "orl $0x0400, %1\n\t" /* rounding down */ \
- "movw %w1, %2\n\t" \
- "fldcw %2\n\t" \
- "frndint\n\t" \
- "fldcw %3" \
- : "=t" (__value), "=&q" (__ignore), "=m" (__cwtmp), \
- "=m" (__cw) \
- : "0" (__x)); \
- return __value)
-
-__inline_mathcodeNP (ceil, __x, \
- register long double __value; \
- register int __ignore; \
- unsigned short int __cw; \
- unsigned short int __cwtmp; \
- __asm __volatile ("fnstcw %3\n\t" \
- "movzwl %3, %1\n\t" \
- "andl $0xf3ff, %1\n\t" \
- "orl $0x0800, %1\n\t" /* rounding up */ \
- "movw %w1, %2\n\t" \
- "fldcw %2\n\t" \
- "frndint\n\t" \
- "fldcw %3" \
- : "=t" (__value), "=&q" (__ignore), "=m" (__cwtmp), \
- "=m" (__cw) \
- : "0" (__x)); \
- return __value)
-
-#ifdef __FAST_MATH__
-# define __ldexp_code \
- register long double __value; \
- __asm __volatile__ \
- ("fscale" \
- : "=t" (__value) : "0" (__x), "u" ((long double) __y)); \
- return __value
-
-__MATH_INLINE double
-__NTH (ldexp (double __x, int __y))
-{
- __ldexp_code;
-}
-#endif
-
-
-/* Optimized versions for some non-standardized functions. */
-#if defined __USE_ISOC99 || defined __USE_MISC
-
-# ifdef __FAST_MATH__
-__inline_mathcodeNP (expm1, __x, __expm1_code)
-
-/* We cannot rely on M_SQRT being defined. So we do it for ourself
- here. */
-# define __M_SQRT2 1.41421356237309504880L /* sqrt(2) */
-
-# if !__GNUC_PREREQ (3, 5)
-__inline_mathcodeNP (log1p, __x, \
- register long double __value; \
- if (__fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \
- __value = logl (1.0 + __x); \
- else \
- __asm __volatile__ \
- ("fldln2\n\t" \
- "fxch\n\t" \
- "fyl2xp1" \
- : "=t" (__value) : "0" (__x) : "st(1)"); \
- return __value)
-# endif
-
-
-/* The argument range of the inline version of asinhl is slightly reduced. */
-__inline_mathcodeNP (asinh, __x, \
- register long double __y = __fabsl (__x); \
- return (log1pl (__y * __y / (__libc_sqrtl (__y * __y + 1.0) + 1.0) + __y) \
- * __sgn1l (__x)))
-
-__inline_mathcodeNP (acosh, __x, \
- return logl (__x + __libc_sqrtl (__x - 1.0) * __libc_sqrtl (__x + 1.0)))
-
-__inline_mathcodeNP (atanh, __x, \
- register long double __y = __fabsl (__x); \
- return -0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * __sgn1l (__x))
-
-/* The argument range of the inline version of hypotl is slightly reduced. */
-__inline_mathcodeNP2 (hypot, __x, __y,
- return __libc_sqrtl (__x * __x + __y * __y))
-
-# if !__GNUC_PREREQ (3, 5)
-__inline_mathcodeNP(logb, __x, \
- register long double __value; \
- register long double __junk; \
- __asm __volatile__ \
- ("fxtract\n\t" \
- : "=t" (__junk), "=u" (__value) : "0" (__x)); \
- return __value)
-# endif
-
-# endif
-#endif
-
-#ifdef __USE_ISOC99
-# ifdef __FAST_MATH__
-
-# if !__GNUC_PREREQ (3, 5)
-__inline_mathop_declNP (log2, "fld1; fxch; fyl2x", "0" (__x) : "st(1)")
-# endif
-
-__MATH_INLINE float
-__NTH (ldexpf (float __x, int __y))
-{
- __ldexp_code;
-}
-
-__MATH_INLINE long double
-__NTH (ldexpl (long double __x, int __y))
-{
- __ldexp_code;
-}
-
-__inline_mathopNP (rint, "frndint")
-# endif /* __FAST_MATH__ */
-
-# define __lrint_code \
- long int __lrintres; \
- __asm__ __volatile__ \
- ("fistpl %0" \
- : "=m" (__lrintres) : "t" (__x) : "st"); \
- return __lrintres
-__MATH_INLINE long int
-__NTH (lrintf (float __x))
-{
- __lrint_code;
-}
-__MATH_INLINE long int
-__NTH (lrint (double __x))
-{
- __lrint_code;
-}
-__MATH_INLINE long int
-__NTH (lrintl (long double __x))
-{
- __lrint_code;
-}
-# undef __lrint_code
-
-# define __llrint_code \
- long long int __llrintres; \
- __asm__ __volatile__ \
- ("fistpll %0" \
- : "=m" (__llrintres) : "t" (__x) : "st"); \
- return __llrintres
-__MATH_INLINE long long int
-__NTH (llrintf (float __x))
-{
- __llrint_code;
-}
-__MATH_INLINE long long int
-__NTH (llrint (double __x))
-{
- __llrint_code;
-}
-__MATH_INLINE long long int
-__NTH (llrintl (long double __x))
-{
- __llrint_code;
-}
-# undef __llrint_code
-
-#endif
-
-
-#ifdef __USE_MISC
-
-# if defined __FAST_MATH__ && !__GNUC_PREREQ (3, 5)
-__inline_mathcodeNP2 (drem, __x, __y, \
- register double __value; \
- register int __clobbered; \
- __asm __volatile__ \
- ("1: fprem1\n\t" \
- "fstsw %%ax\n\t" \
- "sahf\n\t" \
- "jp 1b" \
- : "=t" (__value), "=&a" (__clobbered) : "0" (__x), "u" (__y) : "cc"); \
- return __value)
-# endif
-
-
-/* This function is used in the `isfinite' macro. */
-__MATH_INLINE int
-__NTH (__finite (double __x))
-{
- return (__extension__
- (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]
- | 0x800fffffu) + 1) >> 31));
-}
-
-#endif /* __USE_MISC */
-
-/* Undefine some of the large macros which are not used anymore. */
-#undef __atan2_code
-#ifdef __FAST_MATH__
-# undef __expm1_code
-# undef __exp_code
-# undef __sincos_code
-#endif /* __FAST_MATH__ */
-
-#endif /* __NO_MATH_INLINES */
-
-
-/* This code is used internally in the GNU libc. */
-#ifdef __LIBC_INTERNAL_MATH_INLINES
-__inline_mathop (__ieee754_sqrt, "fsqrt")
-__inline_mathcode2 (__ieee754_atan2, __y, __x,
- register long double __value;
- __asm __volatile__ ("fpatan\n\t"
- : "=t" (__value)
- : "0" (__x), "u" (__y) : "st(1)");
- return __value;)
-#endif
-
-#endif /* __GNUC__ */
diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86/fpu/bits/mathinline.h
similarity index 100%
rename from sysdeps/x86_64/fpu/bits/mathinline.h
rename to sysdeps/x86/fpu/bits/mathinline.h
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=0e9bc2239a9f44f90e38d6e06c10a553f11fbfd1
commit 0e9bc2239a9f44f90e38d6e06c10a553f11fbfd1
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jun 4 13:32:51 2012 -0700
Merge i386 bits/mathinline.h with x86_64
diff --git a/ChangeLog.pr14117 b/ChangeLog.pr14117
index 5a12cb3..a46cdb6 100644
--- a/ChangeLog.pr14117
+++ b/ChangeLog.pr14117
@@ -1,5 +1,10 @@
2012-06-04 H.J. Lu <hongjiu.lu@intel.com>
+ [BZ #14050]
+ [BZ #14117]
+ * sysdeps/i386/fpu/bits/mathinline.h: Merged with ...
+ * sysdeps/x86_64/fpu/bits/mathinline.h: This.
+
[BZ #14117]
* sysdeps/i386/fpu/bits/fenv.h: Removed.
* sysdeps/i386/fpu/Implies: New file.
diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
index 7cfe688..7919d1e 100644
--- a/sysdeps/x86_64/fpu/bits/mathinline.h
+++ b/sysdeps/x86_64/fpu/bits/mathinline.h
@@ -1,5 +1,5 @@
-/* Inline math functions for x86-64.
- Copyright (C) 2002-2012 Free Software Foundation, Inc.
+/* Inline math functions for i387 and SSE.
+ Copyright (C) 1995-2012 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
@@ -27,35 +27,125 @@
#endif
+#if defined __USE_ISOC99 && defined __GNUC__ && __GNUC__ >= 2
+/* GCC 2.97 and up have builtins that actually can be used. */
+# if !__GNUC_PREREQ (2,97)
+/* ISO C99 defines some macros to perform unordered comparisons. The
+ ix87 FPU supports this with special opcodes and we should use them.
+ These must not be inline functions since we have to be able to handle
+ all floating-point types. */
+# undef isgreater
+# undef isgreaterequal
+# undef isless
+# undef islessequal
+# undef islessgreater
+# undef isunordered
+# ifdef __i686__
+/* For the PentiumPro and more recent processors we can provide
+ better code. */
+# define isgreater(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucomip %%st(1), %%st; seta %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
+ __result; })
+# define isgreaterequal(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucomip %%st(1), %%st; setae %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
+ __result; })
+
+# define isless(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucomip %%st(1), %%st; seta %%al" \
+ : "=a" (__result) : "u" (x), "t" (y) : "cc", "st"); \
+ __result; })
+
+# define islessequal(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucomip %%st(1), %%st; setae %%al" \
+ : "=a" (__result) : "u" (x), "t" (y) : "cc", "st"); \
+ __result; })
+
+# define islessgreater(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucomip %%st(1), %%st; setne %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
+ __result; })
+
+# define isunordered(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucomip %%st(1), %%st; setp %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \
+ __result; })
+# else
+/* This is the dumb, portable code for i386 and above. */
+# define isgreater(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
+ __result; })
+
+# define isgreaterequal(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
+ __result; })
+
+# define isless(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \
+ : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \
+ __result; })
+
+# define islessequal(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al" \
+ : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \
+ __result; })
+
+# define islessgreater(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucompp; fnstsw; testb $0x44, %%ah; setz %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
+ __result; })
+
+# define isunordered(x, y) \
+ ({ register char __result; \
+ __asm__ ("fucompp; fnstsw; sahf; setp %%al" \
+ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
+ __result; })
+# endif /* __i686__ */
+# endif /* GCC 2.97 */
+
/* The gcc, version 2.7 or below, has problems with all this inlining
code. So disable it for this version of the compiler. */
-#if __GNUC_PREREQ (2, 8) && defined __USE_ISOC99
+# if __GNUC_PREREQ (2, 8) && defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Test for negative number. Used in the signbit() macro. */
__MATH_INLINE int
__NTH (__signbitf (float __x))
{
-# ifndef __x86_64__
+# ifndef __x86_64__
__extension__ union { float __f; int __i; } __u = { __f: __x };
return __u.__i < 0;
-# else
+# else
int __m;
__asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
return __m & 0x8;
-# endif
+# endif
}
__MATH_INLINE int
__NTH (__signbit (double __x))
{
-# ifndef __x86_64__
+# ifndef __x86_64__
__extension__ union { double __d; int __i[2]; } __u = { __d: __x };
return __u.__i[1] < 0;
-# else
+# else
int __m;
__asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
return __m & 0x80;
-# endif
+# endif
}
__MATH_INLINE int
__NTH (__signbitl (long double __x))
@@ -65,19 +155,23 @@ __NTH (__signbitl (long double __x))
}
__END_NAMESPACE_C99
+# endif
#endif
-#if __GNUC_PREREQ (2, 8) && !__GNUC_PREREQ (3, 4) \
- && !defined __NO_MATH_INLINES && defined __OPTIMIZE__
+/* The gcc, version 2.7 or below, has problems with all this inlining
+ code. So disable it for this version of the compiler. */
+#if __GNUC_PREREQ (2, 8)
+# if !__GNUC_PREREQ (3, 4) && !defined __NO_MATH_INLINES \
+ && defined __OPTIMIZE__
/* GCC 3.4 introduced builtins for all functions below, so
there's no need to define any of these inline functions. */
-# ifdef __USE_ISOC99
+# ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Round to nearest integer. */
-# ifdef __SSE_MATH__
+# ifdef __SSE_MATH__
__MATH_INLINE long int
__NTH (lrintf (float __x))
{
@@ -89,8 +183,8 @@ __NTH (lrintf (float __x))
__asm __volatile__ ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
return __res;
}
-# endif
-# ifdef __SSE2_MATH__
+# endif
+# ifdef __SSE2_MATH__
__MATH_INLINE long int
__NTH (lrint (double __x))
{
@@ -102,8 +196,8 @@ __NTH (lrint (double __x))
__asm __volatile__ ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
return __res;
}
-# endif
-# ifdef __x86_64__
+# endif
+# ifdef __x86_64__
__MATH_INLINE long long int
__NTH (llrintf (float __x))
{
@@ -126,68 +220,68 @@ __NTH (llrint (double __x))
__asm __volatile__ ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
return __res;
}
-# endif
+# endif
-# if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0 \
- && defined __SSE2_MATH__
+# if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0 \
+ && defined __SSE2_MATH__
/* Determine maximum of two values. */
__MATH_INLINE float
__NTH (fmaxf (float __x, float __y))
{
-# ifdef __AVX__
+# ifdef __AVX__
float __res;
__asm ("vmaxss %2, %1, %0" : "=x" (__res) : "x" (x), "xm" (__y));
return __res;
-# else
+# else
__asm ("maxss %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
-# endif
+# endif
}
__MATH_INLINE double
__NTH (fmax (double __x, double __y))
{
-# ifdef __AVX__
+# ifdef __AVX__
float __res;
__asm ("vmaxsd %2, %1, %0" : "=x" (__res) : "x" (x), "xm" (__y));
return __res;
-# else
+# else
__asm ("maxsd %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
-# endif
+# endif
}
/* Determine minimum of two values. */
__MATH_INLINE float
__NTH (fminf (float __x, float __y))
{
-# ifdef __AVX__
+# ifdef __AVX__
float __res;
__asm ("vminss %2, %1, %0" : "=x" (__res) : "x" (x), "xm" (__y));
return __res;
-# else
+# else
__asm ("minss %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
-# endif
+# endif
}
__MATH_INLINE double
__NTH (fmin (double __x, double __y))
{
-# ifdef __AVX__
+# ifdef __AVX__
float __res;
__asm ("vminsd %2, %1, %0" : "=x" (__res) : "x" (x), "xm" (__y));
return __res;
-# else
+# else
__asm ("minsd %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
-# endif
+# endif
}
-# endif
+# endif
__END_NAMESPACE_C99
-# endif
+# endif
-# if defined __SSE4_1__ && defined __SSE2_MATH__
-# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+# if defined __SSE4_1__ && defined __SSE2_MATH__
+# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Round to nearest integer. */
@@ -214,7 +308,7 @@ __NTH (rintf (float __x))
return __res;
}
-# ifdef __USE_ISOC99
+# ifdef __USE_ISOC99
/* Round to nearest integer without raising inexact exception. */
__MATH_INLINE double
__NTH (nearbyint (double __x))
@@ -238,10 +332,10 @@ __NTH (nearbyintf (float __x))
__asm __volatile__ ("roundss $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
return __res;
}
-# endif
+# endif
__END_NAMESPACE_C99
-# endif
+# endif
__BEGIN_NAMESPACE_STD
/* Smallest integral value not less than X. */
@@ -284,6 +378,590 @@ __NTH (floorf (float __x))
return __res;
}
__END_NAMESPACE_C99
+# endif
# endif
-#endif
+# if ((!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) \
+ && !defined __SSE_MATH__ && defined __OPTIMIZE__)
+/* Not used by SSE math. */
+
+/* The inline functions do not set errno or raise necessarily the
+ correct exceptions. */
+# undef math_errhandling
+
+/* A macro to define float, double, and long double versions of various
+ math functions for the ix87 FPU. FUNC is the function name (which will
+ be suffixed with f and l for the float and long double version,
+ respectively). OP is the name of the FPU operation.
+ We define two sets of macros. The set with the additional NP
+ doesn't add a prototype declaration. */
+
+# if defined __USE_MISC || defined __USE_ISOC99
+# define __inline_mathop(func, op) \
+ __inline_mathop_ (double, func, op) \
+ __inline_mathop_ (float, __CONCAT(func,f), op) \
+ __inline_mathop_ (long double, __CONCAT(func,l), op)
+# define __inline_mathopNP(func, op) \
+ __inline_mathopNP_ (double, func, op) \
+ __inline_mathopNP_ (float, __CONCAT(func,f), op) \
+ __inline_mathopNP_ (long double, __CONCAT(func,l), op)
+# else
+# define __inline_mathop(func, op) \
+ __inline_mathop_ (double, func, op)
+# define __inline_mathopNP(func, op) \
+ __inline_mathopNP_ (double, func, op)
+# endif
+
+# define __inline_mathop_(float_type, func, op) \
+ __inline_mathop_decl_ (float_type, func, op, "0" (__x))
+# define __inline_mathopNP_(float_type, func, op) \
+ __inline_mathop_declNP_ (float_type, func, op, "0" (__x))
+
+
+# if defined __USE_MISC || defined __USE_ISOC99
+# define __inline_mathop_decl(func, op, params...) \
+ __inline_mathop_decl_ (double, func, op, params) \
+ __inline_mathop_decl_ (float, __CONCAT(func,f), op, params) \
+ __inline_mathop_decl_ (long double, __CONCAT(func,l), op, params)
+# define __inline_mathop_declNP(func, op, params...) \
+ __inline_mathop_declNP_ (double, func, op, params) \
+ __inline_mathop_declNP_ (float, __CONCAT(func,f), op, params) \
+ __inline_mathop_declNP_ (long double, __CONCAT(func,l), op, params)
+# else
+# define __inline_mathop_decl(func, op, params...) \
+ __inline_mathop_decl_ (double, func, op, params)
+# define __inline_mathop_declNP(func, op, params...) \
+ __inline_mathop_declNP_ (double, func, op, params)
+# endif
+
+# define __inline_mathop_decl_(float_type, func, op, params...) \
+ __MATH_INLINE float_type func (float_type) __THROW; \
+ __inline_mathop_declNP_ (float_type, func, op, params)
+
+# define __inline_mathop_declNP_(float_type, func, op, params...) \
+ __MATH_INLINE float_type __NTH (func (float_type __x)) \
+ { \
+ register float_type __result; \
+ __asm __volatile__ (op : "=t" (__result) : params); \
+ return __result; \
+ }
+
+
+# if defined __USE_MISC || defined __USE_ISOC99
+# define __inline_mathcode(func, arg, code) \
+ __inline_mathcode_ (double, func, arg, code) \
+ __inline_mathcode_ (float, __CONCAT(func,f), arg, code) \
+ __inline_mathcode_ (long double, __CONCAT(func,l), arg, code)
+# define __inline_mathcodeNP(func, arg, code) \
+ __inline_mathcodeNP_ (double, func, arg, code) \
+ __inline_mathcodeNP_ (float, __CONCAT(func,f), arg, code) \
+ __inline_mathcodeNP_ (long double, __CONCAT(func,l), arg, code)
+# define __inline_mathcode2(func, arg1, arg2, code) \
+ __inline_mathcode2_ (double, func, arg1, arg2, code) \
+ __inline_mathcode2_ (float, __CONCAT(func,f), arg1, arg2, code) \
+ __inline_mathcode2_ (long double, __CONCAT(func,l), arg1, arg2, code)
+# define __inline_mathcodeNP2(func, arg1, arg2, code) \
+ __inline_mathcodeNP2_ (double, func, arg1, arg2, code) \
+ __inline_mathcodeNP2_ (float, __CONCAT(func,f), arg1, arg2, code) \
+ __inline_mathcodeNP2_ (long double, __CONCAT(func,l), arg1, arg2, code)
+# define __inline_mathcode3(func, arg1, arg2, arg3, code) \
+ __inline_mathcode3_ (double, func, arg1, arg2, arg3, code) \
+ __inline_mathcode3_ (float, __CONCAT(func,f), arg1, arg2, arg3, code) \
+ __inline_mathcode3_ (long double, __CONCAT(func,l), arg1, arg2, arg3, code)
+# define __inline_mathcodeNP3(func, arg1, arg2, arg3, code) \
+ __inline_mathcodeNP3_ (double, func, arg1, arg2, arg3, code) \
+ __inline_mathcodeNP3_ (float, __CONCAT(func,f), arg1, arg2, arg3, code) \
+ __inline_mathcodeNP3_ (long double, __CONCAT(func,l), arg1, arg2, arg3, code)
+# else
+# define __inline_mathcode(func, arg, code) \
+ __inline_mathcode_ (double, func, (arg), code)
+# define __inline_mathcodeNP(func, arg, code) \
+ __inline_mathcodeNP_ (double, func, (arg), code)
+# define __inline_mathcode2(func, arg1, arg2, code) \
+ __inline_mathcode2_ (double, func, arg1, arg2, code)
+# define __inline_mathcodeNP2(func, arg1, arg2, code) \
+ __inline_mathcodeNP2_ (double, func, arg1, arg2, code)
+# define __inline_mathcode3(func, arg1, arg2, arg3, code) \
+ __inline_mathcode3_ (double, func, arg1, arg2, arg3, code)
+# define __inline_mathcodeNP3(func, arg1, arg2, arg3, code) \
+ __inline_mathcodeNP3_ (double, func, arg1, arg2, arg3, code)
+# endif
+
+# define __inline_mathcode_(float_type, func, arg, code) \
+ __MATH_INLINE float_type func (float_type) __THROW; \
+ __inline_mathcodeNP_(float_type, func, arg, code)
+
+# define __inline_mathcodeNP_(float_type, func, arg, code) \
+ __MATH_INLINE float_type __NTH (func (float_type arg)) \
+ { \
+ code; \
+ }
+
+
+# define __inline_mathcode2_(float_type, func, arg1, arg2, code) \
+ __MATH_INLINE float_type func (float_type, float_type) __THROW; \
+ __inline_mathcodeNP2_ (float_type, func, arg1, arg2, code)
+
+# define __inline_mathcodeNP2_(float_type, func, arg1, arg2, code) \
+ __MATH_INLINE float_type __NTH (func (float_type arg1, float_type arg2)) \
+ { \
+ code; \
+ }
+
+# define __inline_mathcode3_(float_type, func, arg1, arg2, arg3, code) \
+ __MATH_INLINE float_type func (float_type, float_type, float_type) __THROW; \
+ __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code)
+
+# define __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code) \
+ __MATH_INLINE float_type __NTH (func (float_type arg1, float_type arg2, \
+ float_type arg3)) \
+ { \
+ code; \
+ }
+# endif
+
+
+# if !defined __SSE_MATH__ && !defined __NO_MATH_INLINES && defined __OPTIMIZE__
+/* Miscellaneous functions. Not used by SSE math. */
+
+/* __FAST_MATH__ is defined by gcc -ffast-math. */
+# ifdef __FAST_MATH__
+# ifdef __USE_GNU
+# define __sincos_code \
+ register long double __cosr; \
+ register long double __sinr; \
+ register unsigned int __swtmp; \
+ __asm __volatile__ \
+ ("fsincos\n\t" \
+ "fnstsw %w2\n\t" \
+ "testl $0x400, %2\n\t" \
+ "jz 1f\n\t" \
+ "fldpi\n\t" \
+ "fadd %%st(0)\n\t" \
+ "fxch %%st(1)\n\t" \
+ "2: fprem1\n\t" \
+ "fnstsw %w2\n\t" \
+ "testl $0x400, %2\n\t" \
+ "jnz 2b\n\t" \
+ "fstp %%st(1)\n\t" \
+ "fsincos\n\t" \
+ "1:" \
+ : "=t" (__cosr), "=u" (__sinr), "=a" (__swtmp) : "0" (__x)); \
+ *__sinx = __sinr; \
+ *__cosx = __cosr
+
+__MATH_INLINE void
+__NTH (__sincos (double __x, double *__sinx, double *__cosx))
+{
+ __sincos_code;
+}
+
+__MATH_INLINE void
+__NTH (__sincosf (float __x, float *__sinx, float *__cosx))
+{
+ __sincos_code;
+}
+
+__MATH_INLINE void
+__NTH (__sincosl (long double __x, long double *__sinx, long double *__cosx))
+{
+ __sincos_code;
+}
+# endif
+
+
+/* Optimized inline implementation, sometimes with reduced precision
+ and/or argument range. */
+
+# if __GNUC_PREREQ (3, 5)
+# define __expm1_code \
+ register long double __temp; \
+ __temp = __builtin_expm1l (__x); \
+ return __temp ? __temp : __x
+# else
+# define __expm1_code \
+ register long double __value; \
+ register long double __exponent; \
+ register long double __temp; \
+ __asm __volatile__ \
+ ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" \
+ "fmul %%st(1) # x * log2(e)\n\t" \
+ "fst %%st(1)\n\t" \
+ "frndint # int(x * log2(e))\n\t" \
+ "fxch\n\t" \
+ "fsub %%st(1) # fract(x * log2(e))\n\t" \
+ "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" \
+ "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" \
+ : "=t" (__value), "=u" (__exponent) : "0" (__x)); \
+ __asm __volatile__ \
+ ("fscale # 2^int(x * log2(e))\n\t" \
+ : "=t" (__temp) : "0" (1.0), "u" (__exponent)); \
+ __temp -= 1.0; \
+ __temp += __value; \
+ return __temp ? __temp : __x
+# endif
+__inline_mathcodeNP_ (long double, __expm1l, __x, __expm1_code)
+
+# if __GNUC_PREREQ (3, 4)
+__inline_mathcodeNP_ (long double, __expl, __x, return __builtin_expl (__x))
+# else
+# define __exp_code \
+ register long double __value; \
+ register long double __exponent; \
+ __asm __volatile__ \
+ ("fldl2e # e^x = 2^(x * log2(e))\n\t" \
+ "fmul %%st(1) # x * log2(e)\n\t" \
+ "fst %%st(1)\n\t" \
+ "frndint # int(x * log2(e))\n\t" \
+ "fxch\n\t" \
+ "fsub %%st(1) # fract(x * log2(e))\n\t" \
+ "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" \
+ : "=t" (__value), "=u" (__exponent) : "0" (__x)); \
+ __value += 1.0; \
+ __asm __volatile__ \
+ ("fscale" \
+ : "=t" (__value) : "0" (__value), "u" (__exponent)); \
+ return __value
+__inline_mathcodeNP (exp, __x, __exp_code)
+__inline_mathcodeNP_ (long double, __expl, __x, __exp_code)
+# endif
+
+
+# if !__GNUC_PREREQ (3, 5)
+__inline_mathcodeNP (tan, __x, \
+ register long double __value; \
+ register long double __value2 __attribute__ ((__unused__)); \
+ __asm __volatile__ \
+ ("fptan" \
+ : "=t" (__value2), "=u" (__value) : "0" (__x)); \
+ return __value)
+# endif
+# endif /* __FAST_MATH__ */
+
+
+# if __GNUC_PREREQ (3, 4)
+__inline_mathcodeNP2_ (long double, __atan2l, __y, __x,
+ return __builtin_atan2l (__y, __x))
+# else
+# define __atan2_code \
+ register long double __value; \
+ __asm __volatile__ \
+ ("fpatan" \
+ : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); \
+ return __value
+# ifdef __FAST_MATH__
+__inline_mathcodeNP2 (atan2, __y, __x, __atan2_code)
+# endif
+__inline_mathcodeNP2_ (long double, __atan2l, __y, __x, __atan2_code)
+# endif
+
+
+# if defined __FAST_MATH__ && !__GNUC_PREREQ (3, 5)
+__inline_mathcodeNP2 (fmod, __x, __y, \
+ register long double __value; \
+ __asm __volatile__ \
+ ("1: fprem\n\t" \
+ "fnstsw %%ax\n\t" \
+ "sahf\n\t" \
+ "jp 1b" \
+ : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); \
+ return __value)
+# endif
+
+
+# ifdef __FAST_MATH__
+# if !__GNUC_PREREQ (3,3)
+__inline_mathopNP (sqrt, "fsqrt")
+__inline_mathopNP_ (long double, __sqrtl, "fsqrt")
+# define __libc_sqrtl(n) __sqrtl (n)
+# else
+# define __libc_sqrtl(n) __builtin_sqrtl (n)
+# endif
+# endif
+
+# if __GNUC_PREREQ (2, 8)
+__inline_mathcodeNP_ (double, fabs, __x, return __builtin_fabs (__x))
+# if defined __USE_MISC || defined __USE_ISOC99
+__inline_mathcodeNP_ (float, fabsf, __x, return __builtin_fabsf (__x))
+__inline_mathcodeNP_ (long double, fabsl, __x, return __builtin_fabsl (__x))
+# endif
+__inline_mathcodeNP_ (long double, __fabsl, __x, return __builtin_fabsl (__x))
+# else
+__inline_mathop (fabs, "fabs")
+__inline_mathop_ (long double, __fabsl, "fabs")
+# endif
+
+# ifdef __FAST_MATH__
+# if !__GNUC_PREREQ (3, 4)
+/* The argument range of this inline version is reduced. */
+__inline_mathopNP (sin, "fsin")
+/* The argument range of this inline version is reduced. */
+__inline_mathopNP (cos, "fcos")
+
+__inline_mathop_declNP (log, "fldln2; fxch; fyl2x", "0" (__x) : "st(1)")
+# endif
+
+# if !__GNUC_PREREQ (3, 5)
+__inline_mathop_declNP (log10, "fldlg2; fxch; fyl2x", "0" (__x) : "st(1)")
+
+__inline_mathcodeNP (asin, __x, return __atan2l (__x, __libc_sqrtl (1.0 - __x * __x)))
+__inline_mathcodeNP (acos, __x, return __atan2l (__libc_sqrtl (1.0 - __x * __x), __x))
+# endif
+
+# if !__GNUC_PREREQ (3, 4)
+__inline_mathop_declNP (atan, "fld1; fpatan", "0" (__x) : "st(1)")
+# endif
+# endif /* __FAST_MATH__ */
+
+__inline_mathcode_ (long double, __sgn1l, __x, \
+ __extension__ union { long double __xld; unsigned int __xi[3]; } __n = \
+ { __xld: __x }; \
+ __n.__xi[2] = (__n.__xi[2] & 0x8000) | 0x3fff; \
+ __n.__xi[1] = 0x80000000; \
+ __n.__xi[0] = 0; \
+ return __n.__xld)
+
+
+# ifdef __FAST_MATH__
+/* The argument range of the inline version of sinhl is slightly reduced. */
+__inline_mathcodeNP (sinh, __x, \
+ register long double __exm1 = __expm1l (__fabsl (__x)); \
+ return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x))
+
+__inline_mathcodeNP (cosh, __x, \
+ register long double __ex = __expl (__x); \
+ return 0.5 * (__ex + 1.0 / __ex))
+
+__inline_mathcodeNP (tanh, __x, \
+ register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \
+ return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x))
+# endif
+
+__inline_mathcodeNP (floor, __x, \
+ register long double __value; \
+ register int __ignore; \
+ unsigned short int __cw; \
+ unsigned short int __cwtmp; \
+ __asm __volatile ("fnstcw %3\n\t" \
+ "movzwl %3, %1\n\t" \
+ "andl $0xf3ff, %1\n\t" \
+ "orl $0x0400, %1\n\t" /* rounding down */ \
+ "movw %w1, %2\n\t" \
+ "fldcw %2\n\t" \
+ "frndint\n\t" \
+ "fldcw %3" \
+ : "=t" (__value), "=&q" (__ignore), "=m" (__cwtmp), \
+ "=m" (__cw) \
+ : "0" (__x)); \
+ return __value)
+
+__inline_mathcodeNP (ceil, __x, \
+ register long double __value; \
+ register int __ignore; \
+ unsigned short int __cw; \
+ unsigned short int __cwtmp; \
+ __asm __volatile ("fnstcw %3\n\t" \
+ "movzwl %3, %1\n\t" \
+ "andl $0xf3ff, %1\n\t" \
+ "orl $0x0800, %1\n\t" /* rounding up */ \
+ "movw %w1, %2\n\t" \
+ "fldcw %2\n\t" \
+ "frndint\n\t" \
+ "fldcw %3" \
+ : "=t" (__value), "=&q" (__ignore), "=m" (__cwtmp), \
+ "=m" (__cw) \
+ : "0" (__x)); \
+ return __value)
+
+# ifdef __FAST_MATH__
+# define __ldexp_code \
+ register long double __value; \
+ __asm __volatile__ \
+ ("fscale" \
+ : "=t" (__value) : "0" (__x), "u" ((long double) __y)); \
+ return __value
+
+__MATH_INLINE double
+__NTH (ldexp (double __x, int __y))
+{
+ __ldexp_code;
+}
+# endif
+
+
+/* Optimized versions for some non-standardized functions. */
+# if defined __USE_ISOC99 || defined __USE_MISC
+
+# ifdef __FAST_MATH__
+__inline_mathcodeNP (expm1, __x, __expm1_code)
+
+/* We cannot rely on M_SQRT being defined. So we do it for ourself
+ here. */
+# define __M_SQRT2 1.41421356237309504880L /* sqrt(2) */
+
+# if !__GNUC_PREREQ (3, 5)
+__inline_mathcodeNP (log1p, __x, \
+ register long double __value; \
+ if (__fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \
+ __value = logl (1.0 + __x); \
+ else \
+ __asm __volatile__ \
+ ("fldln2\n\t" \
+ "fxch\n\t" \
+ "fyl2xp1" \
+ : "=t" (__value) : "0" (__x) : "st(1)"); \
+ return __value)
+# endif
+
+
+/* The argument range of the inline version of asinhl is slightly reduced. */
+__inline_mathcodeNP (asinh, __x, \
+ register long double __y = __fabsl (__x); \
+ return (log1pl (__y * __y / (__libc_sqrtl (__y * __y + 1.0) + 1.0) + __y) \
+ * __sgn1l (__x)))
+
+__inline_mathcodeNP (acosh, __x, \
+ return logl (__x + __libc_sqrtl (__x - 1.0) * __libc_sqrtl (__x + 1.0)))
+
+__inline_mathcodeNP (atanh, __x, \
+ register long double __y = __fabsl (__x); \
+ return -0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * __sgn1l (__x))
+
+/* The argument range of the inline version of hypotl is slightly reduced. */
+__inline_mathcodeNP2 (hypot, __x, __y,
+ return __libc_sqrtl (__x * __x + __y * __y))
+
+# if !__GNUC_PREREQ (3, 5)
+__inline_mathcodeNP(logb, __x, \
+ register long double __value; \
+ register long double __junk; \
+ __asm __volatile__ \
+ ("fxtract\n\t" \
+ : "=t" (__junk), "=u" (__value) : "0" (__x)); \
+ return __value)
+# endif
+
+# endif
+# endif
+
+# ifdef __USE_ISOC99
+# ifdef __FAST_MATH__
+
+# if !__GNUC_PREREQ (3, 5)
+__inline_mathop_declNP (log2, "fld1; fxch; fyl2x", "0" (__x) : "st(1)")
+# endif
+
+__MATH_INLINE float
+__NTH (ldexpf (float __x, int __y))
+{
+ __ldexp_code;
+}
+
+__MATH_INLINE long double
+__NTH (ldexpl (long double __x, int __y))
+{
+ __ldexp_code;
+}
+
+__inline_mathopNP (rint, "frndint")
+# endif /* __FAST_MATH__ */
+
+# define __lrint_code \
+ long int __lrintres; \
+ __asm__ __volatile__ \
+ ("fistpl %0" \
+ : "=m" (__lrintres) : "t" (__x) : "st"); \
+ return __lrintres
+__MATH_INLINE long int
+__NTH (lrintf (float __x))
+{
+ __lrint_code;
+}
+__MATH_INLINE long int
+__NTH (lrint (double __x))
+{
+ __lrint_code;
+}
+__MATH_INLINE long int
+__NTH (lrintl (long double __x))
+{
+ __lrint_code;
+}
+# undef __lrint_code
+
+# define __llrint_code \
+ long long int __llrintres; \
+ __asm__ __volatile__ \
+ ("fistpll %0" \
+ : "=m" (__llrintres) : "t" (__x) : "st"); \
+ return __llrintres
+__MATH_INLINE long long int
+__NTH (llrintf (float __x))
+{
+ __llrint_code;
+}
+__MATH_INLINE long long int
+__NTH (llrint (double __x))
+{
+ __llrint_code;
+}
+__MATH_INLINE long long int
+__NTH (llrintl (long double __x))
+{
+ __llrint_code;
+}
+# undef __llrint_code
+
+# endif
+
+
+# ifdef __USE_MISC
+
+# if defined __FAST_MATH__ && !__GNUC_PREREQ (3, 5)
+__inline_mathcodeNP2 (drem, __x, __y, \
+ register double __value; \
+ register int __clobbered; \
+ __asm __volatile__ \
+ ("1: fprem1\n\t" \
+ "fstsw %%ax\n\t" \
+ "sahf\n\t" \
+ "jp 1b" \
+ : "=t" (__value), "=&a" (__clobbered) : "0" (__x), "u" (__y) : "cc"); \
+ return __value)
+# endif
+
+
+/* This function is used in the `isfinite' macro. */
+__MATH_INLINE int
+__NTH (__finite (double __x))
+{
+ return (__extension__
+ (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]
+ | 0x800fffffu) + 1) >> 31));
+}
+
+# endif /* __USE_MISC */
+
+/* Undefine some of the large macros which are not used anymore. */
+# undef __atan2_code
+# ifdef __FAST_MATH__
+# undef __expm1_code
+# undef __exp_code
+# undef __sincos_code
+# endif /* __FAST_MATH__ */
+
+# endif /* __NO_MATH_INLINES */
+
+
+/* This code is used internally in the GNU libc. Not used by SSE math. */
+# if !defined __SSE_MATH__ && defined __LIBC_INTERNAL_MATH_INLINES
+__inline_mathop (__ieee754_sqrt, "fsqrt")
+__inline_mathcode2 (__ieee754_atan2, __y, __x,
+ register long double __value;
+ __asm __volatile__ ("fpatan\n\t"
+ : "=t" (__value)
+ : "0" (__x), "u" (__y) : "st(1)");
+ return __value;)
+# endif
+
+#endif /* __GNUC__ */
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=47112b70dfc4e83504331b3435d4764d9bc2d8df
commit 47112b70dfc4e83504331b3435d4764d9bc2d8df
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jun 4 13:31:57 2012 -0700
Use x86_64 fpu/bits/fenv.h for i386 and x86_64
diff --git a/ChangeLog.pr14117 b/ChangeLog.pr14117
index 7656c24..5a12cb3 100644
--- a/ChangeLog.pr14117
+++ b/ChangeLog.pr14117
@@ -1,5 +1,11 @@
2012-06-04 H.J. Lu <hongjiu.lu@intel.com>
[BZ #14117]
+ * sysdeps/i386/fpu/bits/fenv.h: Removed.
+ * sysdeps/i386/fpu/Implies: New file.
+ * sysdeps/x86_64/fpu/Implies: Likewise.
+ * sysdeps/x86_64/fpu/bits/fenv.h: Renamed to ...
+ * sysdeps/x86/fpu/bits/fenv.h: This.
+
* sysdeps/x86_64/fpu/bits/fenv.h (feraiseexcept): Check
__SSE_MATH__.
diff --git a/sysdeps/i386/fpu/Implies b/sysdeps/i386/fpu/Implies
new file mode 100644
index 0000000..2b745a3
--- /dev/null
+++ b/sysdeps/i386/fpu/Implies
@@ -0,0 +1 @@
+x86/fpu
diff --git a/sysdeps/i386/fpu/bits/fenv.h b/sysdeps/i386/fpu/bits/fenv.h
deleted file mode 100644
index e71ceb7..0000000
--- a/sysdeps/i386/fpu/bits/fenv.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Copyright (C) 1997-2012 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
- 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, see
- <http://www.gnu.org/licenses/>. */
-
-#ifndef _FENV_H
-# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
-#endif
-
-
-/* Define bits representing the exception. We use the bit positions
- of the appropriate bits in the FPU control word. */
-enum
- {
- FE_INVALID = 0x01,
-#define FE_INVALID FE_INVALID
- __FE_DENORM = 0x02,
- FE_DIVBYZERO = 0x04,
-#define FE_DIVBYZERO FE_DIVBYZERO
- FE_OVERFLOW = 0x08,
-#define FE_OVERFLOW FE_OVERFLOW
- FE_UNDERFLOW = 0x10,
-#define FE_UNDERFLOW FE_UNDERFLOW
- FE_INEXACT = 0x20
-#define FE_INEXACT FE_INEXACT
- };
-
-#define FE_ALL_EXCEPT \
- (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
-
-/* The ix87 FPU supports all of the four defined rounding modes. We
- use again the bit positions in the FPU control word as the values
- for the appropriate macros. */
-enum
- {
- FE_TONEAREST = 0,
-#define FE_TONEAREST FE_TONEAREST
- FE_DOWNWARD = 0x400,
-#define FE_DOWNWARD FE_DOWNWARD
- FE_UPWARD = 0x800,
-#define FE_UPWARD FE_UPWARD
- FE_TOWARDZERO = 0xc00
-#define FE_TOWARDZERO FE_TOWARDZERO
- };
-
-
-/* Type representing exception flags. */
-typedef unsigned short int fexcept_t;
-
-
-/* Type representing floating-point environment. This function corresponds
- to the layout of the block written by the `fstenv'. */
-typedef struct
- {
- unsigned short int __control_word;
- unsigned short int __unused1;
- unsigned short int __status_word;
- unsigned short int __unused2;
- unsigned short int __tags;
- unsigned short int __unused3;
- unsigned int __eip;
- unsigned short int __cs_selector;
- unsigned int __opcode:11;
- unsigned int __unused4:5;
- unsigned int __data_offset;
- unsigned short int __data_selector;
- unsigned short int __unused5;
- }
-fenv_t;
-
-/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((const fenv_t *) -1)
-
-#ifdef __USE_GNU
-/* Floating-point environment where none of the exception is masked. */
-# define FE_NOMASK_ENV ((const fenv_t *) -2)
-#endif
-
-
-#ifdef __USE_EXTERN_INLINES
-__BEGIN_DECLS
-
-/* Optimized versions. */
-extern int __REDIRECT_NTH (__feraiseexcept_renamed, (int), feraiseexcept);
-__extern_inline int
-__NTH (feraiseexcept (int __excepts))
-{
- if (__builtin_constant_p (__excepts)
- && (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0)
- {
- if ((FE_INVALID & __excepts) != 0)
- {
- /* One example of a invalid operation is 0.0 / 0.0. */
- float __f = 0.0;
-
-# ifdef __SSE_MATH__
- __asm__ __volatile__ ("divss %0, %0 " : : "x" (__f));
-# else
- __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait"
- : "=t" (__f) : "0" (__f));
-# endif
- (void) &__f;
- }
- if ((FE_DIVBYZERO & __excepts) != 0)
- {
- float __f = 1.0;
- float __g = 0.0;
-
-# ifdef __SSE_MATH__
- __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
-# else
- __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait"
- : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
-# endif
- (void) &__f;
- }
-
- return 0;
- }
-
- return __feraiseexcept_renamed (__excepts);
-}
-
-__END_DECLS
-#endif
diff --git a/sysdeps/x86_64/fpu/bits/fenv.h b/sysdeps/x86/fpu/bits/fenv.h
similarity index 100%
rename from sysdeps/x86_64/fpu/bits/fenv.h
rename to sysdeps/x86/fpu/bits/fenv.h
diff --git a/sysdeps/x86_64/fpu/Implies b/sysdeps/x86_64/fpu/Implies
new file mode 100644
index 0000000..2b745a3
--- /dev/null
+++ b/sysdeps/x86_64/fpu/Implies
@@ -0,0 +1 @@
+x86/fpu
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=a1b0c02f9e9f7ded4d2f3c659f25f5e3499f92db
commit a1b0c02f9e9f7ded4d2f3c659f25f5e3499f92db
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jun 4 13:30:42 2012 -0700
Check __SSE_MATH__ in x86_64 feraiseexcept
diff --git a/ChangeLog.pr14117 b/ChangeLog.pr14117
new file mode 100644
index 0000000..7656c24
--- /dev/null
+++ b/ChangeLog.pr14117
@@ -0,0 +1,5 @@
+2012-06-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #14117]
+ * sysdeps/x86_64/fpu/bits/fenv.h (feraiseexcept): Check
+ __SSE_MATH__.
diff --git a/sysdeps/x86_64/fpu/bits/fenv.h b/sysdeps/x86_64/fpu/bits/fenv.h
index bb790c9..b2c01c4 100644
--- a/sysdeps/x86_64/fpu/bits/fenv.h
+++ b/sysdeps/x86_64/fpu/bits/fenv.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997-2001,2004,2011,2012 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2012 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
@@ -109,7 +109,12 @@ __NTH (feraiseexcept (int __excepts))
/* One example of a invalid operation is 0.0 / 0.0. */
float __f = 0.0;
+# ifdef __SSE_MATH__
__asm__ __volatile__ ("divss %0, %0 " : : "x" (__f));
+# else
+ __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait"
+ : "=t" (__f) : "0" (__f));
+# endif
(void) &__f;
}
if ((FE_DIVBYZERO & __excepts) != 0)
@@ -117,7 +122,12 @@ __NTH (feraiseexcept (int __excepts))
float __f = 1.0;
float __g = 0.0;
+# ifdef __SSE_MATH__
__asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
+# else
+ __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait"
+ : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
+# endif
(void) &__f;
}
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources