From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122218 invoked by alias); 17 Mar 2015 23:10:34 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 122174 invoked by uid 48); 17 Mar 2015 23:10:30 -0000 From: "gccbugzilla at limegreensocks dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/62109] __gthr_i486_lock_cmp_xchg missing clobber Date: Tue, 17 Mar 2015 23:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gccbugzilla at limegreensocks dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01742.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62109 --- Comment #6 from David --- Actually, the code already uses InterlockedCompareExchange. UNLESS users explicitly tell it not to: #ifdef __GTHREAD_I486_INLINE_LOCK_PRIMITIVES static inline long __gthr_i486_lock_cmp_xchg(long *__dest, long __xchg, long __comperand) { long result; __asm__ __volatile__ ("\n\ lock\n\ cmpxchg{l} {%4, %1|%1, %4}\n" : "=a" (result), "=m" (*__dest) : "0" (__comperand), "m" (*__dest), "r" (__xchg) : "cc"); return result; } #define __GTHR_W32_InterlockedCompareExchange __gthr_i486_lock_cmp_xchg #else /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ #define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange #endif /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ Since we are talking about postponing this to stage 1 (which I do not object to), what if we change this to something like: #ifdef __GTHREAD_I486_INLINE_LOCK_PRIMITIVES #error "__GTHREAD_I486_INLINE_LOCK_PRIMITIVES is no longer supported. Remove this definition to use system calls for Win98 and above." #else /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ #define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange #endif /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ Then wait to see if anyone cares. I am ok with either fixing it (by adding the "memory" clobber) or removing it (since the problem it was intended to fix only happens on OSs that aren't supported anymore). But leaving it "as-is" leaves open the possibility that people are using this without even knowing it (and getting nearly-impossible-to-track-down timing problems). Or that someone might copy/paste this code into their own projects.