diff options
Diffstat (limited to 'erts/include/internal')
-rw-r--r-- | erts/include/internal/ethread.h | 22 | ||||
-rw-r--r-- | erts/include/internal/i386/atomic.h | 20 | ||||
-rw-r--r-- | erts/include/internal/ppc32/atomic.h | 11 | ||||
-rw-r--r-- | erts/include/internal/sparc32/atomic.h | 14 | ||||
-rw-r--r-- | erts/include/internal/tile/atomic.h | 2 |
5 files changed, 49 insertions, 20 deletions
diff --git a/erts/include/internal/ethread.h b/erts/include/internal/ethread.h index 934a79c6f9..564f8f057c 100644 --- a/erts/include/internal/ethread.h +++ b/erts/include/internal/ethread.h @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2004-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2004-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% */ @@ -375,6 +375,12 @@ ETHR_INLINE_FUNC_NAME_(ethr_mutex_unlock)(ethr_mutex *mtx) #define ETHR_HAVE_OPTIMIZED_ATOMIC_OPS 1 #define ETHR_HAVE_OPTIMIZED_LOCKS 1 +#define ETHR_MEMORY_BARRIER \ +do { \ + volatile LONG x___ = 0; \ + (void) _InterlockedCompareExchange(&x___, (LONG) 1, (LONG) 0); \ +} while (0) + typedef struct { volatile LONG value; } ethr_atomic_t; @@ -1124,6 +1130,12 @@ ETHR_INLINE_FUNC_NAME_(ethr_write_lock)(ethr_rwlock_t *lock) */ #ifndef ETHR_HAVE_OPTIMIZED_ATOMIC_OPS +/* + * ETHR_MEMORY_BARRIER orders between locked and atomic accesses only, + * i.e. when this atomic fallback is used a noop is sufficient. + */ +#define ETHR_MEMORY_BARRIER + #define ETHR_ATOMIC_ADDR_BITS 4 #define ETHR_ATOMIC_ADDR_SHIFT 3 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__ diff --git a/erts/include/internal/ppc32/atomic.h b/erts/include/internal/ppc32/atomic.h index fa701c6a92..105d874995 100644 --- a/erts/include/internal/ppc32/atomic.h +++ b/erts/include/internal/ppc32/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,7 @@ typedef struct { volatile int counter; } ethr_native_atomic_t; +#define ETHR_MEMORY_BARRIER __asm__ __volatile__("sync" : : : "memory") #ifdef ETHR_TRY_INLINE_FUNCS diff --git a/erts/include/internal/sparc32/atomic.h b/erts/include/internal/sparc32/atomic.h index d6fdc6b2a4..8fde449a52 100644 --- a/erts/include/internal/sparc32/atomic.h +++ b/erts/include/internal/sparc32/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% */ @@ -28,6 +28,10 @@ typedef struct { volatile long counter; } ethr_native_atomic_t; +#define ETHR_MEMORY_BARRIER \ + __asm__ __volatile__("membar #LoadLoad|#LoadStore|#StoreLoad|#StoreStore\n" \ + : : : "memory") + #ifdef ETHR_TRY_INLINE_FUNCS #if defined(__arch64__) diff --git a/erts/include/internal/tile/atomic.h b/erts/include/internal/tile/atomic.h index 59a9250e7c..5e4c7ac9fe 100644 --- a/erts/include/internal/tile/atomic.h +++ b/erts/include/internal/tile/atomic.h @@ -32,6 +32,8 @@ typedef struct { volatile long counter; } ethr_native_atomic_t; +#define ETHR_MEMORY_BARRIER __insn_mf() + #ifdef ETHR_TRY_INLINE_FUNCS static ETHR_INLINE void |