public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix x86_64 bits/mathinline.h for -m32 compilation
@ 2009-09-01 15:54 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2009-09-01 15:54 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

With the latest bits/mathinline.h,
echo '#include <math.h>' | gcc -S -xc - -o - -std=c99 -O2 -m32
doesn't compile:
/usr/include/bits/mathinline.h:39: error: impossible constraint in 'asm'
/usr/include/bits/mathinline.h:46: error: impossible constraint in 'asm'
The problem is that SSE{,2} assembly and "x" constraint is used even in
32-bit code.

Here is an untested fix:

2009-09-01  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/x86_64/fpu/bits/mathinline.h: Include bits/wordsize.h.
	(__signbitf, __signbit): Only use SSE inline asm for 64-bit.

diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
index ece0f02..dc58f67 100644
--- a/sysdeps/x86_64/fpu/bits/mathinline.h
+++ b/sysdeps/x86_64/fpu/bits/mathinline.h
@@ -22,6 +22,8 @@
 # error "Never use <bits/mathinline.h> directly; include <math.h> instead."
 #endif
 
+#include <bits/wordsize.h>
+
 #ifndef __extern_inline
 # define __MATH_INLINE __inline
 #else
@@ -35,16 +37,26 @@
 __MATH_INLINE int
 __NTH (__signbitf (float __x))
 {
+#if __WORDSIZE == 32
+  __extension__ union { float __f; int __i; } __u = { __f: __x };
+  return __u.__i < 0;
+#else
   int __m;
   __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
   return __m & 0x8;
+#endif
 }
 __MATH_INLINE int
 __NTH (__signbit (double __x))
 {
+#if __WORDSIZE == 32
+  __extension__ union { double __d; int __i[2]; } __u = { __d: __x };
+  return __u.__i[1] < 0;
+#else
   int __m;
   __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
   return __m & 0x80;
+#endif
 }
 __MATH_INLINE int
 __NTH (__signbitl (long double __x))

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-01 15:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-01 15:54 [PATCH] Fix x86_64 bits/mathinline.h for -m32 compilation Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).