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. 304af73dcfdf26e127f331b0a3147b82118189fb
Date: Sun, 13 Sep 2009 15:32:03 +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  304af73dcfdf26e127f331b0a3147b82118189fb (commit)
      from  008e75c7ebc71eb4f36aa21d94b243d4fc52bdc3 (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=304af73dcfdf26e127f331b0a3147b82118189fb

commit 304af73dcfdf26e127f331b0a3147b82118189fb
Author: Klaus Treichel <address@hidden>
Date:   Sun Sep 13 17:31:42 2009 +0200

    Support the generic interlocked functions with a leading underscore even
    if an arch specific version is available.
    Fix a bug in the ILInterlockedExchange functions for x86 and x86_64.

diff --git a/ChangeLog b/ChangeLog
index 579649b..23ec8c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-09-13  Klaus Treichel  <address@hidden>
+
+       * support/interlocked.h: Add note about the interlocked functions
+       always available with a leading underscore using a mutex to protect
+       the value.
+
+       * support/interlocked_any.h: Change according to new note in
+       interlocked.h.
+
+       * support/interlocked_x86.h (ILInterlockedExchange,
+       ILInterlockedExchangePointers): Fix these two native implementatios to
+       use the xchg instead of the cmpxchg opcode.
+
 2009-09-12  Klaus Treichel  <address@hidden>
 
        * engine/lib_gc.c (GetGCHandleTable): Fix a bug where a thread could
diff --git a/support/interlocked.h b/support/interlocked.h
index 63580bc..ff8c2d0 100644
--- a/support/interlocked.h
+++ b/support/interlocked.h
@@ -115,6 +115,12 @@
  * define: IL_HAVE_INTERLOCKED_OR
  *
  * void ILInterlockedAnd(volatile ILUInt32 *dest, ILUInt32 value)
+ *
+ * NOTE: The versions using a mutex to protect the value are generally
+ * available with the same name and a leading underscore.
+ * This is to allow the usage of the version using the mutex even if a
+ * native version is available if propper protection requires the
+ * consistent availability of more than one interlocked function.
  */
 
 /* TODO: implement native interlocked functions for other processors */
diff --git a/support/interlocked_any.h b/support/interlocked_any.h
index a5a8808..9392931 100644
--- a/support/interlocked_any.h
+++ b/support/interlocked_any.h
@@ -31,12 +31,11 @@ static IL_INLINE void ILInterlockedMemoryBarrier()
 }
 #endif /* !defined(IL_HAVE_INTERLOCKED_MEMORYBARRIER) */
 
-#if !defined(IL_HAVE_INTERLOCKED_EXCHANGE)
 /*
  * Exchange integers.
  */
-static IL_INLINE ILInt32 ILInterlockedExchange(volatile ILInt32 *dest,
-                                                                               
           ILInt32 value)
