---
name: "rte_atomic.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_atomic.h"
---

# rte\_atomic.h(3)

## NAME

rte\_atomic.h

## SYNOPSIS

`#include <stdint.h>`\
 `#include <rte_common.h>`\
 `#include <rte_stdatomic.h>`\

### Data Structures

struct **rte\_atomic16\_t**\
 struct **rte\_atomic32\_t**\
 struct **rte\_atomic64\_t**\

### Macros

\#define **rte\_compiler\_barrier**()\
 \#define **RTE\_ATOMIC16\_INIT**(val)   { (val) }\
 \#define **RTE\_ATOMIC32\_INIT**(val)   { (val) }\
 \#define **RTE\_ATOMIC64\_INIT**(val)   { (val) }\

### Functions

static void **rte\_atomic\_thread\_fence** (rte\_memory\_order memorder)\
 static int **rte\_atomic16\_cmpset** (volatile uint16\_t \*dst, uint16\_t exp, uint16\_t src)\
 static uint16\_t **rte\_atomic16\_exchange** (volatile uint16\_t \*dst, uint16\_t val)\
 static void **rte\_atomic16\_init** (**rte\_atomic16\_t** \*v)\
 static int16\_t **rte\_atomic16\_read** (const **rte\_atomic16\_t** \*v)\
 static void **rte\_atomic16\_set** (**rte\_atomic16\_t** \*v, int16\_t new\_value)\
 static void **rte\_atomic16\_add** (**rte\_atomic16\_t** \*v, int16\_t inc)\
 static void **rte\_atomic16\_sub** (**rte\_atomic16\_t** \*v, int16\_t dec)\
 static void **rte\_atomic16\_inc** (**rte\_atomic16\_t** \*v)\
 static void **rte\_atomic16\_dec** (**rte\_atomic16\_t** \*v)\
 static int16\_t **rte\_atomic16\_add\_return** (**rte\_atomic16\_t** \*v, int16\_t inc)\
 static int16\_t **rte\_atomic16\_sub\_return** (**rte\_atomic16\_t** \*v, int16\_t dec)\
 static int **rte\_atomic16\_inc\_and\_test** (**rte\_atomic16\_t** \*v)\
 static int **rte\_atomic16\_dec\_and\_test** (**rte\_atomic16\_t** \*v)\
 static int **rte\_atomic16\_test\_and\_set** (**rte\_atomic16\_t** \*v)\
 static void **rte\_atomic16\_clear** (**rte\_atomic16\_t** \*v)\
 static int **rte\_atomic32\_cmpset** (volatile uint32\_t \*dst, uint32\_t exp, uint32\_t src)\
 static uint32\_t **rte\_atomic32\_exchange** (volatile uint32\_t \*dst, uint32\_t val)\
 static void **rte\_atomic32\_init** (**rte\_atomic32\_t** \*v)\
 static int32\_t **rte\_atomic32\_read** (const **rte\_atomic32\_t** \*v)\
 static void **rte\_atomic32\_set** (**rte\_atomic32\_t** \*v, int32\_t new\_value)\
 static void **rte\_atomic32\_add** (**rte\_atomic32\_t** \*v, int32\_t inc)\
 static void **rte\_atomic32\_sub** (**rte\_atomic32\_t** \*v, int32\_t dec)\
 static void **rte\_atomic32\_inc** (**rte\_atomic32\_t** \*v)\
 static void **rte\_atomic32\_dec** (**rte\_atomic32\_t** \*v)\
 static int32\_t **rte\_atomic32\_add\_return** (**rte\_atomic32\_t** \*v, int32\_t inc)\
 static int32\_t **rte\_atomic32\_sub\_return** (**rte\_atomic32\_t** \*v, int32\_t dec)\
 static int **rte\_atomic32\_inc\_and\_test** (**rte\_atomic32\_t** \*v)\
 static int **rte\_atomic32\_dec\_and\_test** (**rte\_atomic32\_t** \*v)\
 static int **rte\_atomic32\_test\_and\_set** (**rte\_atomic32\_t** \*v)\
 static void **rte\_atomic32\_clear** (**rte\_atomic32\_t** \*v)\
 static int **rte\_atomic64\_cmpset** (volatile uint64\_t \*dst, uint64\_t exp, uint64\_t src)\
 static uint64\_t **rte\_atomic64\_exchange** (volatile uint64\_t \*dst, uint64\_t val)\
 static void **rte\_atomic64\_init** (**rte\_atomic64\_t** \*v)\
 static int64\_t **rte\_atomic64\_read** (**rte\_atomic64\_t** \*v)\
 static void **rte\_atomic64\_set** (**rte\_atomic64\_t** \*v, int64\_t new\_value)\
 static void **rte\_atomic64\_add** (**rte\_atomic64\_t** \*v, int64\_t inc)\
 static void **rte\_atomic64\_sub** (**rte\_atomic64\_t** \*v, int64\_t dec)\
 static void **rte\_atomic64\_inc** (**rte\_atomic64\_t** \*v)\
 static void **rte\_atomic64\_dec** (**rte\_atomic64\_t** \*v)\
 static int64\_t **rte\_atomic64\_add\_return** (**rte\_atomic64\_t** \*v, int64\_t inc)\
 static int64\_t **rte\_atomic64\_sub\_return** (**rte\_atomic64\_t** \*v, int64\_t dec)\
 static int **rte\_atomic64\_inc\_and\_test** (**rte\_atomic64\_t** \*v)\
 static int **rte\_atomic64\_dec\_and\_test** (**rte\_atomic64\_t** \*v)\
 static int **rte\_atomic64\_test\_and\_set** (**rte\_atomic64\_t** \*v)\
 static void **rte\_atomic64\_clear** (**rte\_atomic64\_t** \*v)\
 struct **\_\_rte\_aligned** (16)\
 static int **rte\_atomic128\_cmp\_exchange** (rte\_int128\_t \*dst, rte\_int128\_t \*exp, const rte\_int128\_t \*src, unsigned int weak, int success, int failure)\

