---
name: "InterlockedCompareExchange"
section: "3w"
platform: "linux"
package: "libwine-dev"
version: "1.0.1-3.1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/InterlockedCompareExchange"
---

# InterlockedCompareExchange(3w)

## NAME

**InterlockedCompareExchange** (KERNEL32.@)

## SYNOPSIS

LONG InterlockedCompareExchange\
  (\
   LONG volatile\* *dest*,\
   LONG           *xchg*,\
   LONG           *compare*\
  )

## DESCRIPTION

Atomically swap one value with another.

## PARAMS

*dest* **\[In/Out\]**  The value to replace.

xchq **\[In\]**  The value to be swapped.

*compare* **\[In\]**  The value to *compare* to *dest*.

## RETURNS

The resulting value of *dest*.

## NOTES

*dest* is updated only if it is equal to *compare*, otherwise no swap is done.

## IMPLEMENTATION

Defined in **"winbase.h"**.

Implemented in **"dlls/kernel32/sync.c"**.

Debug channel **"sync"**.
