This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Update sysdeps/x86_64/fpu_control.h


On Sun, Jun 17, 2012 at 1:38 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Jun 17, 2012 at 1:11 PM, Roland McGrath <roland@hack.frob.com> wrote:
>>> +/* Macros for accessing the hardware control word.
>>> +
>>> + ? Note that the use of these macros is no sufficient anymore with
>>
>> "not sufficient"
>
> Fixed.
>
>>> + ? recent hardware. ?Some floating point operations are executed in
>>> + ? the SSE/SSE2 engines which have their own control and status register. ?*/
>>> +#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
>>> +#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
>>
>> Why *&? ?That seems like a no-op. ?There should be a comment explaining the
>
> "*&" was added by Ulrich on Aug 26, 1996, ?I couldn't find anything beyond
> that. ?It could be a workaround for a compiler bug.
>

For GCC 4.6,

[hjl@gnu-6 tmp]$ cat x.c
#include <fpu_control.h>

void
foo ()
{
  _FPU_SETCW (0x200);
}
[hjl@gnu-6 tmp]$

("fldcw %0" : : "m" (*&cw))

gives:

[hjl@gnu-6 tmp]$ gcc -S x.c
x.c: In function \u2018foo\u2019:
x.c:6:3: error: lvalue required as unary \u2018&\u2019 operand
x.c:6:3: error: memory input 0 is not directly addressable
[hjl@gnu-6 tmp]$

and

("fldcw %0" : : "m" (cw))

gives

[hjl@gnu-6 tmp]$ gcc -S x.c
x.c: In function \u2018foo\u2019:
x.c:6:3: error: memory input 0 is not directly addressable
[hjl@gnu-6 tmp]$

The older compilers may behave differently.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]