**Memory Barrier**\

static void **rte\_mb** (void)\
 static void **rte\_wmb** (void)\
 static void **rte\_rmb** (void)\

**SMP Memory Barrier**\

static void **rte\_smp\_mb** (void)\
 static void **rte\_smp\_wmb** (void)\
 static void **rte\_smp\_rmb** (void)\

**I/O Memory Barrier**\

static void **rte\_io\_mb** (void)\
 static void **rte\_io\_wmb** (void)\
 static void **rte\_io\_rmb** (void)\

## Detailed Description

Atomic Operations

This file defines a generic API for atomic operations.

Definition in file **rte\_atomic.h**.

## Macro Definition Documentation

### #define rte\_compiler\_barrier()

**Value:**.PP

```
    do {        \
    asm volatile ("" : : : "memory");   \
} while(0)
```

Compiler barrier.

Guarantees that operation reordering does not occur at compile time for operations directly before and after the barrier.

Definition at line **157** of file **rte\_atomic.h**.

### #define RTE\_ATOMIC16\_INIT(val) { (val) }

Static initializer for an atomic counter.

Definition at line **234** of file **rte\_atomic.h**.

### #define RTE\_ATOMIC32\_INIT(val) { (val) }

Static initializer for an atomic counter.

Definition at line **519** of file **rte\_atomic.h**.

### #define RTE\_ATOMIC64\_INIT(val) { (val) }

Static initializer for an atomic counter.

Definition at line **803** of file **rte\_atomic.h**.

## Function Documentation

### static void rte\_mb (void)` [inline]`, ` [static]`

General memory barrier.

Guarantees that the LOAD and STORE operations generated before the barrier occur before the LOAD and STORE operations generated after.

### static void rte\_wmb (void)` [inline]`, ` [static]`

Write memory barrier.

Guarantees that the STORE operations generated before the barrier occur before the STORE operations generated after.

### static void rte\_rmb (void)` [inline]`, ` [static]`

Read memory barrier.

Guarantees that the LOAD operations generated before the barrier occur before the LOAD operations generated after.

### static void rte\_smp\_mb (void)` [inline]`, ` [static]`

General memory barrier between lcores

Guarantees that the LOAD and STORE operations that precede the **rte\_smp\_mb()** call are globally visible across the lcores before the LOAD and STORE operations that follows it.

**Note**

