dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. 401a8d92ac96fd7b038f817b31e7c9f88607763b
Date: Sun, 07 Feb 2010 10:37:19 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  401a8d92ac96fd7b038f817b31e7c9f88607763b (commit)
      from  d9964b577b7d0d7748fbc95fb4abbec08867b310 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=401a8d92ac96fd7b038f817b31e7c9f88607763b

commit 401a8d92ac96fd7b038f817b31e7c9f88607763b
Author: Klaus Treichel <address@hidden>
Date:   Sun Feb 7 11:36:53 2010 +0100

    Replace the inlined backup versions for interlocked functions with not
    inlined versions and use more than one lock for protecting the accesses.

diff --git a/ChangeLog b/ChangeLog
index 2292a12..7d9eb15 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2010-02-07  Klaus Treichel  <address@hidden>
+
+       * support/interlocked.c: Move the previously inlined backup functions
+       from support/interlocked_any.h to this new file.
+
+       * support/interlocked.h: Add prototypes for the backup functions.
+
+       * support/interlocked_any.h: Move the backup functions to
+       support/interlocked.c and replace then with prototypes if they are 
needed
+       only conditionally (like 64bit versions on 32bit archs).
+
+       * support/Makefile.am: Add interlocked.c to the sources.
+
+       * support/thread.c (_ILThreadInit): Add initialization of the 
interlocked
+       operations.
+
 2010-01-31  Klaus Treichel  <address@hidden>
 
        * libffi/ChangeLog, libffi/Makefile.am: update to version 3.0.9
diff --git a/support/Makefile.am b/support/Makefile.am
index 7be03ec..b97ebee 100644
--- a/support/Makefile.am
+++ b/support/Makefile.am
@@ -31,6 +31,7 @@ libILSupport_a_SOURCES = aes.c \
                                                 hash.c \
                                                 hashtab.c \
                                                 hb_gc.c \
+                                                interlocked.c \
                                                 interlocked.h \
                                                 interlocked_any.h \
                                                 interlocked_arm.h \
