Move Interlocked* routines from ROSRTL to separate INTRLCK library since
ROSRTL is going to be removed.
Modified: trunk/reactos/lib/directory.xml
Added: trunk/reactos/lib/intrlck/
Added: trunk/reactos/lib/intrlck/intrlck.c
Added: trunk/reactos/lib/intrlck/intrlck.xml
Modified: trunk/reactos/lib/kernel32/kernel32.xml
Modified: trunk/reactos/lib/ntdll/ntdll.xml
Deleted: trunk/reactos/lib/rosrtl/misc/intrlck.c
Modified: trunk/reactos/lib/rosrtl/rosrtl.xml
Modified: trunk/reactos/subsys/csrss/csrss.xml
_____
Modified: trunk/reactos/lib/directory.xml
--- trunk/reactos/lib/directory.xml 2005-07-11 22:15:47 UTC (rev
16538)
+++ trunk/reactos/lib/directory.xml 2005-07-11 23:32:55 UTC (rev
16539)
@@ -91,6 +91,9 @@
<directory name="imm32">
<xi:include href="imm32/imm32.xml" />
</directory>
+<directory name="intrlck">
+ <xi:include href="intrlck/intrlck.xml" />
+</directory>
<directory name="iphlpapi">
<xi:include href="iphlpapi/iphlpapi.xml" />
</directory>
_____
Added: trunk/reactos/lib/intrlck/intrlck.c
--- trunk/reactos/lib/intrlck/intrlck.c 2005-07-11 22:15:47 UTC (rev
16538)
+++ trunk/reactos/lib/intrlck/intrlck.c 2005-07-11 23:32:55 UTC (rev
16539)
@@ -0,0 +1,209 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/ntdll/rtl/intrlck.c
+ * PURPOSE: Inter lock increments
+ * UPDATE HISTORY:
+ * Created 30/09/99
+ */
+
+/*
+ * Win32 kernel functions
+ *
+ * Copyright 1995 Martin von Loewis
+ * Copyright 1997 Onno Hovers
+ * 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
*
+*
*
+* InterlockedIncrement adds 1 to a long variable and returns
*
+* the resulting incremented value.
*
+*
*
+***********************************************************************
*/
+
+#include <windows.h>
+
+LONG
+STDCALL
+InterlockedIncrement(PLONG Addend)
+{
+ long ret;
+#ifdef _M_IX86
+ __asm__
+ (
+ "\tlock\n" /* for SMP systems */
+ "\txaddl %0, (%1)\n"
+ "\tincl %0\n"
+ :"=r" (ret)
+ :"r" (Addend), "0" (1)
+ : "memory"
+ );
+#elif defined(_M_PPC)
+ ret = *Addend;
+ ret = InterlockedExchangeAdd( Addend, ret + 1 );
+#else
+#error Unknown compiler for inline assembler
+#endif
+ return ret;
+}
+
+/**********************************************************************
**
+* InterlockedDecrement
*
+*
*
+* InterlockedDecrement adds -1 to a long variable and returns
*
+* the resulting decremented value.
*
+*
*
+***********************************************************************
*/
+
+LONG
+STDCALL
+InterlockedDecrement(LPLONG lpAddend)
+{
+ long ret;
+#ifdef _M_IX86
+ __asm__
+ (
+ "\tlock\n" /* for SMP systems */
+ "\txaddl %0, (%1)\n"
+ "\tdecl %0\n"
+ :"=r" (ret)
+ :"r" (lpAddend), "0" (-1)
+ : "memory"
+ );
+#elif defined(_M_PPC)
+ ret = *lpAddend;
+ ret = InterlockedExchangeAdd( lpAddend, ret - 1 );
+#else
+#error Unknown compiler for inline assembler
+#endif
+ return ret;
+
+
+}
+
+/**********************************************************************
**
+ * InterlockedExchange
+ *
+ * Atomically exchanges a pair of values.
+ *
+ * RETURNS
+ * Prior value of value pointed to by Target
+ */
+
+LONG
+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)
+ do {
+ ret = *(volatile LONG *)target;
+ } while( InterlockedCompareExchange( target, value, ret ) !=
ret );
+#else
+#error Unknown compiler for inline assembler
+#endif
+ return ret;
+}
+
+/**********************************************************************
**
+ * InterlockedCompareExchange
+ *
+ * Atomically compares Destination and Comperand, and if found equal
exchanges
+ * the value of Destination with Exchange
+ *
+ * RETURNS
+ * Prior value of value pointed to by Destination
+ */
+LONG
+STDCALL
+InterlockedCompareExchange(
+ LPLONG Destination,
+ LONG Exchange,
+ 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");
+#else
+#error Unknown compiler for inline assembler
+#endif
+ return ret;
+}
+
+/**********************************************************************
**
+ * InterlockedExchangeAdd
+ *
+ * Atomically adds Increment to Addend and returns the previous value
of
+ * Addend
+ *
+ * RETURNS
+ * Prior value of value pointed to by Addend
+ */
+LONG
+STDCALL
+InterlockedExchangeAdd(
+ PLONG Addend,
+ 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)
+ LONG newval;
+ do {
+ ret = *(volatile LONG *)Addend;
+ newval = ret + Increment;
+ } while (InterlockedCompareExchange(Addend, ret, newval) !=
ret);
+#else
+#error Unknown compiler for inline assembler
+#endif
+ return ret;
+}
_____
Added: trunk/reactos/lib/intrlck/intrlck.xml
--- trunk/reactos/lib/intrlck/intrlck.xml 2005-07-11 22:15:47 UTC
(rev 16538)
+++ trunk/reactos/lib/intrlck/intrlck.xml 2005-07-11 23:32:55 UTC
(rev 16539)
@@ -0,0 +1,4 @@
+<module name="intrlck" type="staticlibrary">
+ <define name="__USE_W32API" />
+ <file>intrlck.c</file>
+</module>
_____
Modified: trunk/reactos/lib/kernel32/kernel32.xml
--- trunk/reactos/lib/kernel32/kernel32.xml 2005-07-11 22:15:47 UTC
(rev 16538)
+++ trunk/reactos/lib/kernel32/kernel32.xml 2005-07-11 23:32:55 UTC
(rev 16539)
@@ -117,6 +117,7 @@
<library>kernel32_base</library>
<library>pseh</library>
<library>rosrtl</library>
+ <library>intrlck</library>
<library>ntdll</library>
<linkerflag>-lgcc</linkerflag>
<linkerflag>-nostartfiles</linkerflag>
_____
Modified: trunk/reactos/lib/ntdll/ntdll.xml
--- trunk/reactos/lib/ntdll/ntdll.xml 2005-07-11 22:15:47 UTC (rev
16538)
+++ trunk/reactos/lib/ntdll/ntdll.xml 2005-07-11 23:32:55 UTC (rev
16539)
@@ -9,6 +9,7 @@
<define name="_NTOSKRNL_" />
<library>rtl</library>
<library>rosrtl</library>
+ <library>intrlck</library>
<library>string</library>
<linkerflag>-lgcc</linkerflag>
<directory name="csr">
_____
Deleted: trunk/reactos/lib/rosrtl/misc/intrlck.c
--- trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-07-11 22:15:47 UTC
(rev 16538)
+++ trunk/reactos/lib/rosrtl/misc/intrlck.c 2005-07-11 23:32:55 UTC
(rev 16539)
@@ -1,209 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/ntdll/rtl/intrlck.c
- * PURPOSE: Inter lock increments
- * UPDATE HISTORY:
- * Created 30/09/99
- */
-
-/*
- * Win32 kernel functions
- *
- * Copyright 1995 Martin von Loewis
- * Copyright 1997 Onno Hovers
- * 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
*
-*
*
-* InterlockedIncrement adds 1 to a long variable and returns
*
-* the resulting incremented value.
*
-*
*
-***********************************************************************
*/
-
-#include <windows.h>
-
-LONG
-STDCALL
-InterlockedIncrement(PLONG Addend)
-{
- long ret;
-#ifdef _M_IX86
- __asm__
- (
- "\tlock\n" /* for SMP systems */
- "\txaddl %0, (%1)\n"
- "\tincl %0\n"
- :"=r" (ret)
- :"r" (Addend), "0" (1)
- : "memory"
- );
-#elif defined(_M_PPC)
- ret = *Addend;
- ret = InterlockedExchangeAdd( Addend, ret + 1 );
-#else
-#error Unknown compiler for inline assembler
-#endif
- return ret;
-}
-
-/**********************************************************************
**
-* InterlockedDecrement
*
-*
*
-* InterlockedDecrement adds -1 to a long variable and returns
*
-* the resulting decremented value.
*
-*
*
-***********************************************************************
*/
-
-LONG
-STDCALL
-InterlockedDecrement(LPLONG lpAddend)
-{
- long ret;
-#ifdef _M_IX86
- __asm__
- (
- "\tlock\n" /* for SMP systems */
- "\txaddl %0, (%1)\n"
- "\tdecl %0\n"
- :"=r" (ret)
- :"r" (lpAddend), "0" (-1)
- : "memory"
- );
-#elif defined(_M_PPC)
- ret = *lpAddend;
- ret = InterlockedExchangeAdd( lpAddend, ret - 1 );
-#else
-#error Unknown compiler for inline assembler
-#endif
- return ret;
-
-
-}
-
-/**********************************************************************
**
- * InterlockedExchange
- *
- * Atomically exchanges a pair of values.
- *
- * RETURNS
- * Prior value of value pointed to by Target
- */
-
-LONG
-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)
- do {
- ret = *(volatile LONG *)target;
- } while( InterlockedCompareExchange( target, value, ret ) !=
ret );
-#else
-#error Unknown compiler for inline assembler
-#endif
- return ret;
-}
-
-/**********************************************************************
**
- * InterlockedCompareExchange
- *
- * Atomically compares Destination and Comperand, and if found equal
exchanges
- * the value of Destination with Exchange
- *
- * RETURNS
- * Prior value of value pointed to by Destination
- */
-LONG
-STDCALL
-InterlockedCompareExchange(
- LPLONG Destination,
- LONG Exchange,
- 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");
-#else
-#error Unknown compiler for inline assembler
-#endif
- return ret;
-}
-
-/**********************************************************************
**
- * InterlockedExchangeAdd
- *
- * Atomically adds Increment to Addend and returns the previous value
of
- * Addend
- *
- * RETURNS
- * Prior value of value pointed to by Addend
- */
-LONG
-STDCALL
-InterlockedExchangeAdd(
- PLONG Addend,
- 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)
- LONG newval;
- do {
- ret = *(volatile LONG *)Addend;
- newval = ret + Increment;
- } while (InterlockedCompareExchange(Addend, ret, newval) !=
ret);
-#else
-#error Unknown compiler for inline assembler
-#endif
- return ret;
-}
_____
Modified: trunk/reactos/lib/rosrtl/rosrtl.xml
--- trunk/reactos/lib/rosrtl/rosrtl.xml 2005-07-11 22:15:47 UTC (rev
16538)
+++ trunk/reactos/lib/rosrtl/rosrtl.xml 2005-07-11 23:32:55 UTC (rev
16539)
@@ -5,7 +5,6 @@
</directory>
<directory name="misc">
<file>devmode.c</file>
- <file>intrlck.c</file>
<file>logfont.c</file>
<file>qsort.c</file>
</directory>
_____
Modified: trunk/reactos/subsys/csrss/csrss.xml
--- trunk/reactos/subsys/csrss/csrss.xml 2005-07-11 22:15:47 UTC
(rev 16538)
+++ trunk/reactos/subsys/csrss/csrss.xml 2005-07-11 23:32:55 UTC
(rev 16539)
@@ -4,7 +4,7 @@
<define name="__USE_W32API" />
<define name="_WIN32_WINNT">0x0600</define>
<define name="WINVER">0x0501</define>
- <library>rosrtl</library>
+ <library>intrlck</library>
<library>ntdll</library>
<library>smdll</library>
<directory name="api">