diff options
Diffstat (limited to 'include/ruby/random.h')
| -rw-r--r-- | include/ruby/random.h | 63 |
1 files changed, 4 insertions, 59 deletions
diff --git a/include/ruby/random.h b/include/ruby/random.h index 39bdb6f3e3..657b37f034 100644 --- a/include/ruby/random.h +++ b/include/ruby/random.h @@ -16,26 +16,6 @@ #include "ruby/ruby.h" -/* - * version - * 0: before versioning; deprecated - * 1: added version, flags and init_32bit function - */ -#define RUBY_RANDOM_INTERFACE_VERSION_MAJOR 1 -#define RUBY_RANDOM_INTERFACE_VERSION_MINOR 0 - -#define RUBY_RANDOM_PASTE_VERSION_SUFFIX(x, y, z) x##_##y##_##z -#define RUBY_RANDOM_WITH_VERSION_SUFFIX(name, major, minor) \ - RUBY_RANDOM_PASTE_VERSION_SUFFIX(name, major, minor) -#define rb_random_data_type \ - RUBY_RANDOM_WITH_VERSION_SUFFIX(rb_random_data_type, \ - RUBY_RANDOM_INTERFACE_VERSION_MAJOR, \ - RUBY_RANDOM_INTERFACE_VERSION_MINOR) -#define RUBY_RANDOM_INTERFACE_VERSION_INITIALIZER \ - {RUBY_RANDOM_INTERFACE_VERSION_MAJOR, RUBY_RANDOM_INTERFACE_VERSION_MINOR} -#define RUBY_RANDOM_INTERFACE_VERSION_MAJOR_MAX 0xff -#define RUBY_RANDOM_INTERFACE_VERSION_MINOR_MAX 0xff - RBIMPL_SYMBOL_EXPORT_BEGIN() /** @@ -68,17 +48,6 @@ typedef void rb_random_init_func(rb_random_t *rng, const uint32_t *buf, size_t l RBIMPL_ATTR_NONNULL(()) /** - * This is the type of functions called when your random object is initialised. - * Passed data is the seed integer. - * - * @param[out] rng Your random struct to fill in. - * @param[in] data Seed, single word. - * @post `rng` is initialised using the passed seeds. - */ -typedef void rb_random_init_int32_func(rb_random_t *rng, uint32_t data); - -RBIMPL_ATTR_NONNULL(()) -/** * This is the type of functions called from your object's `#rand` method. * * @param[out] rng Your random struct to extract an integer from. @@ -115,24 +84,9 @@ typedef struct { /** Number of bits of seed numbers. */ size_t default_seed_bits; - /** - * Major/minor versions of this interface - */ - struct { - uint8_t major, minor; - } version; - - /** - * Reserved flags - */ - uint16_t flags; - - /** Function to initialize from uint32_t array. */ + /** Initialiser function. */ rb_random_init_func *init; - /** Function to initialize from single uint32_t. */ - rb_random_init_int32_func *init_int32; - /** Function to obtain a random integer. */ rb_random_get_int32_func *get_int32; @@ -176,12 +130,11 @@ typedef struct { } rb_random_interface_t; /** - * This utility macro defines 4 functions named prefix_init, prefix_init_int32, - * prefix_get_int32, prefix_get_bytes. + * This utility macro defines 3 functions named prefix_init, prefix_get_int32, + * prefix_get_bytes. */ #define RB_RANDOM_INTERFACE_DECLARE(prefix) \ static void prefix##_init(rb_random_t *, const uint32_t *, size_t); \ - static void prefix##_init_int32(rb_random_t *, uint32_t); \ static unsigned int prefix##_get_int32(rb_random_t *); \ static void prefix##_get_bytes(rb_random_t *, void *, size_t) @@ -208,9 +161,7 @@ typedef struct { * ``` */ #define RB_RANDOM_INTERFACE_DEFINE(prefix) \ - RUBY_RANDOM_INTERFACE_VERSION_INITIALIZER, 0, \ prefix##_init, \ - prefix##_init_int32, \ prefix##_get_int32, \ prefix##_get_bytes @@ -222,12 +173,6 @@ typedef struct { RB_RANDOM_INTERFACE_DEFINE(prefix), \ prefix##_get_real -#define RB_RANDOM_DEFINE_INIT_INT32_FUNC(prefix) \ - static void prefix##_init_int32(rb_random_t *rnd, uint32_t data) \ - { \ - prefix##_init(rnd, &data, 1); \ - } - #if defined _WIN32 && !defined __CYGWIN__ typedef rb_data_type_t rb_random_data_type_t; # define RB_RANDOM_PARENT 0 @@ -244,7 +189,7 @@ typedef const rb_data_type_t rb_random_data_type_t; * 0, RB_RANDOM_INTERFACE_DEFINE(your), * }; * - * static inline constexpr rb_random_data_type_t your_prng_type = { + * static inline constexpr your_prng = { * "your PRNG", * { rb_random_mark, }, * RB_RANDOM_PARENT, // <<-- HERE |
