Skip to content

Commit

Permalink
Bail out if no atomic operation found
Browse files Browse the repository at this point in the history
As atomic operations are mandatory now, not-working phony fallback
definitions are not only useless but confusing and harmful.
  • Loading branch information
nobu committed Apr 20, 2020
1 parent e92f3e1 commit 20773a1
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions ruby_atomic.h
Expand Up @@ -121,30 +121,7 @@ typedef unsigned int rb_atomic_t;
# endif

#else
typedef int rb_atomic_t;
#define NEED_RUBY_ATOMIC_OPS
extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val);
extern rb_atomic_t ruby_atomic_compare_and_swap(rb_atomic_t *ptr,
rb_atomic_t cmp,
rb_atomic_t newval);

# 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))
static inline size_t
ruby_atomic_size_exchange(size_t *ptr, size_t val)
{
size_t old = *ptr;
*ptr = val;
return old;
}
# error No atomic operation found
#endif

#ifndef ATOMIC_SIZE_INC
Expand Down

0 comments on commit 20773a1

Please sign in to comment.