зеркало из https://github.com/github/ruby.git
unsigned int should have enough bits for rb_thread_shield_waiting
This commit is contained in:
Родитель
1bd60c66d3
Коммит
8108594f47
16
thread.c
16
thread.c
|
@ -4708,16 +4708,22 @@ thread_shield_alloc(VALUE klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GetThreadShieldPtr(obj) ((VALUE)rb_check_typeddata((obj), &thread_shield_data_type))
|
#define GetThreadShieldPtr(obj) ((VALUE)rb_check_typeddata((obj), &thread_shield_data_type))
|
||||||
#define THREAD_SHIELD_WAITING_MASK (FL_USER0|FL_USER1|FL_USER2|FL_USER3|FL_USER4|FL_USER5|FL_USER6|FL_USER7|FL_USER8|FL_USER9|FL_USER10|FL_USER11|FL_USER12|FL_USER13|FL_USER14|FL_USER15|FL_USER16|FL_USER17|FL_USER18|FL_USER19)
|
#define THREAD_SHIELD_WAITING_MASK (((FL_USER19-1)&~(FL_USER0-1))|FL_USER19)
|
||||||
#define THREAD_SHIELD_WAITING_SHIFT (FL_USHIFT)
|
#define THREAD_SHIELD_WAITING_SHIFT (FL_USHIFT)
|
||||||
#define rb_thread_shield_waiting(b) ((RBASIC(b)->flags&THREAD_SHIELD_WAITING_MASK)>>THREAD_SHIELD_WAITING_SHIFT)
|
#define THREAD_SHIELD_WAITING_MAX (THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT)
|
||||||
|
STATIC_ASSERT(THREAD_SHIELD_WAITING_MAX, THREAD_SHIELD_WAITING_MAX <= UINT_MAX);
|
||||||
|
static inline unsigned int
|
||||||
|
rb_thread_shield_waiting(VALUE b)
|
||||||
|
{
|
||||||
|
return ((RBASIC(b)->flags&THREAD_SHIELD_WAITING_MASK)>>THREAD_SHIELD_WAITING_SHIFT);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
rb_thread_shield_waiting_inc(VALUE b)
|
rb_thread_shield_waiting_inc(VALUE b)
|
||||||
{
|
{
|
||||||
unsigned long w = rb_thread_shield_waiting(b);
|
unsigned int w = rb_thread_shield_waiting(b);
|
||||||
w++;
|
w++;
|
||||||
if (w > (THREAD_SHIELD_WAITING_MASK>>THREAD_SHIELD_WAITING_SHIFT))
|
if (w > THREAD_SHIELD_WAITING_MAX)
|
||||||
rb_raise(rb_eRuntimeError, "waiting count overflow");
|
rb_raise(rb_eRuntimeError, "waiting count overflow");
|
||||||
RBASIC(b)->flags &= ~THREAD_SHIELD_WAITING_MASK;
|
RBASIC(b)->flags &= ~THREAD_SHIELD_WAITING_MASK;
|
||||||
RBASIC(b)->flags |= ((VALUE)w << THREAD_SHIELD_WAITING_SHIFT);
|
RBASIC(b)->flags |= ((VALUE)w << THREAD_SHIELD_WAITING_SHIFT);
|
||||||
|
@ -4726,7 +4732,7 @@ rb_thread_shield_waiting_inc(VALUE b)
|
||||||
static inline void
|
static inline void
|
||||||
rb_thread_shield_waiting_dec(VALUE b)
|
rb_thread_shield_waiting_dec(VALUE b)
|
||||||
{
|
{
|
||||||
unsigned long w = rb_thread_shield_waiting(b);
|
unsigned int w = rb_thread_shield_waiting(b);
|
||||||
if (!w) rb_raise(rb_eRuntimeError, "waiting count underflow");
|
if (!w) rb_raise(rb_eRuntimeError, "waiting count underflow");
|
||||||
w--;
|
w--;
|
||||||
RBASIC(b)->flags &= ~THREAD_SHIELD_WAITING_MASK;
|
RBASIC(b)->flags &= ~THREAD_SHIELD_WAITING_MASK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче