Added WITH_REAL macros
Added `WITH_REAL` versions to `RB_RANDOM_INTERFACE` macros. Also these macros including "without real" versions no longer contain the terminator (semicolon and comma).
This commit is contained in:
parent
d6ec0ef59b
commit
4924011262
Notes:
git
2020-09-07 20:08:34 +09:00
@ -7,13 +7,10 @@ typedef struct {
|
|||||||
uint32_t num, idx, *buf;
|
uint32_t num, idx, *buf;
|
||||||
} rand_loop_t;
|
} rand_loop_t;
|
||||||
|
|
||||||
static double loop_get_real(rb_random_t *rnd, int excl);
|
RB_RANDOM_INTERFACE_DECLARE_WITH_REAL(loop);
|
||||||
|
|
||||||
RB_RANDOM_INTERFACE_DECLARE(loop)
|
|
||||||
static const rb_random_interface_t random_loop_if = {
|
static const rb_random_interface_t random_loop_if = {
|
||||||
32,
|
32,
|
||||||
RB_RANDOM_INTERFACE_DEFINE(loop)
|
RB_RANDOM_INTERFACE_DEFINE_WITH_REAL(loop)
|
||||||
loop_get_real,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -44,14 +44,20 @@ typedef struct {
|
|||||||
#define RB_RANDOM_INTERFACE_DECLARE(prefix) \
|
#define RB_RANDOM_INTERFACE_DECLARE(prefix) \
|
||||||
static void prefix##_init(rb_random_t *, const uint32_t *, size_t); \
|
static void prefix##_init(rb_random_t *, const uint32_t *, size_t); \
|
||||||
static unsigned int prefix##_get_int32(rb_random_t *); \
|
static unsigned int prefix##_get_int32(rb_random_t *); \
|
||||||
static void prefix##_get_bytes(rb_random_t *, void *, size_t); \
|
static void prefix##_get_bytes(rb_random_t *, void *, size_t)
|
||||||
/* end */
|
|
||||||
|
#define RB_RANDOM_INTERFACE_DECLARE_WITH_REAL(prefix) \
|
||||||
|
RB_RANDOM_INTERFACE_DECLARE(prefix); \
|
||||||
|
static double prefix##_get_real(rb_random_t *, int)
|
||||||
|
|
||||||
#define RB_RANDOM_INTERFACE_DEFINE(prefix) \
|
#define RB_RANDOM_INTERFACE_DEFINE(prefix) \
|
||||||
prefix##_init, \
|
prefix##_init, \
|
||||||
prefix##_get_int32, \
|
prefix##_get_int32, \
|
||||||
prefix##_get_bytes, \
|
prefix##_get_bytes
|
||||||
/* end */
|
|
||||||
|
#define RB_RANDOM_INTERFACE_DEFINE_WITH_REAL(prefix) \
|
||||||
|
RB_RANDOM_INTERFACE_DEFINE(prefix), \
|
||||||
|
prefix##_get_real
|
||||||
|
|
||||||
#if defined _WIN32 && !defined __CYGWIN__
|
#if defined _WIN32 && !defined __CYGWIN__
|
||||||
typedef rb_data_type_t rb_random_data_type_t;
|
typedef rb_data_type_t rb_random_data_type_t;
|
||||||
|
2
random.c
2
random.c
@ -127,7 +127,7 @@ static VALUE random_seed(VALUE);
|
|||||||
static void fill_random_seed(uint32_t *seed, size_t cnt);
|
static void fill_random_seed(uint32_t *seed, size_t cnt);
|
||||||
static VALUE make_seed_value(uint32_t *ptr, size_t len);
|
static VALUE make_seed_value(uint32_t *ptr, size_t len);
|
||||||
|
|
||||||
RB_RANDOM_INTERFACE_DECLARE(rand_mt)
|
RB_RANDOM_INTERFACE_DECLARE(rand_mt);
|
||||||
static const rb_random_interface_t random_mt_if = {
|
static const rb_random_interface_t random_mt_if = {
|
||||||
DEFAULT_SEED_CNT * 32,
|
DEFAULT_SEED_CNT * 32,
|
||||||
RB_RANDOM_INTERFACE_DEFINE(rand_mt)
|
RB_RANDOM_INTERFACE_DEFINE(rand_mt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user