implement interlocked* functions on Alpha AXP

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

 



Hello,
I know nothing about this except what I have learned in the past 4
hours
so.........

After looking at the interlocked code and reading how
PEACE and Mono implement these functions I think this will work. This
is assuming that the SUN code for implementing this is compatible with 
pthreads. I only get one warrning about a cast in interlocked_xchg_ptr 
so I assume I am on the right track with this. I have not done any work
at this low level before so is there was something wrong with using 
pthreads here? I am not worried about breaking compatiblity with
exsting
Win32/64 AXP apps as there are few left.

Changlog: Implement interlocked* function for the Alpha CPU

Index: wine/libs/port/interlocked.c
===================================================================
RCS file: /home/wine/wine/libs/port/interlocked.c,v
retrieving revision 1.3
diff -u -r1.3 interlocked.c
--- wine/libs/port/interlocked.c        2 Jul 2003 04:29:33 -0000      
1.3
+++ wine/libs/port/interlocked.c        20 Sep 2003 02:07:04 -0000
@@ -244,6 +244,65 @@
     _lwp_mutex_unlock( &interlocked_mutex );
     return retv;
 }
+
+#elif defined(__ALPHA__) || defined(__AXP__)
+/* This code was adapted from the Sparc port. After checking
+ * the way Mono and PEACE implement interlocked functions on
+ * pthreads I think it will work.
+ */
+#include <pthread.h>
+
+static pthread_mutex_t interlocked_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+long interlocked_cmpxchg( long *dest, long xchg, long compare )
+{
+    pthread_mutex_lock( &interlocked_mutex );
+    if (*dest == compare) *dest = xchg;
+    else compare = *dest;
+    pthread_mutex_unlock( &interlocked_mutex );
+    return compare;
+}
+
+void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare
)
+{
+    pthread_mutex_lock( &interlocked_mutex );
+    if (*dest == compare) *dest = xchg;
+    else compare = *dest;
+    pthread_mutex_unlock( &interlocked_mutex );
+    return compare;
+}
+
+long interlocked_xchg( long *dest, long val )
+{
+    long retv;
+    pthread_mutex_lock( &interlocked_mutex );
+    retv = *dest;
+    *dest = val;
+    pthread_mutex_unlock( &interlocked_mutex );
+    return retv;
+}
+
+void *interlocked_xchg_ptr( void **dest, void *val )
+{
+    long retv;
+    pthread_mutex_lock( &interlocked_mutex );
+    retv = *dest;
+    *dest = val;
+    pthread_mutex_unlock( &interlocked_mutex );
+    return retv;
+}
+
+long interlocked_xchg_add( long *dest, long incr )
+{
+    long retv;
+    pthread_mutex_lock( &interlocked_mutex );
+    retv = *dest;
+    *dest += incr;
+    pthread_mutex_unlock( &interlocked_mutex );
+    return retv;
+}
+
 #else
 # error You must implement the interlocked* functions for your CPU
 #endif
+


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux