This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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] | |
Brian,
On Thursday 25 September 2008, Brian Dessent wrote:
> Frank Mehnert wrote:
> > I would like to get some help in writing an inline assembler function
> > for the cmpxchg8b command. Especially for the x86 target and PIC support.
> > PIC (position independant code) implies that EBX must not be changed. And
> > the x86 target has only a limited number of registers available. And of
> > course the code should work regardless if we have -fomit-frame-pointer
> > enabled or not (so no EBP register available). So far I have the
> > following function:
>
> I think you're making life a lot harder than it needs to be. gcc
> already has intrinsics for these things, and
> __sync_{bool,val}_compare_and_swap() will use cmpxchg8b if you use a 8
> byte type and if your selected architecture supports it. Note that the
> default (-march=386) does not, so you need to specify something higher.
>
> <http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html>
Thank you for this suggestion! These functions are indeed very helpful
if they are implemented. It seems that cmpxchg8b is used starting from
gcc version 4.2. However, if compiled with -march=i586 -fPIC, this function
generates wrong code. I've created a bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37651
Thanks anyway,
Frank
--
Dr.-Ing. Frank Mehnert Sun Microsystems http://www.sun.com/
Attachment:
signature.asc
Description: This is a digitally signed message part.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |