This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/38688] New: __sync_lock_test_and_set does not actually lock
- From: "felix-gcc at fefe dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jan 2009 15:56:07 -0000
- Subject: [Bug c/38688] New: __sync_lock_test_and_set does not actually lock
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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