Last fix due to w3seek. I will stop working on this stuff until I have
time to be thorough.
Modified: trunk/reactos/lib/rosrtl/misc/intrlck.c
_____
Modified: trunk/reactos/lib/rosrtl/misc/intrlck.c
--- trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-03-08 23:01:54 UTC
(rev 13892)
+++ trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-03-08 23:07:10 UTC
(rev 13893)
@@ -136,8 +136,9 @@
"lock\n\txchgl %0,(%1)"
:"=r" (ret):"r" (target), "0" (value):"memory" );
#elif defined(_M_PPC)
- ret = *(volatile LONG *)target;
- while( InterlockedCompareExchange( target, value, ret ) != ret
);
+ do {
+ ret = *(volatile LONG *)target;
+ } while( InterlockedCompareExchange( target, value, ret ) !=
ret );
#endif
return ret;
}
Fixes by w3seek regarding interlocked functions. These were due to my
missing a mismatch between the glib functions and windows variants.
Modified: trunk/reactos/lib/rosrtl/misc/intrlck.c
_____
Modified: trunk/reactos/lib/rosrtl/misc/intrlck.c
--- trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-03-08 22:41:27 UTC
(rev 13891)
+++ trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-03-08 23:01:54 UTC
(rev 13892)
@@ -136,8 +136,8 @@
"lock\n\txchgl %0,(%1)"
:"=r" (ret):"r" (target), "0" (value):"memory" );
#elif defined(_M_PPC)
- ret = *target;
- while( InterlockedCompareExchange( target, value, ret ) !=
value );
+ ret = *(volatile LONG *)target;
+ while( InterlockedCompareExchange( target, value, ret ) != ret
);
#endif
return ret;
}
@@ -202,9 +202,11 @@
:"r" (Addend), "0" (Increment)
:"memory" );
#elif defined(_M_PPC)
- do
- ret = *Addend;
- while (!InterlockedCompareExchange(Addend, ret, ret +
Increment));
+ LONG newval;
+ do {
+ ret = *(volatile LONG *)Addend;
+ newval = ret + Increment;
+ } while (InterlockedCompareExchange(Addend, ret, newval) !=
ret);
#endif
return ret;
}
Added PowerPC interlocked functions from glib.
Modified: trunk/reactos/lib/rosrtl/misc/intrlck.c
_____
Modified: trunk/reactos/lib/rosrtl/misc/intrlck.c
--- trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-03-08 21:02:50 UTC
(rev 13889)
+++ trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-03-08 22:39:53 UTC
(rev 13890)
@@ -15,6 +15,29 @@
* Copied from kernel32
*/
+/* PowerPC Functions from gatomic.c in glib
+ *
+ * GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh
MacDonald
+ *
+ * g_atomic_*: atomic operations.
+ * Copyright (C) 2003 Sebastian Wilhelmi
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
/***********************************************************************
*
* InterlockedIncrement
*
@@ -36,6 +59,7 @@
InterlockedIncrement(PLONG Addend)
{
long ret = 0;
+#ifdef _M_IX86
__asm__
(
"\tlock\n" /* for SMP systems */
@@ -48,6 +72,10 @@
"2:\n"
:"=r" (ret):"r" (Addend), "0" (0): "memory"
);
+#elif defined(_M_PPC)
+ ret = *Addend;
+ ret = InterlockedExchangeAdd( Addend, ret + 1 );
+#endif
return ret;
}
@@ -67,6 +95,7 @@
InterlockedDecrement(LPLONG lpAddend)
{
long ret;
+#ifdef _M_IX86
__asm__
(
"\tlock\n" /* for SMP systems */
@@ -79,6 +108,10 @@
"2:\n"
:"=r" (ret):"r" (lpAddend), "0" (0): "memory"
);
+#elif defined(_M_PPC)
+ ret = *lpAddend;
+ ret = InterlockedExchangeAdd( lpAddend, ret - 1 );
+#endif
return ret;
@@ -97,14 +130,16 @@
STDCALL
InterlockedExchange(LPLONG target, LONG value )
{
-
long ret;
+#ifdef _M_IX86
__asm__ ( /* lock for SMP systems */
"lock\n\txchgl %0,(%1)"
:"=r" (ret):"r" (target), "0" (value):"memory" );
+#elif defined(_M_PPC)
+ ret = *target;
+ while( InterlockedCompareExchange( target, value, ret ) !=
value );
+#endif
return ret;
-
-
}
/***********************************************************************
*
@@ -124,8 +159,21 @@
LONG Comperand )
{
LONG ret;
+#ifdef _M_IX86
__asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
: "=a" (ret) : "r" (Destination), "r"
(Exchange), "0" (Comperand) : "memory" );
+#elif defined(_M_PPC)
+ __asm__ __volatile__ ("sync\n"
+ "1: lwarx %0,0,%1\n"
+ " subf. %0,%2,%0\n"
+ " bne 2f\n"
+ " stwcx. %3,0,%1\n"
+ " bne- 1b\n"
+ "2: isync"
+ : "=&r" (ret)
+ : "b" (Destination), "r" (Comperand), "r"
(Exchange)
+ : "cr0", "memory");
+#endif
return ret;
}
@@ -145,14 +193,18 @@
LONG Increment
)
{
-
LONG ret;
+#ifdef _M_IX86
__asm__ ( /* lock for SMP systems */
"lock\n\t"
"xaddl %0,(%1)"
:"=r" (ret)
:"r" (Addend), "0" (Increment)
:"memory" );
+#elif defined(_M_PPC)
+ do
+ ret = *Addend;
+ while (!InterlockedCompareExchange(Addend, ret, ret +
Increment));
+#endif
return ret;
-
}
add newline at EOF to suppress warning
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/pch_detection
.h
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/pch_detection
.h
---
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/pch_detection
.h 2005-03-08 20:40:35 UTC (rev 13887)
+++
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/pch_detection
.h 2005-03-08 20:50:42 UTC (rev 13888)
@@ -1 +1 @@
-// this file is intentionally left empty
\ No newline at end of file
+// this file is intentionally left empty