Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Macros | Typedefs | Functions
ruby_atomic.h File Reference

Go to the source code of this file.

## Macros
#define | NEED_RUBY_ATOMIC_OPS
#define | ATOMIC_SET(var, val) (void)((var) = (val))
#define | ATOMIC_INC(var) ((var)++)
#define | ATOMIC_DEC(var) ((var)--)
#define | ATOMIC_OR(var, val) ((var) |= (val))
#define | ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val))
#define | ATOMIC_CAS(var, oldval, newval) ruby_atomic_compare_and_swap(&(var), (oldval), (newval))
#define | ATOMIC_SIZE_ADD(var, val) (void)((var) += (val))
#define | ATOMIC_SIZE_SUB(var, val) (void)((var) -= (val))
#define | ATOMIC_SIZE_EXCHANGE(var, val) ruby_atomic_size_exchange(&(var), (val))
#define | ATOMIC_SIZE_INC(var) ATOMIC_INC(var)
#define | ATOMIC_SIZE_DEC(var) ATOMIC_DEC(var)
#define | ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
#define | ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
#define | ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
#define | ATOMIC_VALUE_EXCHANGE(var, val) ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
#define | ATOMIC_VALUE_CAS(var, oldval, val) ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))

## Typedefs
typedef int | rb_atomic_t

## Functions
rb_atomic_t | ruby_atomic_exchange (rb_atomic_t *ptr, rb_atomic_t val)
rb_atomic_t | ruby_atomic_compare_and_swap (rb_atomic_t *ptr, rb_atomic_t cmp, rb_atomic_t newval)

## Macro Definition Documentation

## ◆ ATOMIC_CAS

#define ATOMIC_CAS | ( |  | var,
|  |  | oldval,
|  |  | newval
| ) |  | ruby_atomic_compare_and_swap(&(var), (oldval), (newval))

Definition at line 136 of file ruby_atomic.h.

## ◆ ATOMIC_DEC

#define ATOMIC_DEC | ( |  | var | ) | ((var)--)

Definition at line 133 of file ruby_atomic.h.

## ◆ ATOMIC_EXCHANGE

#define ATOMIC_EXCHANGE | ( |  | var,
|  |  | val
| ) |  | ruby_atomic_exchange(&(var), (val))

Definition at line 135 of file ruby_atomic.h.

## ◆ ATOMIC_INC

#define ATOMIC_INC | ( |  | var | ) | ((var)++)

Definition at line 132 of file ruby_atomic.h.

## ◆ ATOMIC_OR

#define ATOMIC_OR | ( |  | var,
|  |  | val
| ) |  | ((var) |= (val))

Definition at line 134 of file ruby_atomic.h.

## ◆ ATOMIC_PTR_CAS

#define ATOMIC_PTR_CAS | ( |  | var,
|  |  | oldval,
|  |  | val
| ) |  | (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))

Definition at line 201 of file ruby_atomic.h.

## ◆ ATOMIC_PTR_EXCHANGE

#define ATOMIC_PTR_EXCHANGE | ( |  | var,
|  |  | val
| ) |  | (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))

Definition at line 186 of file ruby_atomic.h.

## ◆ ATOMIC_SET

#define ATOMIC_SET | ( |  | var,
|  |  | val
| ) |  | (void)((var) = (val))

Definition at line 131 of file ruby_atomic.h.

## ◆ ATOMIC_SIZE_ADD

#define ATOMIC_SIZE_ADD | ( |  | var,
|  |  | val
| ) |  | (void)((var) += (val))

Definition at line 138 of file ruby_atomic.h.

## ◆ ATOMIC_SIZE_CAS

#define ATOMIC_SIZE_CAS | ( |  | var,
|  |  | oldval,
|  |  | val
| ) |  | ATOMIC_CAS(var, oldval, val)

Definition at line 163 of file ruby_atomic.h.

## ◆ ATOMIC_SIZE_DEC

#define ATOMIC_SIZE_DEC | ( |  | var | ) | ATOMIC_DEC(var)

Definition at line 155 of file ruby_atomic.h.

## ◆ ATOMIC_SIZE_EXCHANGE

#define ATOMIC_SIZE_EXCHANGE | ( |  | var,
|  |  | val
| ) |  | ruby_atomic_size_exchange(&(var), (val))

Definition at line 140 of file ruby_atomic.h.

## ◆ ATOMIC_SIZE_INC

#define ATOMIC_SIZE_INC | ( |  | var | ) | ATOMIC_INC(var)

Definition at line 151 of file ruby_atomic.h.

## ◆ ATOMIC_SIZE_SUB

#define ATOMIC_SIZE_SUB | ( |  | var,
|  |  | val
| ) |  | (void)((var) -= (val))

Definition at line 139 of file ruby_atomic.h.

## ◆ ATOMIC_VALUE_CAS

#define ATOMIC_VALUE_CAS | ( |  | var,
|  |  | oldval,
|  |  | val
| ) |  | ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))

Definition at line 231 of file ruby_atomic.h.

## ◆ ATOMIC_VALUE_EXCHANGE

#define ATOMIC_VALUE_EXCHANGE | ( |  | var,
|  |  | val
| ) |  | ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))

Definition at line 216 of file ruby_atomic.h.

## ◆ NEED_RUBY_ATOMIC_OPS

#define NEED_RUBY_ATOMIC_OPS

Definition at line 125 of file ruby_atomic.h.

## Typedef Documentation

## ◆ rb_atomic_t

typedef int rb_atomic_t

Definition at line 124 of file ruby_atomic.h.

## Function Documentation

## ◆ ruby_atomic_compare_and_swap()

rb_atomic_t ruby_atomic_compare_and_swap | ( | rb_atomic_t * | ptr,
|  | rb_atomic_t | cmp,
|  | rb_atomic_t | newval
| ) |  |

Definition at line 54 of file signal.c.

## ◆ ruby_atomic_exchange()

rb_atomic_t ruby_atomic_exchange | ( | rb_atomic_t * | ptr,
|  | rb_atomic_t | val
| ) |  |

Definition at line 46 of file signal.c.

References old, and ptr.