This function is deprecated. It provides similar synchronization primitive as atomic fence, but has different syntax and memory ordering semantic. Hence deprecated for the simplicity of memory ordering semantics in use.

rte\_atomic\_thread\_fence(rte\_memory\_order\_acq\_rel) should be used instead.

### static void rte\_smp\_wmb (void)` [inline]`, ` [static]`

Write memory barrier between lcores

Guarantees that the STORE operations that precede the **rte\_smp\_wmb()** call are globally visible across the lcores before the STORE operations that follows it.

**Note**

This function is deprecated. It provides similar synchronization primitive as atomic fence, but has different syntax and memory ordering semantic. Hence deprecated for the simplicity of memory ordering semantics in use.

rte\_atomic\_thread\_fence(rte\_memory\_order\_release) should be used instead. The fence also guarantees LOAD operations that precede the call are globally visible across the lcores before the STORE operations that follows it.

### static void rte\_smp\_rmb (void)` [inline]`, ` [static]`

Read memory barrier between lcores

Guarantees that the LOAD operations that precede the **rte\_smp\_rmb()** call are globally visible across the lcores before the LOAD operations that follows it.

**Note**

This function is deprecated. It provides similar synchronization primitive as atomic fence, but has different syntax and memory ordering semantic. Hence deprecated for the simplicity of memory ordering semantics in use.

rte\_atomic\_thread\_fence(rte\_memory\_order\_acquire) should be used instead. The fence also guarantees LOAD operations that precede the call are globally visible across the lcores before the STORE operations that follows it.

### static void rte\_io\_mb (void)` [inline]`, ` [static]`

General memory barrier for I/O device

Guarantees that the LOAD and STORE operations that precede the **rte\_io\_mb()** call are visible to I/O device or CPU before the LOAD and STORE operations that follow it.

### static void rte\_io\_wmb (void)` [inline]`, ` [static]`

Write memory barrier for I/O device

Guarantees that the STORE operations that precede the **rte\_io\_wmb()** call are visible to I/O device before the STORE operations that follow it.

### static void rte\_io\_rmb (void)` [inline]`, ` [static]`

Read memory barrier for IO device

Guarantees that the LOAD operations on I/O device that precede the **rte\_io\_rmb()** call are visible to CPU before the LOAD operations that follow it.

### static void rte\_atomic\_thread\_fence (rte\_memory\_order memorder)` [inline]`, ` [static]`

Synchronization fence between threads based on the specified memory order.

### static int rte\_atomic16\_cmpset (volatile uint16\_t \* dst, uint16\_t exp, uint16\_t src)` [inline]`, ` [static]`

Atomic compare and set.

(atomic) equivalent to: if (\*dst == exp) \*dst = src (all 16-bit words)

**Parameters**

*dst* The destination location into which the value will be written. \
 *exp* The expected value. \
 *src* The new value.

**Returns**

Non-zero on success; 0 on failure.

### static uint16\_t rte\_atomic16\_exchange (volatile uint16\_t \* dst, uint16\_t val)` [inline]`, ` [static]`

Atomic exchange.

(atomic) equivalent to: ret = \*dst \*dst = val; return ret;

**Parameters**

*dst* The destination location into which the value will be written. \
 *val* The new value.

**Returns**

The original value at that location

### static void rte\_atomic16\_init (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Initialize an atomic counter.

**Parameters**

*v* A pointer to the atomic counter.

Definition at line **243** of file **rte\_atomic.h**.

### static int16\_t rte\_atomic16\_read (const rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically read a 16-bit value from a counter.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

The value of the counter.

Definition at line **257** of file **rte\_atomic.h**.

### static void rte\_atomic16\_set (rte\_atomic16\_t \* v, int16\_t new\_value)` [inline]`, ` [static]`

Atomically set a counter to a 16-bit value.

**Parameters**

*v* A pointer to the atomic counter. \
 *new\_value* The new value for the counter.

Definition at line **271** of file **rte\_atomic.h**.

### static void rte\_atomic16\_add (rte\_atomic16\_t \* v, int16\_t inc)` [inline]`, ` [static]`

Atomically add a 16-bit value to an atomic counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *inc* The value to be added to the counter.

Definition at line **285** of file **rte\_atomic.h**.

