📄 compareexchange.c
字号:
/*
* PROJECT: ReactOS system libraries
* LICENSE: GPL - See COPYING in the top level directory
* FILE: lib/intrlck/i386/compareexchange.c
* PURPOSE: Inter lock compare exchanges
* PROGRAMMERS: Copyright 1995 Martin von Loewis
* Copyright 1997 Onno Hovers
*/
/************************************************************************
* 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 NTAPI InterlockedCompareExchange(LPLONG Destination, LONG Exchange, LONG Comperand)
*/
#include <windows.h>
LONG
NTAPI
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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -