blob: 2b0fadd88dd146d400d922aed72804db8132504e [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301#include <Library/DebugLib.h>
2#include "InterlockedCompareExchange16.h"
3
4/**
5 Performs an atomic compare exchange operation on a 16-bit unsigned integer.
6
7 Performs an atomic compare exchange operation on the 16-bit unsigned integer
8 specified by Value. If Value is equal to CompareValue, then Value is set to
9 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
10 then Value is returned. The compare exchange operation must be performed using
11 MP safe mechanisms.
12
13 If Value is NULL, then ASSERT().
14
15 @param Value A pointer to the 16-bit value for the compare exchange
16 operation.
17 @param CompareValue 16-bit value used in compare operation.
18 @param ExchangeValue 16-bit value used in exchange operation.
19
20 @return The original *Value before exchange.
21
22**/
23UINT16
24EFIAPI
25InterlockedCompareExchange16 (
26 IN OUT UINT16 *Value,
27 IN UINT16 CompareValue,
28 IN UINT16 ExchangeValue
29 )
30{
31 ASSERT (Value != NULL);
32 return InternalSyncCompareExchange16 (Value, CompareValue, ExchangeValue);
33}