### static void rte\_atomic16\_sub (rte\_atomic16\_t \* v, int16\_t dec)` [inline]`, ` [static]`

Atomically subtract a 16-bit value from an atomic counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *dec* The value to be subtracted from the counter.

Definition at line **300** of file **rte\_atomic.h**.

### static void rte\_atomic16\_inc (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically increment a counter by one.

**Parameters**

*v* A pointer to the atomic counter.

### static void rte\_atomic16\_dec (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically decrement a counter by one.

**Parameters**

*v* A pointer to the atomic counter.

### static int16\_t rte\_atomic16\_add\_return (rte\_atomic16\_t \* v, int16\_t inc)` [inline]`, ` [static]`

Atomically add a 16-bit value to a counter and return the result.

Atomically adds the 16-bits value (inc) to the atomic counter (v) and returns the value of v after addition.

**Parameters**

*v* A pointer to the atomic counter. \
 *inc* The value to be added to the counter.

**Returns**

The value of v after the addition.

Definition at line **354** of file **rte\_atomic.h**.

### static int16\_t rte\_atomic16\_sub\_return (rte\_atomic16\_t \* v, int16\_t dec)` [inline]`, ` [static]`

Atomically subtract a 16-bit value from a counter and return the result.

Atomically subtracts the 16-bit value (inc) from the atomic counter (v) and returns the value of v after the subtraction.

**Parameters**

*v* A pointer to the atomic counter. \
 *dec* The value to be subtracted from the counter.

**Returns**

The value of v after the subtraction.

Definition at line **375** of file **rte\_atomic.h**.

### static int rte\_atomic16\_inc\_and\_test (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically increment a 16-bit counter by one and test.

Atomically increments the atomic counter (v) by one and returns true if the result is 0, or false in all other cases.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

True if the result after the increment operation is 0; false otherwise.

### static int rte\_atomic16\_dec\_and\_test (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically decrement a 16-bit counter by one and test.

Atomically decrements the atomic counter (v) by one and returns true if the result is 0, or false in all other cases.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

True if the result after the decrement operation is 0; false otherwise.

### static int rte\_atomic16\_test\_and\_set (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically test and set a 16-bit atomic counter.

If the counter value is already set, return 0 (failed). Otherwise, set the counter value to 1 and return 1 (success).

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

0 if failed; else 1, success.

### static void rte\_atomic16\_clear (rte\_atomic16\_t \* v)` [inline]`, ` [static]`

Atomically set a 16-bit counter to 0.

**Parameters**

*v* A pointer to the atomic counter.

Definition at line **449** of file **rte\_atomic.h**.

### static int rte\_atomic32\_cmpset (volatile uint32\_t \* dst, uint32\_t exp, uint32\_t src)` [inline]`, ` [static]`

Atomic compare and set.

(atomic) equivalent to: if (\*dst == exp) \*dst = src (all 32-bit words)

**Parameters**

*dst* The destination location into which the value will be written. \
 *exp* The expected value. \
 *src* The new value.

**Returns**

Non-zero on success; 0 on failure.

### static uint32\_t rte\_atomic32\_exchange (volatile uint32\_t \* dst, uint32\_t val)` [inline]`, ` [static]`

Atomic exchange.

(atomic) equivalent to: ret = \*dst \*dst = val; return ret;

**Parameters**

*dst* The destination location into which the value will be written. \
 *val* The new value.

**Returns**

The original value at that location

### static void rte\_atomic32\_init (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Initialize an atomic counter.

**Parameters**

*v* A pointer to the atomic counter.

Definition at line **528** of file **rte\_atomic.h**.

### static int32\_t rte\_atomic32\_read (const rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically read a 32-bit value from a counter.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

The value of the counter.

Definition at line **542** of file **rte\_atomic.h**.

### static void rte\_atomic32\_set (rte\_atomic32\_t \* v, int32\_t new\_value)` [inline]`, ` [static]`

Atomically set a counter to a 32-bit value.

**Parameters**

*v* A pointer to the atomic counter. \
 *new\_value* The new value for the counter.

Definition at line **556** of file **rte\_atomic.h**.

