Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Functions | Variables
random.c File Reference
`#include "internal.h"`
`#include <limits.h>`
`#include <time.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <math.h>`
`#include <errno.h>`
`#include "ruby_atomic.h"`
`#include "missing/mt19937.c"`
`#include "siphash.c"`

Go to the source code of this file.

## Data Structures
struct | rb_random_t
struct | seed_keys_t

## Macros
#define | DEFAULT_SEED_CNT 4
#define | SIZEOF_INT32 (31/CHAR_BIT + 1)
#define | id_minus '-'
#define | id_plus '+'
#define | DEFAULT_SEED_LEN (DEFAULT_SEED_CNT * (int)sizeof(int32_t))
#define | USE_DEV_URANDOM 0
#define | fill_random_bytes_urandom(seed, size) -1
#define | fill_random_bytes_syscall(seed, size, need_secure) -1
#define | fill_random_bytes ruby_fill_random_bytes
#define | SIP_HASH_STREAMING 0
#define | sip_hash13 ruby_sip_hash13
#define | BYTE_ORDER LITTLE_ENDIAN
#define | LITTLE_ENDIAN 1234
#define | BIG_ENDIAN 4321

## Typedefs
typedef int | int_must_be_32bit_at_least[sizeof(int) *CHAR_BIT< 32 ? -1 :1]

## Functions
unsigned int | rb_genrand_int32 (void)
double | rb_genrand_real (void)
| NORETURN (static void domain_error(void))
int | ruby_fill_random_bytes (void *seed, size_t size, int need_secure)
unsigned long | rb_genrand_ulong_limited (unsigned long limit)
unsigned int | rb_random_int32 (VALUE obj)
double | rb_random_real (VALUE obj)
unsigned long | rb_random_ulong_limited (VALUE obj, unsigned long limit)
VALUE | rb_random_bytes (VALUE obj, long n)
| NORETURN (static void invalid_argument(VALUE))
| NO_SANITIZE ("unsigned-integer-overflow", extern st_index_t rb_hash_start(st_index_t h))
st_index_t | rb_hash_start (st_index_t h)
st_index_t | rb_memhash (const void *ptr, long len)
void | Init_RandomSeedCore (void)
void | rb_reset_random_seed (void)
void | InitVM_Random (void)
void | Init_Random (void)

## Variables
VALUE | rb_cRandom

## Macro Definition Documentation

## ◆ BIG_ENDIAN

#define BIG_ENDIAN 4321

Definition at line 1408 of file random.c.

## ◆ BYTE_ORDER

#define BYTE_ORDER LITTLE_ENDIAN

Definition at line 1402 of file random.c.

## ◆ DEFAULT_SEED_CNT

#define DEFAULT_SEED_CNT 4

Definition at line 91 of file random.c.

## ◆ DEFAULT_SEED_LEN

#define DEFAULT_SEED_LEN (DEFAULT_SEED_CNT * (int)sizeof(int32_t))

Definition at line 275 of file random.c.

## ◆ fill_random_bytes

#define fill_random_bytes ruby_fill_random_bytes

Definition at line 441 of file random.c.

## ◆ fill_random_bytes_syscall

#define fill_random_bytes_syscall | ( |  | seed,
|  |  | size,
|  |  | need_secure
| ) |  | -1

Definition at line 430 of file random.c.

## ◆ fill_random_bytes_urandom

#define fill_random_bytes_urandom | ( |  | seed,
|  |  | size
| ) |  | -1

Definition at line 320 of file random.c.

## ◆ id_minus

#define id_minus '-'

Definition at line 153 of file random.c.

## ◆ id_plus

#define id_plus '+'

Definition at line 154 of file random.c.

## ◆ LITTLE_ENDIAN

#define LITTLE_ENDIAN 1234

Definition at line 1405 of file random.c.

## ◆ sip_hash13

#define sip_hash13 ruby_sip_hash13

Definition at line 1397 of file random.c.

## ◆ SIP_HASH_STREAMING

#define SIP_HASH_STREAMING 0

Definition at line 1396 of file random.c.

## ◆ SIZEOF_INT32

#define SIZEOF_INT32 (31/CHAR_BIT + 1)

Definition at line 128 of file random.c.

## ◆ USE_DEV_URANDOM

#define USE_DEV_URANDOM 0

Definition at line 280 of file random.c.

## Typedef Documentation

## ◆ int_must_be_32bit_at_least

typedef int int_must_be_32bit_at_least[sizeof(int) *CHAR_BIT< 32 ? -1 :1]

Definition at line 47 of file random.c.

## Function Documentation

## ◆ Init_Random()

void Init_Random | ( | void |  | ) |

Definition at line 1576 of file random.c.

## ◆ Init_RandomSeedCore()

void Init_RandomSeedCore | ( | void |  | ) |

Definition at line 1453 of file random.c.

References DEFAULT_SEED_CNT.

## ◆ InitVM_Random()

void InitVM_Random | ( | void |  | ) |

Definition at line 1530 of file random.c.

References rb_define_global_function().

## ◆ NO_SANITIZE()

NO_SANITIZE | ( | "unsigned-integer-overflow" | ,
|  | extern st_index_t | rb_hash_startst_index_t h
| ) |  |

## ◆ NORETURN() [1/2]

NORETURN | ( | static void | domain_errorvoid | ) |

## ◆ NORETURN() [2/2]

NORETURN | ( | static void | invalid_argumentVALUE | ) |

## ◆ rb_genrand_int32()

unsigned int rb_genrand_int32 | ( | void |  | ) |

Definition at line 115 of file random.c.

## ◆ rb_genrand_real()

double rb_genrand_real | ( | void |  | ) |

Definition at line 122 of file random.c.

## ◆ rb_genrand_ulong_limited()

unsigned long rb_genrand_ulong_limited | ( | unsigned long | limit | ) |

Definition at line 807 of file random.c.

## ◆ rb_hash_start()

st_index_t rb_hash_start | ( | st_index_t | h | ) |

Definition at line 1434 of file random.c.

References st_hash_start.

## ◆ rb_memhash()

st_index_t rb_memhash | ( | const void * | ptr,
|  | long | len
| ) |  |

Definition at line 1440 of file random.c.

References h, and sip_hash13.

Referenced by rb_dbl_long_hash(), and rb_str_hash().

## ◆ rb_random_bytes()

VALUE rb_random_bytes | ( | VALUE | obj,
|  | long | n
| ) |  |

Definition at line 1021 of file random.c.

## ◆ rb_random_int32()

unsigned int rb_random_int32 | ( | VALUE | obj | ) |

Definition at line 835 of file random.c.

## ◆ rb_random_real()

double rb_random_real | ( | VALUE | obj | ) |

Definition at line 870 of file random.c.

## ◆ rb_random_ulong_limited()

unsigned long rb_random_ulong_limited | ( | VALUE | obj,
|  | unsigned long | limit
| ) |  |

Definition at line 930 of file random.c.

## ◆ rb_reset_random_seed()

void rb_reset_random_seed | ( | void |  | ) |

Definition at line 1498 of file random.c.

## ◆ ruby_fill_random_bytes()

int ruby_fill_random_bytes | ( | void * | seed,
|  | size_t | size,
|  | int | need_secure
| ) |  |

Definition at line 434 of file random.c.

## Variable Documentation

## ◆ key

seed_keys_t key

Definition at line 1419 of file random.c.

## ◆ u32

uint32_t u32[type_roomof(seed_keys_t, uint32_t)]

Definition at line 1420 of file random.c.