Bug 21097 - __sync_bool_compare_and_swap doesn't work with -m32
Summary: __sync_bool_compare_and_swap doesn't work with -m32
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-18 22:32 UTC by H.J. Lu
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2005-04-18 22:32:38 UTC
[hjl@gnu-9 gcc]$ cat /tmp/x.c
#include <stdio.h>

#ifdef OLD
extern int __sync_bool_compare_and_swap_di (long *, long, long);
#else
#define __sync_bool_compare_and_swap_di __sync_bool_compare_and_swap
#endif

int
foo (long *x)
{
  long address = *x;
  if (!__sync_bool_compare_and_swap_di (x, address, (address | 1)))
    return 0;
  else
    return 1;
}

int
main ()
{
  long val = 0;
  int ret;
  printf ("val: 0x%lx\n", val);
  ret = foo (&val);
  printf ("ret: %d: val: 0x%lx\n", ret, val);
  return;
}
[hjl@gnu-9 gcc]$ ./xgcc -B./ -O2 /tmp/x.c
[hjl@gnu-9 gcc]$ ./a.out
val: 0x0
ret: 1: val: 0x1
[hjl@gnu-9 gcc]$ ./xgcc -B./ -O2 /tmp/x.c -m32
/tmp/ccQy8ACO.o: In function `foo':
x.c:(.text+0x1c): undefined reference to `__sync_bool_compare_and_swap_4'
collect2: ld returned 1 exit status
Comment 1 Richard Henderson 2005-04-19 16:21:46 UTC
When, exactly, did you think that cmpxchg was added?  Use -march=i486.  Duh.
Comment 2 H.J. Lu 2005-04-19 16:28:26 UTC
But there is no __sync_bool_compare_and_swap_4 in source code.
If it isn't available, shouldn't gcc leave __sync_bool_compare_and_swap
alone.
Comment 3 Richard Henderson 2005-04-19 19:34:21 UTC
No, because __sync_bool_compare_and_swap is overloaded.
This expansion to __sync_bool_compare_and_swap_N is documented.