### static void rte\_atomic32\_add (rte\_atomic32\_t \* v, int32\_t inc)` [inline]`, ` [static]`

Atomically add a 32-bit value to an atomic counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *inc* The value to be added to the counter.

Definition at line **570** of file **rte\_atomic.h**.

### static void rte\_atomic32\_sub (rte\_atomic32\_t \* v, int32\_t dec)` [inline]`, ` [static]`

Atomically subtract a 32-bit value from an atomic counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *dec* The value to be subtracted from the counter.

Definition at line **585** of file **rte\_atomic.h**.

### static void rte\_atomic32\_inc (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically increment a counter by one.

**Parameters**

*v* A pointer to the atomic counter.

### static void rte\_atomic32\_dec (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically decrement a counter by one.

**Parameters**

*v* A pointer to the atomic counter.

### static int32\_t rte\_atomic32\_add\_return (rte\_atomic32\_t \* v, int32\_t inc)` [inline]`, ` [static]`

Atomically add a 32-bit value to a counter and return the result.

Atomically adds the 32-bits value (inc) to the atomic counter (v) and returns the value of v after addition.

**Parameters**

*v* A pointer to the atomic counter. \
 *inc* The value to be added to the counter.

**Returns**

The value of v after the addition.

Definition at line **639** of file **rte\_atomic.h**.

### static int32\_t rte\_atomic32\_sub\_return (rte\_atomic32\_t \* v, int32\_t dec)` [inline]`, ` [static]`

Atomically subtract a 32-bit value from a counter and return the result.

Atomically subtracts the 32-bit value (inc) from the atomic counter (v) and returns the value of v after the subtraction.

**Parameters**

*v* A pointer to the atomic counter. \
 *dec* The value to be subtracted from the counter.

**Returns**

The value of v after the subtraction.

Definition at line **660** of file **rte\_atomic.h**.

### static int rte\_atomic32\_inc\_and\_test (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically increment a 32-bit counter by one and test.

Atomically increments the atomic counter (v) by one and returns true if the result is 0, or false in all other cases.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

True if the result after the increment operation is 0; false otherwise.

### static int rte\_atomic32\_dec\_and\_test (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically decrement a 32-bit counter by one and test.

Atomically decrements the atomic counter (v) by one and returns true if the result is 0, or false in all other cases.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

True if the result after the decrement operation is 0; false otherwise.

### static int rte\_atomic32\_test\_and\_set (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically test and set a 32-bit atomic counter.

If the counter value is already set, return 0 (failed). Otherwise, set the counter value to 1 and return 1 (success).

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

0 if failed; else 1, success.

### static void rte\_atomic32\_clear (rte\_atomic32\_t \* v)` [inline]`, ` [static]`

Atomically set a 32-bit counter to 0.

**Parameters**

*v* A pointer to the atomic counter.

Definition at line **734** of file **rte\_atomic.h**.

### static int rte\_atomic64\_cmpset (volatile uint64\_t \* dst, uint64\_t exp, uint64\_t src)` [inline]`, ` [static]`

An atomic compare and set function used by the mutex functions. (atomic) equivalent to: if (\*dst == exp) \*dst = src (all 64-bit words)

**Parameters**

*dst* The destination into which the value will be written. \
 *exp* The expected value. \
 *src* The new value.

**Returns**

Non-zero on success; 0 on failure.

### static uint64\_t rte\_atomic64\_exchange (volatile uint64\_t \* dst, uint64\_t val)` [inline]`, ` [static]`

Atomic exchange.

(atomic) equivalent to: ret = \*dst \*dst = val; return ret;

**Parameters**

*dst* The destination location into which the value will be written. \
 *val* The new value.

**Returns**

The original value at that location

### static void rte\_atomic64\_init (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Initialize the atomic counter.

**Parameters**

*v* A pointer to the atomic counter.

### static int64\_t rte\_atomic64\_read (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically read a 64-bit counter.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

The value of the counter.

### static void rte\_atomic64\_set (rte\_atomic64\_t \* v, int64\_t new\_value)` [inline]`, ` [static]`

Atomically set a 64-bit counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *new\_value* The new value of the counter.

### static void rte\_atomic64\_add (rte\_atomic64\_t \* v, int64\_t inc)` [inline]`, ` [static]`

