Ruby: include/ruby/random.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Functions | Variables
random.h File Reference
`#include "ruby/ruby.h"`

Go to the source code of this file.

## Data Structures
struct | rb_random_struct
struct | rb_random_interface_t

## Macros
#define | RB_RANDOM_INTERFACE_DECLARE(prefix)
#define | RB_RANDOM_INTERFACE_DECLARE_WITH_REAL(prefix)
#define | RB_RANDOM_INTERFACE_DEFINE(prefix)
#define | RB_RANDOM_INTERFACE_DEFINE_WITH_REAL(prefix)
#define | RB_RANDOM_PARENT &rb_random_data_type
#define | RB_RANDOM_DATA_INIT_PARENT(random_data) rbimpl_random_data_init_parent(&random_data)

## Typedefs
typedef struct rb_random_struct | rb_random_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 void | rb_random_get_bytes_func(rb_random_t *, void *, size_t)
typedef double | rb_random_get_real_func(rb_random_t *, int)
typedef const rb_data_type_t | rb_random_data_type_t

## Functions
void | rb_random_mark (void *ptr)
void | rb_random_base_init (rb_random_t *rnd)
double | rb_int_pair_to_real (uint32_t a, uint32_t b, int excl)
void | rb_rand_bytes_int32 (rb_random_get_int32_func *, rb_random_t *, void *, size_t)

## Variables
const rb_data_type_t | rb_random_data_type

## Detailed Description

Date
  Sat May 7 11:51:14 JST 2016

Copyright
  2007-2020 Yukihiro Matsumoto
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition in file random.h.

## Macro Definition Documentation

## ◆ RB_RANDOM_DATA_INIT_PARENT

#define RB_RANDOM_DATA_INIT_PARENT | ( |  | random_data | ) | rbimpl_random_data_init_parent(&random_data)

Definition at line 61 of file random.h.

## ◆ RB_RANDOM_INTERFACE_DECLARE

#define RB_RANDOM_INTERFACE_DECLARE | ( |  | prefix | ) |

Value:
static void prefix##_init(rb_random_t *, const uint32_t *, size_t); \
static unsigned int prefix##_get_int32(rb_random_t *); \
static void prefix##_get_bytes(rb_random_t *, void *, size_t)
prefix
unsigned short prefix[65536]
Definition: gun.c:163
uint32_t
unsigned int uint32_t
Definition: sha2.h:101
rb_random_struct
Definition: random.h:17

Definition at line 35 of file random.h.

## ◆ RB_RANDOM_INTERFACE_DECLARE_WITH_REAL

#define RB_RANDOM_INTERFACE_DECLARE_WITH_REAL | ( |  | prefix | ) |

Value:
RB_RANDOM_INTERFACE_DECLARE(prefix); \
static double prefix##_get_real(rb_random_t *, int)
RB_RANDOM_INTERFACE_DECLARE
#define RB_RANDOM_INTERFACE_DECLARE(prefix)
Definition: random.h:35

Definition at line 40 of file random.h.

## ◆ RB_RANDOM_INTERFACE_DEFINE

#define RB_RANDOM_INTERFACE_DEFINE | ( |  | prefix | ) |

Value:
prefix##_init, \
prefix##_get_int32, \
prefix##_get_bytes

Definition at line 44 of file random.h.

## ◆ RB_RANDOM_INTERFACE_DEFINE_WITH_REAL

#define RB_RANDOM_INTERFACE_DEFINE_WITH_REAL | ( |  | prefix | ) |

Value:
RB_RANDOM_INTERFACE_DEFINE(prefix), \
prefix##_get_real
RB_RANDOM_INTERFACE_DEFINE
#define RB_RANDOM_INTERFACE_DEFINE(prefix)
Definition: random.h:44

Definition at line 49 of file random.h.

## ◆ RB_RANDOM_PARENT

#define RB_RANDOM_PARENT &rb_random_data_type

Definition at line 58 of file random.h.

## Typedef Documentation

## ◆ rb_random_data_type_t

typedef const rb_data_type_t rb_random_data_type_t

Definition at line 57 of file random.h.

## ◆ rb_random_get_bytes_func

typedef void rb_random_get_bytes_func(rb_random_t *, void *, size_t)

Definition at line 24 of file random.h.

## ◆ rb_random_get_int32_func

typedef unsigned int rb_random_get_int32_func(rb_random_t *)

Definition at line 23 of file random.h.

## ◆ rb_random_get_real_func

typedef double rb_random_get_real_func(rb_random_t *, int)

Definition at line 25 of file random.h.

## ◆ rb_random_init_func

typedef void rb_random_init_func(rb_random_t *, const uint32_t *, size_t)

Definition at line 22 of file random.h.

## ◆ rb_random_t

typedef struct rb_random_struct rb_random_t

Definition at line 20 of file random.h.

## Function Documentation

## ◆ rb_int_pair_to_real()

double rb_int_pair_to_real | ( | uint32_t | a,
|  | uint32_t | b,
|  | int | excl
| ) |  |

Definition at line 1036 of file random.c.

## ◆ rb_rand_bytes_int32()

void rb_rand_bytes_int32 | ( | rb_random_get_int32_func * | get_int32,
|  | rb_random_t * | rnd,
|  | void * | p,
|  | size_t | n
| ) |  |

Definition at line 1182 of file random.c.

References CHAR_BIT, ptr, and SIZEOF_INT32.

## ◆ rb_random_base_init()

void rb_random_base_init | ( | rb_random_t * | rnd | ) |

Definition at line 333 of file random.c.

References INT2FIX, and rb_random_struct::seed.

## ◆ rb_random_mark()

void rb_random_mark | ( | void * | ptr | ) |

## Variable Documentation

## ◆ rb_random_data_type

const rb_data_type_t rb_random_data_type
| extern

Definition at line 249 of file random.c.