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
* [Bug c/38688] __sync_lock_test_and_set does not actually lock
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 ` felix-gcc at fefe dot de
2009-01-01 16:03 ` felix-gcc at fefe dot de
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: felix-gcc at fefe dot de @ 2009-01-01 16:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from felix-gcc at fefe dot de 2009-01-01 15:58 -------
All I really want is a way to access lock cmpxchg and lock xadd, really :-)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38688
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/38688] __sync_lock_test_and_set does not actually lock
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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: felix-gcc at fefe dot de @ 2009-01-01 16:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from felix-gcc at fefe dot de 2009-01-01 16:01 -------
Sorry, I just found out that xchg has an implicit lock. Never mind about this
bug.
--
felix-gcc at fefe dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38688
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/38688] __sync_lock_test_and_set does not actually lock
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
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-01 16:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2009-01-01 16:01 -------
;; Recall that xchg implicitly sets LOCK#, so adding it again wastes space.
(define_insn "sync_lock_test_and_set<mode>"
[(set (match_operand:IMODE 0 "register_operand" "=<modeconstraint>")
(unspec_volatile:IMODE
[(match_operand:IMODE 1 "memory_operand" "+m")] UNSPECV_XCHG))
(set (match_dup 1)
(match_operand:IMODE 2 "register_operand" "0"))]
So this is invalid as xchg implicitly sets LOCK. why do you want to waste
space in the icache for something that is already done implicitly?
See also
http://groups.google.com/group/alt.lang.asm/browse_thread/thread/7ae1bc600fe8aadc?pli=1
.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38688
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/38688] __sync_lock_test_and_set does not actually lock
2009-01-01 15:57 [Bug c/38688] New: __sync_lock_test_and_set does not actually lock felix-gcc at fefe dot de
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu dot org @ 2009-04-15 19:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jb at gcc dot gnu dot org 2009-04-15 19:38 -------
Subject: Bug 38688
Author: jb
Date: Wed Apr 15 19:38:32 2009
New Revision: 146134
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146134
Log:
2009-04-15 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/38688
* io/transfer.c (finalize_transfer): Don't flush for advance='no'.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/transfer.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38688
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/38688] __sync_lock_test_and_set does not actually lock
2009-01-01 15:57 [Bug c/38688] New: __sync_lock_test_and_set does not actually lock felix-gcc at fefe dot de
` (3 preceding siblings ...)
2009-04-15 19:39 ` jb at gcc dot gnu dot org
@ 2009-04-15 19:42 ` jb at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu dot org @ 2009-04-15 19:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jb at gcc dot gnu dot org 2009-04-15 19:42 -------
Er, sorry, wrong PR in the ChangeLog.
--
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).