Atomically add a 64-bit value to a counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *inc* The value to be added to the counter.

### static void rte\_atomic64\_sub (rte\_atomic64\_t \* v, int64\_t dec)` [inline]`, ` [static]`

Atomically subtract a 64-bit value from a counter.

**Parameters**

*v* A pointer to the atomic counter. \
 *dec* The value to be subtracted from the counter.

### static void rte\_atomic64\_inc (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically increment a 64-bit counter by one and test.

**Parameters**

*v* A pointer to the atomic counter.

### static void rte\_atomic64\_dec (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically decrement a 64-bit counter by one and test.

**Parameters**

*v* A pointer to the atomic counter.

### static int64\_t rte\_atomic64\_add\_return (rte\_atomic64\_t \* v, int64\_t inc)` [inline]`, ` [static]`

Add a 64-bit value to an atomic counter and return the result.

Atomically adds the 64-bit value (inc) to the atomic counter (v) and returns the value of v after the addition.

**Parameters**

*v* A pointer to the atomic counter. \
 *inc* The value to be added to the counter.

**Returns**

The value of v after the addition.

### static int64\_t rte\_atomic64\_sub\_return (rte\_atomic64\_t \* v, int64\_t dec)` [inline]`, ` [static]`

Subtract a 64-bit value from an atomic counter and return the result.

Atomically subtracts the 64-bit value (dec) from the atomic counter (v) and returns the value of v after the subtraction.

**Parameters**

*v* A pointer to the atomic counter. \
 *dec* The value to be subtracted from the counter.

**Returns**

The value of v after the subtraction.

### static int rte\_atomic64\_inc\_and\_test (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically increment a 64-bit counter by one and test.

Atomically increments the atomic counter (v) by one and returns true if the result is 0, or false in all other cases.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

True if the result after the addition is 0; false otherwise.

### static int rte\_atomic64\_dec\_and\_test (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically decrement a 64-bit counter by one and test.

Atomically decrements the atomic counter (v) by one and returns true if the result is 0, or false in all other cases.

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

True if the result after subtraction is 0; false otherwise.

### static int rte\_atomic64\_test\_and\_set (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically test and set a 64-bit atomic counter.

If the counter value is already set, return 0 (failed). Otherwise, set the counter value to 1 and return 1 (success).

**Parameters**

*v* A pointer to the atomic counter.

**Returns**

0 if failed; else 1, success.

### static void rte\_atomic64\_clear (rte\_atomic64\_t \* v)` [inline]`, ` [static]`

Atomically set a 64-bit counter to 0.

**Parameters**

*v* A pointer to the atomic counter.

### struct \_\_rte\_aligned (16)

128-bit integer structure.

Definition at line **1085** of file **rte\_atomic.h**.

### static int rte\_atomic128\_cmp\_exchange (rte\_int128\_t \* dst, rte\_int128\_t \* exp, const rte\_int128\_t \* src, unsigned int weak, int success, int failure)` [inline]`, ` [static]`

An atomic compare and set function used by the mutex functions. (Atomically) Equivalent to:

```
if (*dst == *exp)
  *dst = *src
else
  *exp = *dst
```

**Note**

This function is currently available for the x86-64 and aarch64 platforms.

The success and failure arguments must be one of the \_\_ATOMIC\_\* values defined in the C++11 standard. For details on their behavior, refer to the standard.

**Parameters**

*dst* The destination into which the value will be written. \
 *exp* Pointer to the expected value. If the operation fails, this memory is updated with the actual value. \
 *src* Pointer to the new value. \
 *weak* A value of true allows the comparison to spuriously fail and allows the 'exp' update to occur non-atomically (i.e. a torn read may occur). Implementations may ignore this argument and only implement the strong variant. \
 *success* If successful, the operation's memory behavior conforms to this (or a stronger) model. \
 *failure* If unsuccessful, the operation's memory behavior conforms to this (or a stronger) model. This argument cannot be rte\_memory\_order\_release, rte\_memory\_order\_acq\_rel, or a stronger model than success.

**Returns**

Non-zero on success; 0 on failure.

## Author

Generated automatically by Doxygen for DPDK from the source code.
