public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38688]  New: __sync_lock_test_and_set does not actually lock
@ 2009-01-01 15:57 felix-gcc at fefe dot de
  2009-01-01 16:00 ` [Bug c/38688] " felix-gcc at fefe dot de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: felix-gcc at fefe dot de @ 2009-01-01 15:57 UTC (permalink / raw)
  To: gcc-bugs

I was looking for something like MSVC's InterlockedIncrement in gcc and found
the __sync_lock_test_and_set builtin.

I wrote a small test program:

  #include <stdio.h>
  int l;
  int main() {
    printf("%d\n",__sync_lock_test_and_set(&l,1));
  }

and when I look at the disassembly I get

  xchgl   l(%rip), %esi

in 64-bit mode and

  xchgl   l, %eax

in 32-bit mode.  Notably missing is the lock prefix.  I was expecting a lock
prefix since the builtin is called __sync_LOCK_test_and_set.  Should there not
be a lock here?


-- 
           Summary: __sync_lock_test_and_set does not actually lock
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: felix-gcc at fefe dot de
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38688


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-15 19:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-01 15:57 [Bug c/38688] New: __sync_lock_test_and_set does not actually lock felix-gcc at fefe dot de
2009-01-01 16:00 ` [Bug c/38688] " felix-gcc at fefe dot de
2009-01-01 16:03 ` felix-gcc at fefe dot de
2009-01-01 16:03 ` pinskia at gcc dot gnu dot org
2009-04-15 19:39 ` jb at gcc dot gnu dot org
2009-04-15 19:42 ` jb at gcc dot gnu dot org

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).