+static IL_INLINE ILInt32 _ILInterlockedExchange(volatile ILInt32 *dest,
+                                                                               
                ILInt32 value)
 {
        ILInt32 retval;
 
@@ -49,14 +48,16 @@ static IL_INLINE ILInt32 ILInterlockedExchange(volatile 
ILInt32 *dest,
 
        return retval;
 }
+#if !defined(IL_HAVE_INTERLOCKED_EXCHANGE)
+#define ILInterlockedExchange(dest, value) \
+               _ILInterlockedExchange((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGE) */
 
-#if !defined(IL_HAVE_INTERLOCKED_EXCHANGEPOINTERS)
 /*
  * Exchange pointers.
  */
-static IL_INLINE void *ILInterlockedExchangePointers(void * volatile *dest,
-                                                                               
                         void *value)
+static IL_INLINE void *_ILInterlockedExchangePointers(void * volatile *dest,
+                                                                               
                          void *value)
 {
        void *retval;
                
@@ -69,15 +70,17 @@ static IL_INLINE void *ILInterlockedExchangePointers(void * 
volatile *dest,
        
        return retval;
 }
+#if !defined(IL_HAVE_INTERLOCKED_EXCHANGEPOINTERS)
+#define ILInterlockedExchangePointers(dest, value) \
+               _ILInterlockedExchangePointers((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_EXCHANGEPOINTERS) */
 
-#if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGE)
 /*
  * Compare and exchange two 32bit integers.
  */
-static IL_INLINE ILInt32 ILInterlockedCompareAndExchange(volatile ILInt32 
*dest,
-                                                                               
                                 ILInt32 value,
-                                                                               
                                 ILInt32 comparand)
+static IL_INLINE ILInt32 _ILInterlockedCompareAndExchange(volatile ILInt32 
*dest,
+                                                                               
                                  ILInt32 value,
+                                                                               
                                  ILInt32 comparand)
 {
        ILInt32 retval;
        
@@ -94,15 +97,17 @@ static IL_INLINE ILInt32 
ILInterlockedCompareAndExchange(volatile ILInt32 *dest,
        
        return retval;
 }
+#if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGE)
+#define ILInterlockedCompareAndExchange(dest, value, comparand) \
+               _ILInterlockedCompareAndExchange((dest), (value), (comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGE) */
 
-#if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEPOINTERS)
 /*
  * Compare and exchange two pointers.
  */
-static IL_INLINE void *ILInterlockedCompareAndExchangePointers(void * volatile 
*dest,
-                                                                               
                                           void *value,
-                                                                               
                                           void *comparand)
+static IL_INLINE void *_ILInterlockedCompareAndExchangePointers(void * 
volatile *dest,
+                                                                               
                                                void *value,
+                                                                               
                                                void *comparand)
 {
        void *retval;
                
@@ -119,14 +124,16 @@ static IL_INLINE void 
*ILInterlockedCompareAndExchangePointers(void * volatile *
        
        return retval;
 }
+#if !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEPOINTERS)
+#define ILInterlockedCompareAndExchangePointers(dest, value, comparand) \
+               _ILInterlockedCompareAndExchangePointers((dest), (value), 
(comparand))
 #endif /* !defined(IL_HAVE_INTERLOCKED_COMPAREANDEXCHANGEPOINTERS) */
 
-#if !defined(IL_HAVE_INTERLOCKED_ADD)
 /*
  * Add the two 32bit integers *dest and value and store the result at *dest.
  */
-static IL_INLINE ILInt32 ILInterlockedAdd(volatile ILInt32 *dest,
-                                                                               
  ILInt32 value)
+static IL_INLINE ILInt32 _ILInterlockedAdd(volatile ILInt32 *dest,
+                                                                               
   ILInt32 value)
 {
        ILInt32 retval;
 
@@ -139,44 +146,54 @@ static IL_INLINE ILInt32 ILInterlockedAdd(volatile 
ILInt32 *dest,
 
        return retval;  
 }
+#if !defined(IL_HAVE_INTERLOCKED_ADD)
+#define ILInterlockedAdd(dest, value)  _ILInterlockedAdd((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_ADD) */
 
-#if !defined(IL_HAVE_INTERLOCKED_SUB)
 /*
  * Subtract value from *dest and store the result at *dest.
  */
-#define ILInterlockedSub(dest, value)  ILInterlockedAdd((dest), -(value))
+#define _ILInterlockedSub(dest, value) _ILInterlockedAdd((dest), -(value))
+#if !defined(IL_HAVE_INTERLOCKED_SUB)
 #if defined(IL_HAVE_INTERLOCKED_ADD)
+#define ILInterlockedSub(dest, value)  ILInterlockedAdd((dest), -(value))
 #define IL_HAVE_INTERLOCKED_SUB 1
+#else
+#define ILInterlockedSub(dest, value)  _ILInterlockedSub((dest), (value))
 #endif
 #endif /* !defined(IL_HAVE_INTERLOCKED_SUB) */
 
-#if !defined(IL_HAVE_INTERLOCKED_INCREMENT)
 /*
  * Increment a 32bit integer.
  */
-#define ILInterlockedIncrement(dest) ILInterlockedAdd((dest), 1)
+#define _ILInterlockedIncrement(dest)  _ILInterlockedAdd((dest), 1)
+#if !defined(IL_HAVE_INTERLOCKED_INCREMENT)
 #if defined(IL_HAVE_INTERLOCKED_ADD)
+#define ILInterlockedIncrement(dest)   ILInterlockedAdd((dest), 1)
 #define IL_HAVE_INTERLOCKED_INCREMENT 1
+#else
+#define ILInterlockedIncrement(dest)   _ILInterlockedIncrement((dest))
 #endif
 #endif /* !defined(IL_HAVE_INTERLOCKED_INCREMENT) */
 
-#if !defined(IL_HAVE_INTERLOCKED_DECREMENT)
 /*
  * Decrement a 32bit integer.
  */
-#define ILInterlockedDecrement(dest)   ILInterlockedSub((dest), 1)
+#define _ILInterlockedDecrement(dest)  _ILInterlockedSub((dest), 1)
+#if !defined(IL_HAVE_INTERLOCKED_DECREMENT)
 #if defined(IL_HAVE_INTERLOCKED_SUB)
+#define ILInterlockedDecrement(dest)   ILInterlockedSub((dest), 1)
 #define IL_HAVE_INTERLOCKED_DECREMENT 1
+#else
+#define ILInterlockedDecrement(dest)   _ILInterlockedDecrement((dest))
 #endif
 #endif /* !defined(IL_HAVE_INTERLOCKED_DECREMENT) */
 
-#if !defined(IL_HAVE_INTERLOCKED_AND)
 /*
  * Atomic bitwise AND of unsigned 32 bit values
  */
-static IL_INLINE void ILInterlockedAnd(volatile ILUInt32 *dest,
-                                                                          
ILUInt32 value)
+static IL_INLINE void _ILInterlockedAnd(volatile ILUInt32 *dest,
+                                                                               
ILUInt32 value)
 {
        ILThreadAtomicStart();
 
@@ -184,14 +201,15 @@ static IL_INLINE void ILInterlockedAnd(volatile ILUInt32 
*dest,
 
        ILThreadAtomicEnd();
 }
+#if !defined(IL_HAVE_INTERLOCKED_AND)
+#define ILInterlockedAnd(dest, value)  _ILInterlockedAnd((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_AND) */
 
-#if !defined(IL_HAVE_INTERLOCKED_OR)
 /*
  * Atomic bitwise OR of unsigned 32 bit values
  */
-static IL_INLINE void ILInterlockedOr(volatile ILUInt32 *dest,
-                                                                         
ILUInt32 value)
+static IL_INLINE void _ILInterlockedOr(volatile ILUInt32 *dest,
+                                                                          
ILUInt32 value)
 {
        ILThreadAtomicStart();
 
@@ -199,4 +217,6 @@ static IL_INLINE void ILInterlockedOr(volatile ILUInt32 
*dest,
 
        ILThreadAtomicEnd();
 }
+#if !defined(IL_HAVE_INTERLOCKED_OR)
+#define ILInterlockedOr(dest, value)   _ILInterlockedOr((dest), (value))
 #endif /* !defined(IL_HAVE_INTERLOCKED_OR) */
diff --git a/support/interlocked_x86.h b/support/interlocked_x86.h
index c2f0e64..b723919 100644
--- a/support/interlocked_x86.h
+++ b/support/interlocked_x86.h
@@ -58,12 +58,10 @@ static IL_INLINE ILInt32 ILInterlockedExchange(volatile 
ILInt32 *dest,
 
        __asm__ __volatile__ 
        (
-               "1:;"
-               "lock;"
-               "cmpxchgl %2, %0;"
-               "jne 1b"
-               : "=m" (*dest), "=a" (retval)
-               : "r" (value), "m" (*dest), "a" (*dest)
+               "xchgl %2, %0;"
+               : "=m" (*dest), "=r" (retval)
+               : "1" (value), "m" (*dest)
+               : "memory"
        );
 
        return retval;
@@ -80,16 +78,14 @@ static IL_INLINE void *ILInterlockedExchangePointers(void * 
volatile *dest,
 
        __asm__ __volatile__ 
        (
-               "1:;"
-               "lock;"
 #if defined(__x86_64__)
-               "cmpxchgq %2, %0;"
+               "xchgq %2, %0;"
 #else
-               "cmpxchgl %2, %0;"
+               "xchgl %2, %0;"
 #endif
-               "jne 1b"
-               : "=m" (*dest), "=a" (retval)
-               : "r" (value), "m" (*dest), "a" (*dest)
+               : "=m" (*dest), "=r" (retval)
+               : "1" (value), "m" (*dest)
+               : "memory"
        );
 
        return retval;

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

Summary of changes:
 ChangeLog                 |   13 +++++++
 support/interlocked.h     |    6 +++
 support/interlocked_any.h |   78 ++++++++++++++++++++++++++++-----------------
 support/interlocked_x86.h |   22 +++++-------
 4 files changed, 77 insertions(+), 42 deletions(-)


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




reply via email to

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