mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 05:22:57 +00:00
Moved interlocked function to rosrtl rather than exporting them from ntdll as windows does not export them from there.
svn path=/trunk/; revision=10815
This commit is contained in:
parent
d0cbef2f9f
commit
bd82ff9f5e
6 changed files with 165 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.def,v 1.127 2004/08/11 09:30:23 ekohl Exp $
|
; $Id: ntdll.def,v 1.128 2004/09/10 23:29:18 sedwards Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -32,10 +32,6 @@ DbgUiIssueRemoteBreakin@4
|
||||||
DbgUiRemoteBreakin@0
|
DbgUiRemoteBreakin@0
|
||||||
DbgUiWaitStateChange@8
|
DbgUiWaitStateChange@8
|
||||||
DbgUserBreakPoint@0
|
DbgUserBreakPoint@0
|
||||||
InterlockedIncrement@4
|
|
||||||
InterlockedDecrement@4
|
|
||||||
InterlockedExchange@8
|
|
||||||
InterlockedCompareExchange@12
|
|
||||||
KiRaiseUserExceptionDispatcher
|
KiRaiseUserExceptionDispatcher
|
||||||
KiUserApcDispatcher
|
KiUserApcDispatcher
|
||||||
KiUserCallbackDispatcher
|
KiUserCallbackDispatcher
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.edf,v 1.117 2004/08/11 09:30:23 ekohl Exp $
|
; $Id: ntdll.edf,v 1.118 2004/09/10 23:29:18 sedwards Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -32,10 +32,6 @@ DbgUiIssueRemoteBreakin=DbgUiIssueRemoteBreakin@4
|
||||||
DbgUiRemoteBreakin=DbgUiRemoteBreakin@0
|
DbgUiRemoteBreakin=DbgUiRemoteBreakin@0
|
||||||
DbgUiWaitStateChange=DbgUiWaitStateChange@8
|
DbgUiWaitStateChange=DbgUiWaitStateChange@8
|
||||||
DbgUserBreakPoint=DbgUserBreakPoint@0
|
DbgUserBreakPoint=DbgUserBreakPoint@0
|
||||||
InterlockedIncrement=InterlockedIncrement@4
|
|
||||||
InterlockedDecrement=InterlockedDecrement@4
|
|
||||||
InterlockedExchange=InterlockedExchange@8
|
|
||||||
InterlockedCompareExchange=InterlockedCompareExchange@12
|
|
||||||
KiRaiseUserExceptionDispatcher=KiRaiseUserExceptionDispatcher@0
|
KiRaiseUserExceptionDispatcher=KiRaiseUserExceptionDispatcher@0
|
||||||
KiUserApcDispatcher=KiUserApcDispatcher@20
|
KiUserApcDispatcher=KiUserApcDispatcher@20
|
||||||
KiUserCallbackDispatcher=KiUserCallbackDispatcher@12
|
KiUserCallbackDispatcher=KiUserCallbackDispatcher@12
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.108 2004/08/10 12:03:29 ekohl Exp $
|
# $Id: makefile,v 1.109 2004/09/10 23:29:18 sedwards Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ RTL_OBJECTS = \
|
||||||
rtl/dbgbuffer.o \
|
rtl/dbgbuffer.o \
|
||||||
rtl/exception.o \
|
rtl/exception.o \
|
||||||
rtl/handle.o \
|
rtl/handle.o \
|
||||||
rtl/intrlck.o \
|
|
||||||
rtl/math.o \
|
rtl/math.o \
|
||||||
rtl/message.o \
|
rtl/message.o \
|
||||||
rtl/misc.o \
|
rtl/misc.o \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.14 2004/08/11 08:28:13 weiden Exp $
|
# $Id: makefile,v 1.15 2004/09/10 23:29:07 sedwards Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ REGISTRY_OBJECTS = \
|
||||||
|
|
||||||
MISC_OBJECTS = \
|
MISC_OBJECTS = \
|
||||||
misc/devmode.o \
|
misc/devmode.o \
|
||||||
|
misc/intrlck.o \
|
||||||
misc/logfont.o \
|
misc/logfont.o \
|
||||||
misc/qsort.o
|
misc/qsort.o
|
||||||
|
|
||||||
|
|
158
reactos/lib/rosrtl/misc/intrlck.c
Normal file
158
reactos/lib/rosrtl/misc/intrlck.c
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* InterlockedIncrement *
|
||||||
|
* *
|
||||||
|
* InterlockedIncrement adds 1 to a long variable and returns *
|
||||||
|
* - a negative number if the result < 0 *
|
||||||
|
* - zero if the result == 0 *
|
||||||
|
* - a positive number if the result > 0 *
|
||||||
|
* *
|
||||||
|
* The returned number need not be equal to the result!!!! *
|
||||||
|
* note: *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
InterlockedIncrement(PLONG Addend)
|
||||||
|
{
|
||||||
|
long ret = 0;
|
||||||
|
__asm__
|
||||||
|
(
|
||||||
|
"\tlock\n" /* for SMP systems */
|
||||||
|
"\tincl (%1)\n"
|
||||||
|
"\tje 2f\n"
|
||||||
|
"\tjl 1f\n"
|
||||||
|
"\tincl %0\n"
|
||||||
|
"\tjmp 2f\n"
|
||||||
|
"1:\tdec %0\n"
|
||||||
|
"2:\n"
|
||||||
|
:"=r" (ret):"r" (Addend), "0" (0): "memory"
|
||||||
|
);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* InterlockedDecrement *
|
||||||
|
* *
|
||||||
|
* InterlockedIncrement adds 1 to a long variable and returns *
|
||||||
|
* - a negative number if the result < 0 *
|
||||||
|
* - zero if the result == 0 *
|
||||||
|
* - a positive number if the result > 0 *
|
||||||
|
* *
|
||||||
|
* The returned number need not be equal to the result!!!! *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
LONG
|
||||||
|
STDCALL
|
||||||
|
InterlockedDecrement(LPLONG lpAddend)
|
||||||
|
{
|
||||||
|
long ret;
|
||||||
|
__asm__
|
||||||
|
(
|
||||||
|
"\tlock\n" /* for SMP systems */
|
||||||
|
"\tdecl (%1)\n"
|
||||||
|
"\tje 2f\n"
|
||||||
|
"\tjl 1f\n"
|
||||||
|
"\tincl %0\n"
|
||||||
|
"\tjmp 2f\n"
|
||||||
|
"1:\tdec %0\n"
|
||||||
|
"2:\n"
|
||||||
|
:"=r" (ret):"r" (lpAddend), "0" (0): "memory"
|
||||||
|
);
|
||||||
|
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;
|
||||||
|
__asm__ ( /* lock for SMP systems */
|
||||||
|
"lock\n\txchgl %0,(%1)"
|
||||||
|
:"=r" (ret):"r" (target), "0" (value):"memory" );
|
||||||
|
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;
|
||||||
|
__asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
|
||||||
|
: "=a" (ret) : "r" (Destination), "r" (Exchange), "0" (Comperand) : "memory" );
|
||||||
|
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;
|
||||||
|
__asm__ ( /* lock for SMP systems */
|
||||||
|
"lock\n\t"
|
||||||
|
"xaddl %0,(%1)"
|
||||||
|
:"=r" (ret)
|
||||||
|
:"r" (Addend), "0" (Increment)
|
||||||
|
:"memory" );
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.30 2004/07/12 20:09:34 gvg Exp $
|
# $Id: makefile,v 1.31 2004/09/10 23:29:28 sedwards Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue