Use opaque struct pointer than void
This commit is contained in:
parent
5d8fe1267d
commit
039ba387aa
@ -14,9 +14,10 @@
|
|||||||
|
|
||||||
RBIMPL_SYMBOL_EXPORT_BEGIN()
|
RBIMPL_SYMBOL_EXPORT_BEGIN()
|
||||||
|
|
||||||
typedef struct {
|
struct rb_random_struct {
|
||||||
VALUE seed;
|
VALUE seed;
|
||||||
} rb_random_t;
|
};
|
||||||
|
typedef struct rb_random_struct rb_random_t;
|
||||||
|
|
||||||
typedef void rb_random_init_func(rb_random_t *, const uint32_t *, size_t);
|
typedef void rb_random_init_func(rb_random_t *, const uint32_t *, size_t);
|
||||||
typedef unsigned int rb_random_get_int32_func(rb_random_t *);
|
typedef unsigned int rb_random_get_int32_func(rb_random_t *);
|
||||||
|
6
ractor.c
6
ractor.c
@ -1773,11 +1773,11 @@ rb_ractor_stderr_set(VALUE err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
struct rb_random_struct *
|
||||||
rb_ractor_default_rand(void *ptr)
|
rb_ractor_default_rand(struct rb_random_struct *ptr)
|
||||||
{
|
{
|
||||||
if (rb_ractor_main_p()) {
|
if (rb_ractor_main_p()) {
|
||||||
static void *default_rnd;
|
static struct rb_random_struct *default_rnd;
|
||||||
if (UNLIKELY(ptr != NULL)) {
|
if (UNLIKELY(ptr != NULL)) {
|
||||||
rb_ractor_t *cr = GET_RACTOR();
|
rb_ractor_t *cr = GET_RACTOR();
|
||||||
cr->default_rand = default_rnd = ptr;
|
cr->default_rand = default_rnd = ptr;
|
||||||
|
@ -36,6 +36,8 @@ struct rb_ractor_waiting_list {
|
|||||||
rb_ractor_t **ractors;
|
rb_ractor_t **ractors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct rb_random_struct; // c.f. ruby/random.h
|
||||||
|
|
||||||
struct rb_ractor_struct {
|
struct rb_ractor_struct {
|
||||||
// ractor lock
|
// ractor lock
|
||||||
rb_nativethread_lock_t lock;
|
rb_nativethread_lock_t lock;
|
||||||
@ -127,7 +129,7 @@ struct rb_ractor_struct {
|
|||||||
VALUE verbose;
|
VALUE verbose;
|
||||||
VALUE debug;
|
VALUE debug;
|
||||||
|
|
||||||
void *default_rand; // used in random.c
|
struct rb_random_struct *default_rand; // used in random.c
|
||||||
|
|
||||||
// gc.c rb_objspace_reachable_objects_from
|
// gc.c rb_objspace_reachable_objects_from
|
||||||
struct gc_mark_func_data_struct {
|
struct gc_mark_func_data_struct {
|
||||||
|
4
random.c
4
random.c
@ -149,11 +149,11 @@ rand_start(rb_random_mt_t *r)
|
|||||||
static rb_random_mt_t *
|
static rb_random_mt_t *
|
||||||
default_rand(void)
|
default_rand(void)
|
||||||
{
|
{
|
||||||
void *rb_ractor_default_rand(void *); // ractor.c
|
rb_random_t *rb_ractor_default_rand(rb_random_t *); // ractor.c
|
||||||
rb_random_mt_t *rnd = (rb_random_mt_t *)rb_ractor_default_rand(NULL);
|
rb_random_mt_t *rnd = (rb_random_mt_t *)rb_ractor_default_rand(NULL);
|
||||||
if (rnd == NULL) {
|
if (rnd == NULL) {
|
||||||
rnd = ZALLOC(rb_random_mt_t);
|
rnd = ZALLOC(rb_random_mt_t);
|
||||||
rb_ractor_default_rand(rnd);
|
rb_ractor_default_rand(&rnd->base);
|
||||||
}
|
}
|
||||||
return rnd;
|
return rnd;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user