diff --git a/support/interlocked.c b/support/interlocked.c
new file mode 100644
index 0000000..46d79d8
--- /dev/null
+++ b/support/interlocked.c
@@ -0,0 +1,522 @@
+/*
+ * interlocked.c - Implementation of interlocked functions.
+ *
+ * Copyright (C) 2010  Southern Storm Software, Pty Ltd.
+ *
+ * Authors: Klaus Treichel (address@hidden)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "thr_defs.h"
+#include "interlocked.h"
+
+/*
+ * The number of critical sections to be used or protecting interlocked
+ * operations.
+ * The number MUST be a power of 2
+ */
+#define _INTERLOCKED_NUM_LOCKS 16
+
+/*
+ * The static array of critical sections to be used
+ */
+static _ILCriticalSection _locks[_INTERLOCKED_NUM_LOCKS];
+
+/*
+ * Calculate the lock to be used from a pointer.
+ */
+#define _LOCK_HASH(dest) \
+       ((((ILNativeInt)(dest)) ^ (((ILNativeInt)(dest)) >> 12)) & \
+       (_INTERLOCKED_NUM_LOCKS - 1))
+
+#define _LOCK(dest) \
+       _ILCriticalSection *_lock; \
+       _lock = &(_locks[_LOCK_HASH(dest)]); \
+       _ILCriticalSectionEnter(_lock);
+
+#define _UNLOCK() \
+       _ILCriticalSectionLeave(_lock);
+
+/*
+ * Initialize the interlocked system.
+ */
+void ILInterlockedInit(void)
+{
+       int i;
+
+       for(i = 0; i < _INTERLOCKED_NUM_LOCKS; i++)
+       {
+               _ILCriticalSectionCreate(&(_locks[i]));
+       }
+}
+
+/*
+ * Flush cache and set a memory barrier.
+ */
+void _ILInterlockedMemoryBarrier()
+{
+       void *temp;
+       _LOCK(&temp);
+       _UNLOCK();
+}
+
+#if !defined(IL_NATIVE_INT64)
+/*
+ * Load a signed 64 bit value from a location.
+ */
+ILInt64 _ILInterlockedLoadI8_Full(const volatile ILInt64 *dest)
+{
+       ILInt64 result;
+
+       _LOCK(dest);
+
+       result = *dest;
+
+       _UNLOCK();
+
+       return result;
+}
+
+/*
+ * Load an unsigned 64 bit value from a location.
+ */
+ILUInt64 _ILInterlockedLoadU8_Full(const volatile ILUInt64 *dest)
+{
+       ILUInt64 result;
+
+       _LOCK(dest);
+
+       result = *dest;
+
+       _UNLOCK();
+
+       return result;
+}
+
+/*
+ * Load a double precision floatingpoint value from a location.
+ */
+ILDouble _ILInterlockedLoadR8_Full(const volatile ILDouble *dest)
+{
+       ILDouble result;
+
+       _LOCK(dest);
+
+       result = *dest;
+
+       _UNLOCK();
+
+       return result;
+}
+
+/*
+ * Store a signed 64 bit value to a location.
+ */
+void _ILInterlockedStoreI8_Full(volatile ILInt64 *dest, ILInt64 value)
+{
+       _LOCK(dest);
+
+       *dest = value;
+
+       _UNLOCK();
+}
+
+/*
+ * Store an unsigned 64 bit value to a location.
+ */
+void _ILInterlockedStoreU8_Full(volatile ILUInt64 *dest, ILUInt64 value)
+{
+       _LOCK(dest);
+
+       *dest = value;
+
+       _UNLOCK();
+}
+
+/*
+ * Store a double precision floatingpoint value to a location.
+ */
+void _ILInterlockedStoreR8_Full(volatile ILDouble *dest, ILDouble value)
+{
+       _LOCK(dest);
+
+       *dest = value;
+
+       _UNLOCK();
+}
+#endif /* !defined(IL_NATIVE_INT64) */
+
+/*
+ * Exchange signed 32 bit integers.
+ */
+ILInt32 _ILInterlockedExchangeI4_Full(volatile ILInt32 *dest, ILInt32 value)
+{
+       ILInt32 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Exchange unsigned 32 bit integers.
+ */
+ILUInt32 _ILInterlockedExchangeU4_Full(volatile ILUInt32 *dest, ILUInt32 value)
+{
+       ILUInt32 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Exchange signed 64 bit integers.
+ */
+ILInt64 _ILInterlockedExchangeI8_Full(volatile ILInt64 *dest, ILInt64 value)
+{
+       ILInt64 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Exchange unsigned 64 bit integers.
+ */
+ILUInt64 _ILInterlockedExchangeU8_Full(volatile ILUInt64 *dest, ILUInt64 value)
+{
+       ILUInt64 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Exchange pointers.
+ */
+void *_ILInterlockedExchangeP_Full(void * volatile *dest, void *value)
+{
+       void *retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Exchange 32 bit foatingpoint values.
+ */
+ILFloat _ILInterlockedExchangeR4_Full(volatile ILFloat *dest, ILFloat value)
+{
+       ILFloat retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Exchange 64 bit foatingpoint values.
+ */
+ILDouble _ILInterlockedExchangeR8_Full(volatile ILDouble *dest, ILDouble value)
+{
+       ILDouble retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+       *dest = value;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange signed 32 bit integers.
+ */
+ILInt32 _ILInterlockedCompareAndExchangeI4_Full(volatile ILInt32 *dest,
+                                                                               
                ILInt32 value,
+                                                                               
                ILInt32 comparand)
+{
+       ILInt32 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+
+       if (retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange unsigned 32 bit integers.
+ */
+ILUInt32 _ILInterlockedCompareAndExchangeU4_Full(volatile ILUInt32 *dest,
+                                                                               
                 ILUInt32 value,
+                                                                               
                 ILUInt32 comparand)
+{
+       ILUInt32 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+
+       if(retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange signed 64 bit integers.
+ */
+ILInt64 _ILInterlockedCompareAndExchangeI8_Full(volatile ILInt64 *dest,
+                                                                               
                ILInt64 value,
+                                                                               
                ILInt64 comparand)
+{
+       ILInt64 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+
+       if (retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange unsigned 64 bit integers.
+ */
+ILUInt64 _ILInterlockedCompareAndExchangeU8_Full(volatile ILUInt64 *dest,
+                                                                               
                 ILUInt64 value,
+                                                                               
                 ILUInt64 comparand)
+{
+       ILUInt64 retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+
+       if(retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange pointers.
+ */
+void *_ILInterlockedCompareAndExchangeP_Full(void * volatile *dest,
+                                                                               
         void *value,
+                                                                               
         void *comparand)
+{
+       void *retval;
+
+       _LOCK(dest);
+
+       retval = (void *)*dest;
+
+       if(retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange 32 bit floatingpoint values.
+ */
+ILFloat _ILInterlockedCompareAndExchangeR4_Full(volatile ILFloat *dest,
+                                                                               
                ILFloat value,
+                                                                               
                ILFloat comparand)
+{
+       ILFloat retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+
+       if(retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Compare and exchange 64 bit floatingpoint values.
+ */
+ILDouble _ILInterlockedCompareAndExchangeR8_Full(volatile ILDouble *dest,
+                                                                               
                 ILDouble value,
+                                                                               
                 ILDouble comparand)
+{
+       ILDouble retval;
+
+       _LOCK(dest);
+
+       retval = *dest;
+
+       if(retval == comparand)
+       {
+               *dest = value;
+       }
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Add two signed 32 bit integers.
+ */
+ILInt32 _ILInterlockedAddI4_Full(volatile ILInt32 *dest, ILInt32 value)
+{
+       ILInt32 retval;
+
+       _LOCK(dest);
+
+       retval = *dest + value;
+       *dest = retval;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Add two signed 64 bit integers.
+ */
+ILInt64 _ILInterlockedAddI8_Full(volatile ILInt64 *dest, ILInt64 value)
+{
+       ILInt64 retval;
+
+       _LOCK(dest);
+
+       retval = *dest + value;
+       *dest = retval;
+
+       _UNLOCK();
+
+       return retval;
+}
+
+/*
+ * Bitwise and two unsigned 32 bit integers.
+ */
+void _ILInterlockedAndU4_Full(volatile ILUInt32 *dest, ILUInt32 value)
+{
+       _LOCK(dest);
+
+       *dest &= value;
+
+       _UNLOCK();
+}
+
+/*
+ * Bitwise and two unsigned 64 bit integers.
+ */
+void _ILInterlockedAndU8_Full(volatile ILUInt64 *dest, ILUInt64 value)
+{
+       _LOCK(dest);
+
+       *dest &= value;
+
+       _UNLOCK();
+}
+
+/*
+ * Bitwise or two unsigned 32 bit integers.
+ */
+void _ILInterlockedOrU4_Full(volatile ILUInt32 *dest, ILUInt32 value)
+{
+       _LOCK(dest);
+
+       *dest |= value;
+
+       _UNLOCK();
+}
+
+/*
+ * Bitwise or two unsigned 64 bit integers.
+ */
+void _ILInterlockedOrU8_Full(volatile ILUInt64 *dest, ILUInt64 value)
+{
+       _LOCK(dest);
+
+       *dest |= value;
+
+       _UNLOCK();
+}
diff --git a/support/interlocked.h b/support/interlocked.h
index 0d673bb..1819090 100644
--- a/support/interlocked.h
+++ b/support/interlocked.h
@@ -1,7 +1,7 @@
 /*
  * interlocked.h - Implementation of interlocked functions.
  *
- * Copyright (C) 2002, 2009  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2002, 2009, 2010  Southern Storm Software, Pty Ltd.
  *
  * Authors: Thong Nguyen (address@hidden)
  *
@@ -210,6 +210,134 @@
 #define ILInterlockedCompilerBarrier
 #endif
 
+/*
+ * Initialize the interlocked system.
+ */
+void ILInterlockedInit(void);
+
+/*
+ * Backup functions if the operation is not supported by the processor.
+ */
+
+/*
+ * Flush cache and set a memory barrier.
+ */
+void _ILInterlockedMemoryBarrier();
+
+/*
+ * Exchange signed 32 bit integers.
+ */
+ILInt32 _ILInterlockedExchangeI4_Full(volatile ILInt32 *dest, ILInt32 value);
+
+/*
+ * Exchange unsigned 32 bit integers.
+ */
+ILUInt32 _ILInterlockedExchangeU4_Full(volatile ILUInt32 *dest, ILUInt32 
value);
+
+/*
+ * Exchange signed 64 bit integers.
+ */
+ILInt64 _ILInterlockedExchangeI8_Full(volatile ILInt64 *dest, ILInt64 value);
+
+/*
+ * Exchange unsigned 64 bit integers.
+ */
+ILUInt64 _ILInterlockedExchangeU8_Full(volatile ILUInt64 *dest, ILUInt64 
value);
+
+/*
+ * Exchange pointers.
+ */
+void *_ILInterlockedExchangeP_Full(void * volatile *dest, void *value);
+
+/*
+ * Exchange 32 bit foatingpoint values.
+ */
+ILFloat _ILInterlockedExchangeR4_Full(volatile ILFloat *dest, ILFloat value);
+
+/*
+ * Exchange 64 bit foatingpoint values.
+ */
+ILDouble _ILInterlockedExchangeR8_Full(volatile ILDouble *dest, ILDouble 
value);
+
+/*
+ * Compare and exchange signed 32 bit integers.
+ */
+ILInt32 _ILInterlockedCompareAndExchangeI4_Full(volatile ILInt32 *dest,
+                                                                               
                ILInt32 value,
+                                                                               
                ILInt32 comparand);
+
+/*
+ * Compare and exchange unsigned 32 bit integers.
+ */
+ILUInt32 _ILInterlockedCompareAndExchangeU4_Full(volatile ILUInt32 *dest,
+                                                                               
                 ILUInt32 value,
+                                                                               
                 ILUInt32 comparand);
+
+/*
+ * Compare and exchange signed 64 bit integers.
+ */
+ILInt64 _ILInterlockedCompareAndExchangeI8_Full(volatile ILInt64 *dest,
+                                                                               
                ILInt64 value,
+                                                                               
                ILInt64 comparand);
+
+/*
+ * Compare and exchange unsigned 64 bit integers.
+ */
+ILUInt64 _ILInterlockedCompareAndExchangeU8_Full(volatile ILUInt64 *dest,
+                                                                               
                 ILUInt64 value,
+                                                                               
                 ILUInt64 comparand);
+
+/*
+ * Compare and exchange pointers.
+ */
+void *_ILInterlockedCompareAndExchangeP_Full(void * volatile *dest,
+                                                                               
         void *value,
+                                                                               
         void *comparand);
+
+/*
+ * Compare and exchange 32 bit floatingpoint values.
+ */
+ILFloat _ILInterlockedCompareAndExchangeR4_Full(volatile ILFloat *dest,
+                                                                               
                ILFloat value,
+                                                                               
                ILFloat comparand);
+
+/*
+ * Compare and exchange 64 bit floatingpoint values.
+ */
+ILDouble _ILInterlockedCompareAndExchangeR8_Full(volatile ILDouble *dest,
+                                                                               
                 ILDouble value,
+                                                                               
                 ILDouble comparand);
+
+/*
+ * Add two signed 32 bit integers.
+ */
+ILInt32 _ILInterlockedAddI4_Full(volatile ILInt32 *dest, ILInt32 value);
+
+/*
+ * Add two signed 64 bit integers.
+ */
+ILInt64 _ILInterlockedAddI8_Full(volatile ILInt64 *dest, ILInt64 value);
+
+/*
+ * Bitwise and two unsigned 32 bit integers.
+ */
+void _ILInterlockedAndU4_Full(volatile ILUInt32 *dest, ILUInt32 value);
+
+/*
+ * Bitwise and two unsigned 64 bit integers.
+ */
+void _ILInterlockedAndU8_Full(volatile ILUInt64 *dest, ILUInt64 value);
+
+/*
+ * Bitwise or two unsigned 32 bit integers.
+ */
+void _ILInterlockedOrU4_Full(volatile ILUInt32 *dest, ILUInt32 value);
+
+/*
+ * Bitwise or two unsigned 64 bit integers.
+ */
+void _ILInterlockedOrU8_Full(volatile ILUInt64 *dest, ILUInt64 value);
+
 /* TODO: implement native interlocked functions for other processors */
 
 #include "interlocked_x86.h"
diff --git a/support/interlocked_any.h b/support/interlocked_any.h
index db4575b..4ea2b76 100644
--- a/support/interlocked_any.h
+++ b/support/interlocked_any.h
@@ -36,14 +36,7 @@ typedef union
 } ILInterlockedConv8;
 
 #if !defined(IL_HAVE_INTERLOCKED_MEMORYBARRIER)
-/*
- * Flush cache and set a memory barrier.
- */
-static IL_INLINE void ILInterlockedMemoryBarrier()
-{
-       ILThreadAtomicStart();
-       ILThreadAtomicEnd();
-}
+#define ILInterlockedMemoryBarrier() _ILInterlockedMemoryBarrier()
 #endif /* !defined(IL_HAVE_INTERLOCKED_MEMORYBARRIER) */
 
 /*
@@ -721,15 +714,18 @@ static IL_INLINE ILDouble _ILInterlockedLoadR8_Full(const 
volatile ILDouble *des
 /*
  * Load a signed 64 bit value from a location.
  */
-static IL_INLINE ILInt64 _ILInterlockedLoadI8_Full(const volatile ILInt64 
*dest)
-{
-       ILInt64 result;
+ILInt64 _ILInterlockedLoadI8_Full(const volatile ILInt64 *dest);
+
+/*
+ * Load an unsigned 64 bit value from a location.
+ */
+ILUInt64 _ILInterlockedLoadU8_Full(const volatile ILUInt64 *dest);
+
+/*
+ * Load a double precision floatingpoint value from a location.
+ */
+ILDouble _ILInterlockedLoadR8_Full(const volatile ILDouble *dest);
 
-       ILThreadAtomicStart();
-       result = *dest;
-       ILThreadAtomicEnd();
-       return result;
-}
 #if !defined(IL_HAVE_INTERLOCKED_LOADI8)
 #define ILInterlockedLoadI8(dest)      _ILInterlockedLoadI8_Full((dest))
 #endif /* !defined(IL_HAVE_INTERLOCKED_LOADI8) */
@@ -743,18 +739,6 @@ static IL_INLINE ILInt64 _ILInterlockedLoadI8_Full(const 
volatile ILInt64 *dest)
 #define ILInterlockedLoadI8_Full(dest) _ILInterlockedLoadI8_Full((dest))
 #endif /* !defined(IL_HAVE_INTERLOCKED_LOADI8_FULL) */
 
-/*
- * Load an unsigned 64 bit value from a location.
- */
-static IL_INLINE ILUInt64 _ILInterlockedLoadU8_Full(const volatile ILUInt64 
*dest)
-{
-       ILUInt64 result;
-
-       ILThreadAtomicStart();
-       result = *dest;
-       ILThreadAtomicEnd();
-       return result;
-}
 #if !defined(IL_HAVE_INTERLOCKED_LOADU8)
 #define ILInterlockedLoadU8(dest)      _ILInterlockedLoadU8_Full((dest))
 #endif /* !defined(IL_HAVE_INTERLOCKED_LOADU8) */
@@ -768,18 +752,6 @@ static IL_INLINE ILUInt64 _ILInterlockedLoadU8_Full(const 
volatile ILUInt64 *des
 #define ILInterlockedLoadU8_Full(dest) _ILInterlockedLoadU8_Full((dest))
 #endif /* !defined(IL_HAVE_INTERLOCKED_LOADU8_FULL) */
 
-/*
- * Load a double precision floatingpoint value from a location.
- */
-static IL_INLINE ILDouble _ILInterlockedLoadR8_Full(const volatile ILDouble 
*dest)
-{
-       ILDouble result;
-
-       ILThreadAtomicStart();
-       result = *dest;
-       ILThreadAtomicEnd();
-       return result;
-}
 #if !defined(IL_HAVE_INTERLOCKED_LOADR8)
 #define ILInterlockedLoadR8(dest)      _ILInterlockedLoadR8_Full((dest))
 #endif /* !defined(IL_HAVE_INTERLOCKED_LOADR8) */
@@ -1480,13 +1452,18 @@ static IL_INLINE void 
_ILInterlockedStoreR8_Full(volatile ILDouble *dest,
 /*
  * Store a signed 64 bit value to a location.
  */
-static IL_INLINE void _ILInterlockedStoreI8_Full(volatile ILInt64 *dest,
-                                                                               
                 ILInt64 value)
-{
-       ILThreadAtomicStart();
-       *dest = value;
-       ILThreadAtomicEnd();
-}
+void _ILInterlockedStoreI8_Full(volatile ILInt64 *dest, ILInt64 value);
+
+/*
+ * Store an unsigned 64 bit value to a location.
+ */
+void _ILInterlockedStoreU8_Full(volatile ILUInt64 *dest, ILUInt64 value);
+
+/*
+ * Store a double precision floatingpoint value to a location.
+ */
+void _ILInterlockedStoreR8_Full(volatile ILDouble *dest, ILDouble value);
+
 #if !defined(IL_HAVE_INTERLOCKED_STOREI8)
 #define ILInterlockedStoreI8(dest, value) \
                _ILInterlockedStoreI8_Full((dest), (value))
@@ -1504,16 +1481,6 @@ static IL_INLINE void 
_ILInterlockedStoreI8_Full(volatile ILInt64 *dest,
                _ILInterlockedStoreI8_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_STOREI8_FULL) */
 
-/*
- * Store an unsigned 64 bit value to a location.
- */
-static IL_INLINE void _ILInterlockedStoreU8_Full(volatile ILUInt64 *dest,
-                                                                               
                 ILUInt64 value)
-{
-       ILThreadAtomicStart();
-       *dest = value;
-       ILThreadAtomicEnd();
-}
 #if !defined(IL_HAVE_INTERLOCKED_STOREU8)
 #define ILInterlockedStoreU8(dest, value) \
                _ILInterlockedStoreU8_Full((dest), (value))
@@ -1531,16 +1498,6 @@ static IL_INLINE void 
_ILInterlockedStoreU8_Full(volatile ILUInt64 *dest,
                _ILInterlockedStoreU8_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_STOREU8_FULL) */
 
-/*
- * Store a double precision floatingpoint value to a location.
- */
-static IL_INLINE void _ILInterlockedStoreR8_Full(volatile ILDouble *dest,
-                                                                               
                 ILDouble value)
-{
-       ILThreadAtomicStart();
-       *dest = value;
-       ILThreadAtomicEnd();
-}
 #if !defined(IL_HAVE_INTERLOCKED_STORER8)
 #define ILInterlockedStoreR8(dest, value) \
                _ILInterlockedStoreR8_Full((dest), (value))
@@ -2265,20 +2222,6 @@ static IL_INLINE void *ILInterlockedExchangeP_Full(void 
* volatile *dest,
 /*
  * Exchange pointers.
  */
-static IL_INLINE void *_ILInterlockedExchangeP_Full(void * volatile *dest,
-                                                                               
                        void *value)
-{
-       void *retval;
-               
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       *dest = value;
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGEP)
 #define ILInterlockedExchangeP(dest, value) \
                _ILInterlockedExchangeP_Full((dest), (value))
@@ -4107,20 +4050,6 @@ static IL_INLINE void ILInterlockedOrU8_Full(volatile 
ILUInt64 *dest,
 /*
  * Backup declarations if no native implementation is available
  */
-static IL_INLINE ILInt32 _ILInterlockedExchangeI4_Full(volatile ILInt32 *dest,
-                                                                               
                           ILInt32 value)
-{
-       ILInt32 retval;
-
-       ILThreadAtomicStart();
-
-       retval = *dest;
-       *dest = value;
-
-       ILThreadAtomicEnd();
-
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGEI4)
 #define ILInterlockedExchangeI4(dest, value) \
                _ILInterlockedExchangeI4_Full((dest), (value))
@@ -4138,20 +4067,6 @@ static IL_INLINE ILInt32 
_ILInterlockedExchangeI4_Full(volatile ILInt32 *dest,
                _ILInterlockedExchangeI4_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGEI4_FULL) */
 
-static IL_INLINE ILUInt32 _ILInterlockedExchangeU4_Full(volatile ILUInt32 
*dest,
-                                                                               
                                ILUInt32 value)
-{
-       ILUInt32 retval;
-
-       ILThreadAtomicStart();
-
-       retval = *dest;
-       *dest = value;
-
-       ILThreadAtomicEnd();
-
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGEU4)
 #define ILInterlockedExchangeU4(dest, value) \
                _ILInterlockedExchangeU4_Full((dest), (value))
@@ -4169,20 +4084,6 @@ static IL_INLINE ILUInt32 
_ILInterlockedExchangeU4_Full(volatile ILUInt32 *dest,
                _ILInterlockedExchangeU4_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGEU4_FULL) */
 
-static IL_INLINE ILFloat _ILInterlockedExchangeR4_Full(volatile ILFloat *dest,
-                                                                               
                           ILFloat value)
-{
-       ILFloat retval;
-               
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       *dest = value;
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGER4)
 #define ILInterlockedExchangeR4(dest, value) \
                _ILInterlockedExchangeR4_Full((dest), (value))
@@ -4200,20 +4101,6 @@ static IL_INLINE ILFloat 
_ILInterlockedExchangeR4_Full(volatile ILFloat *dest,
                _ILInterlockedExchangeR4_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGER4_FULL) */
 
-static IL_INLINE ILInt64 _ILInterlockedExchangeI8_Full(volatile ILInt64 *dest,
-                                                                               
                           ILInt64 value)
-{
-       ILInt64 retval;
-
-       ILThreadAtomicStart();
-
-       retval = *dest;
-       *dest = value;
-
-       ILThreadAtomicEnd();
-
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGEI8)
 #define ILInterlockedExchangeI8(dest, value) \
                _ILInterlockedExchangeI8_Full((dest), (value))
@@ -4231,20 +4118,6 @@ static IL_INLINE ILInt64 
_ILInterlockedExchangeI8_Full(volatile ILInt64 *dest,
                _ILInterlockedExchangeI8_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGEI8_FULL) */
 
-static IL_INLINE ILUInt64 _ILInterlockedExchangeU8_Full(volatile ILUInt64 
*dest,
-                                                                               
                                ILUInt64 value)
-{
-       ILUInt64 retval;
-
-       ILThreadAtomicStart();
-
-       retval = *dest;
-       *dest = value;
-
-       ILThreadAtomicEnd();
-
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGEU8)
 #define ILInterlockedExchangeU8(dest, value) \
                _ILInterlockedExchangeU8_Full((dest), (value))
@@ -4262,20 +4135,6 @@ static IL_INLINE ILUInt64 
_ILInterlockedExchangeU8_Full(volatile ILUInt64 *dest,
                _ILInterlockedExchangeU8_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGEU8_FULL) */
 
-static IL_INLINE ILDouble _ILInterlockedExchangeR8_Full(volatile ILDouble 
*dest,
-                                                                               
                                ILDouble value)
-{
-       ILDouble retval;
-               
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       *dest = value;
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_EXCHANGER8)
 #define ILInterlockedExchangeR8(dest, value) \
                _ILInterlockedExchangeR8_Full((dest), (value))
@@ -4293,25 +4152,6 @@ static IL_INLINE ILDouble 
_ILInterlockedExchangeR8_Full(volatile ILDouble *dest,
                _ILInterlockedExchangeR8_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGER8_FULL) */
 
-static IL_INLINE ILInt32 _ILInterlockedCompareAndExchangeI4_Full(volatile 
ILInt32 *dest,
-                                                                               
                                                 ILInt32 value,
-                                                                               
                                                 ILInt32 comparand)
-{
-       ILInt32 retval;
-       
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       
-       if (retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEI4)
 #define ILInterlockedCompareAndExchangeI4(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeI4_Full((dest), (value), 
(comparand))
@@ -4329,25 +4169,6 @@ static IL_INLINE ILInt32 
_ILInterlockedCompareAndExchangeI4_Full(volatile ILInt3
                _ILInterlockedCompareAndExchangeI4_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEI4_FULL) */
 
-static IL_INLINE ILUInt32 _ILInterlockedCompareAndExchangeU4_Full(volatile 
ILUInt32 *dest,
-                                                                               
                                                  ILUInt32 value,
-                                                                               
                                                  ILUInt32 comparand)
-{
-       ILUInt32 retval;
-       
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       
-       if(retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEU4)
 #define ILInterlockedCompareAndExchangeU4(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeU4_Full((dest), (value), 
(comparand))
@@ -4365,25 +4186,6 @@ static IL_INLINE ILUInt32 
_ILInterlockedCompareAndExchangeU4_Full(volatile ILUIn
                _ILInterlockedCompareAndExchangeU4_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEU4_FULL) */
 
-static IL_INLINE ILFloat _ILInterlockedCompareAndExchangeR4_Full(volatile 
ILFloat *dest,
-                                                                               
                                                 ILFloat value,
-                                                                               
                                                 ILFloat comparand)
-{
-       ILFloat retval;
-       
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       
-       if(retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGER4)
 #define ILInterlockedCompareAndExchangeR4(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeR4_Full((dest), (value), 
(comparand))
@@ -4401,25 +4203,6 @@ static IL_INLINE ILFloat 
_ILInterlockedCompareAndExchangeR4_Full(volatile ILFloa
                _ILInterlockedCompareAndExchangeR4_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGER4_FULL) */
 
-static IL_INLINE ILInt32 _ILInterlockedCompareAndExchangeI8_Full(volatile 
ILInt64 *dest,
-                                                                               
                                                 ILInt64 value,
-                                                                               
                                                 ILInt64 comparand)
-{
-       ILInt64 retval;
-       
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       
-       if (retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEI8)
 #define ILInterlockedCompareAndExchangeI8(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeI8_Full((dest), (value), 
(comparand))
@@ -4437,25 +4220,6 @@ static IL_INLINE ILInt32 
_ILInterlockedCompareAndExchangeI8_Full(volatile ILInt6
                _ILInterlockedCompareAndExchangeI8_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEI8_FULL) */
 
-static IL_INLINE ILUInt64 _ILInterlockedCompareAndExchangeU8_Full(volatile 
ILUInt64 *dest,
-                                                                               
                                                  ILUInt64 value,
-                                                                               
                                                  ILUInt64 comparand)
-{
-       ILUInt64 retval;
-       
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       
-       if(retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEU8)
 #define ILInterlockedCompareAndExchangeU8(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeU8_Full((dest), (value), 
(comparand))
@@ -4473,25 +4237,6 @@ static IL_INLINE ILUInt64 
_ILInterlockedCompareAndExchangeU8_Full(volatile ILUIn
                _ILInterlockedCompareAndExchangeU8_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEU8_FULL) */
 
-static IL_INLINE ILDouble _ILInterlockedCompareAndExchangeR8_Full(volatile 
ILDouble *dest,
-                                                                               
                                                  ILDouble value,
-                                                                               
                                                  ILDouble comparand)
-{
-       ILDouble retval;
-       
-       ILThreadAtomicStart();
-       
-       retval = *dest;
-       
-       if(retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGER8)
 #define ILInterlockedCompareAndExchangeR8(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeR8_Full((dest), (value), 
(comparand))
@@ -4509,25 +4254,6 @@ static IL_INLINE ILDouble 
_ILInterlockedCompareAndExchangeR8_Full(volatile ILDou
                _ILInterlockedCompareAndExchangeR8_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGER8_FULL) */
 
-static IL_INLINE void *_ILInterlockedCompareAndExchangeP_Full(void * volatile 
*dest,
-                                                                               
                                          void *value,
-                                                                               
                                          void *comparand)
-{
-       void *retval;
-               
-       ILThreadAtomicStart();
-       
-       retval = (void *)*dest;
-       
-       if(retval == comparand)
-       {
-               *dest = value;
-       }
-       
-       ILThreadAtomicEnd();
-       
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEP)
 #define ILInterlockedCompareAndExchangeP(dest, value, comparand) \
                _ILInterlockedCompareAndExchangeP_Full((dest), (value), 
(comparand))
@@ -4545,20 +4271,6 @@ static IL_INLINE void 
*_ILInterlockedCompareAndExchangeP_Full(void * volatile *d
                _ILInterlockedCompareAndExchangeP_Full((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEP_FULL) */
 
-static IL_INLINE ILInt32 _ILInterlockedAddI4_Full(volatile ILInt32 *dest,
-                                                                               
                  ILInt32 value)
-{
-       ILInt32 retval;
-
-       ILThreadAtomicStart();
-
-       retval = *dest + value;
-       *dest = retval;
-
-       ILThreadAtomicEnd();
-
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_ADDI4)
 #define ILInterlockedAddI4(dest, value) \
                _ILInterlockedAddI4_Full((dest), (value))
@@ -4576,20 +4288,6 @@ static IL_INLINE ILInt32 
_ILInterlockedAddI4_Full(volatile ILInt32 *dest,
                _ILInterlockedAddI4_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_ADDI4_FULL) */
 
-static IL_INLINE ILInt64 _ILInterlockedAddI8_Full(volatile ILInt64 *dest,
-                                                                               
                  ILInt64 value)
-{
-       ILInt64 retval;
-
-       ILThreadAtomicStart();
-
-       retval = *dest + value;
-       *dest = retval;
-
-       ILThreadAtomicEnd();
-
-       return retval;
-}
 #if !defined(IL_HAVE_INTERLOCKED_ADDI8)
 #define ILInterlockedAddI8(dest, value) \
                _ILInterlockedAddI8_Full((dest), (value))
@@ -4709,15 +4407,6 @@ static IL_INLINE ILInt64 
_ILInterlockedAddI8_Full(volatile ILInt64 *dest,
                _ILInterlockedAddI8_Full((dest), -1)
 #endif /* !defined(IL_HAVE_INTERLOCKED_DECREMENTI8_FULL) */
 
-static IL_INLINE void _ILInterlockedAndU4_Full(volatile ILUInt32 *dest,
-                                                                               
           ILUInt32 value)
-{
-       ILThreadAtomicStart();
-
-       *dest &= value;
-
-       ILThreadAtomicEnd();
-}
 #if !defined(IL_HAVE_INTERLOCKED_ANDU4)
 #define ILInterlockedAndU4(dest, value) \
                _ILInterlockedAndU4_Full((dest), (value))
@@ -4735,15 +4424,6 @@ static IL_INLINE void _ILInterlockedAndU4_Full(volatile 
ILUInt32 *dest,
                _ILInterlockedAndU4_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_ANDU4_FULL) */
 
-static IL_INLINE void _ILInterlockedAndU8_Full(volatile ILUInt64 *dest,
-                                                                               
           ILUInt64 value)
-{
-       ILThreadAtomicStart();
-
-       *dest &= value;
-
-       ILThreadAtomicEnd();
-}
 #if !defined(IL_HAVE_INTERLOCKED_ANDU8)
 #define ILInterlockedAndU8(dest, value) \
                _ILInterlockedAndU8_Full((dest), (value))
@@ -4761,15 +4441,6 @@ static IL_INLINE void _ILInterlockedAndU8_Full(volatile 
ILUInt64 *dest,
                _ILInterlockedAndU8_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_ANDU8_FULL) */
 
-static IL_INLINE void _ILInterlockedOrU4_Full(volatile ILUInt32 *dest,
-                                                                               
          ILUInt32 value)
-{
-       ILThreadAtomicStart();
-
-       *dest |= value;
-
-       ILThreadAtomicEnd();
-}
 #if !defined(IL_HAVE_INTERLOCKED_ORU4)
 #define ILInterlockedOrU4(dest, value) \
                _ILInterlockedOrU4_Full((dest), (value))
@@ -4787,15 +4458,6 @@ static IL_INLINE void _ILInterlockedOrU4_Full(volatile 
ILUInt32 *dest,
                _ILInterlockedOrU4_Full((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_ORU4_FULL) */
 
-static IL_INLINE void _ILInterlockedOrU8_Full(volatile ILUInt64 *dest,
-                                                                               
          ILUInt64 value)
-{
-       ILThreadAtomicStart();
-
-       *dest |= value;
-
-       ILThreadAtomicEnd();
-}
 #if !defined(IL_HAVE_INTERLOCKED_ORU8)
 #define ILInterlockedOrU8(dest, value) \
                _ILInterlockedOrU8_Full((dest), (value))
diff --git a/support/thread.c b/support/thread.c
index 4324299..5f752ff 100644
--- a/support/thread.c
+++ b/support/thread.c
@@ -76,6 +76,9 @@ static void _ILThreadInit(void)
 {
        /* Initialize the main thread to all 0s */
        ILMemZero(&mainThread, sizeof(ILThread));
+
+       /* Initialize the atomic operations */
+       ILInterlockedInit();
        
        /* Perform system-specific initialization */
        _ILThreadInitSystem(&mainThread);

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 |   16 ++
 support/Makefile.am       |    1 +
 support/interlocked.c     |  522 +++++++++++++++++++++++++++++++++++++++++++++
 support/interlocked.h     |  130 +++++++++++-
 support/interlocked_any.h |  386 ++-------------------------------
 support/thread.c          |    3 +
 6 files changed, 695 insertions(+), 363 deletions(-)
 create mode 100644 support/interlocked.c


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]