### Function

# GLib atomic_int_add

since: 2.4

#### Declaration

    gint
    g_atomic_int_add (
      volatile gint* atomic,
      gint val
    )

#### Description

Atomically adds `val` to the value of `atomic`.

Think of this operation as an atomic version of `{ tmp = *atomic; *atomic += val; return tmp; }`.

This call acts as a full compiler and hardware memory barrier.

Before version 2.30, this function did not return a value (but `g_atomic_int_exchange_and_add()` did, and had the same meaning).

While `atomic` has a `volatile` qualifier, this is a historical artifact and the pointer passed to it should not be `volatile`.

Available since: 2.4

#### Parameters

`atomic`

  Type: `volatile gint*`

  A pointer to a #gint or #guint.

  The data is owned by the caller of the function.

`val`

  Type: `gint`

  The value to add.

#### Return value

Type: `gint`

The value of `atomic` before the add, signed.