From b53f8a67649a371a38dc6d97b0dfe52111236a3e Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Tue, 1 Jun 2010 13:50:50 +0000 Subject: OTP-8658 Add missing memory barriers in erts_poll() Missing memory barriers in erts_poll() could cause the runtime system to hang indefinitely. --- erts/include/internal/i386/atomic.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'erts/include/internal/i386') diff --git a/erts/include/internal/i386/atomic.h b/erts/include/internal/i386/atomic.h index 3291ad38e5..90b4c5f773 100644 --- a/erts/include/internal/i386/atomic.h +++ b/erts/include/internal/i386/atomic.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2005-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2005-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -32,6 +32,16 @@ typedef struct { volatile long counter; } ethr_native_atomic_t; +#ifdef __x86_64__ +#define ETHR_MEMORY_BARRIER __asm__ __volatile__("mfence" : : : "memory") +#else +#define ETHR_MEMORY_BARRIER \ +do { \ + volatile long x___ = 0; \ + __asm__ __volatile__("lock; incl %0" : "=m"(x___) : "m"(x___) : "memory"); \ +} while (0) +#endif + #ifdef ETHR_TRY_INLINE_FUNCS #ifdef __x86_64__ -- cgit v1.2.3