mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Bail out if no atomic operation found
As atomic operations are mandatory now, not-working phony fallback definitions are not only useless but confusing and harmful.
This commit is contained in:
parent
e92f3e1216
commit
20773a1090
1 changed files with 1 additions and 24 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue