30static inline uint64_t splitmix64(uint64_t *seed)
34 r = (*seed += 0x9e3779b97f4a7c15ULL);
35 r = (r ^ (r >> 30)) * 0xbf58476d1ce4e5b9ULL;
36 r = (r ^ (r >> 27)) * 0x94d049bb133111ebULL;
37 return (r ^ (r >> 31));
42 return (x << k) | (x >> (64 - k));
47 const uint64_t r = rotl(
s->state[1] * 5, 7) * 9;
48 const uint64_t t =
s->state[1] << 17;
50 s->state[2] ^=
s->state[0];
51 s->state[3] ^=
s->state[1];
52 s->state[1] ^=
s->state[2];
53 s->state[0] ^=
s->state[3];
57 s->state[3] = rotl(
s->state[3], 45);
64 uint64_t s0 = 0, s1 = 0, s2 = 0, s3 = 0;
66 for (uint32_t i = 0; i < 4; i++) {
67 for (uint32_t
j = 0;
j < 64;
j++) {
68 if (jmp[i] & 1ULL <<
j) {
69 s0 ^=
state->state[0];
70 s1 ^=
state->state[1];
71 s2 ^=
state->state[2];
72 s3 ^=
state->state[3];
75 generate_state(
state);
97 s[0] = splitmix64(&seed);
98 s[1] = splitmix64(&seed);
99 s[2] = splitmix64(&seed);
100 s[3] = splitmix64(&seed);
108 .size =
sizeof(uint64_t),
126 for (uint32_t i = 0; i < 4; i++) {
140 if (zend_hash_num_elements(
data) != 4) {
144 for (uint32_t i = 0; i < 4; i++) {
167 static const uint64_t jmp[] = {0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c};
173 static const uint64_t jmp[] = {0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635};
208 bool seed_is_null =
true;
219 if (php_random_bytes_throw(&t,
sizeof(t)) ==
FAILURE) {
223 }
while (
UNEXPECTED(t[0] == 0 && t[1] == 0 && t[2] == 0 && t[3] == 0));
233 for (uint32_t i = 0; i < 4; i++) {
235 for (uint32_t
j = 0;
j < 8;
j++) {
236 t[i] += ((uint64_t) (
unsigned char)
ZSTR_VAL(str_seed)[(i * 8) +
j]) << (
j * 8);
240 if (
UNEXPECTED(t[0] == 0 && t[1] == 0 && t[2] == 0 && t[3] == 0)) {
PHPAPI void php_random_xoshiro256starstar_seed64(php_random_status_state_xoshiro256starstar *state, uint64_t seed)
PHPAPI void php_random_xoshiro256starstar_jump_long(php_random_status_state_xoshiro256starstar *state)
PHPAPI void php_random_xoshiro256starstar_jump(php_random_status_state_xoshiro256starstar *state)
PHPAPI const php_random_algo php_random_algo_xoshiro256starstar
PHPAPI void php_random_xoshiro256starstar_seed256(php_random_status_state_xoshiro256starstar *state, uint64_t s0, uint64_t s1, uint64_t s2, uint64_t s3)
PHPAPI zend_string * php_random_bin2hex_le(const void *ptr, const size_t len)
PHPAPI bool php_random_hex2bin_le(zend_string *hexstr, void *dest)
struct _php_random_algo_with_state php_random_algo_with_state
PHPAPI zend_class_entry * random_ce_Random_RandomException
#define Z_RANDOM_ENGINE_P(zval)
PHPAPI zend_long php_random_range(php_random_algo_with_state engine, zend_long min, zend_long max)
struct _php_random_algo php_random_algo
struct _php_random_status_state_xoshiro256starstar php_random_status_state_xoshiro256starstar
struct _php_random_result php_random_result
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
#define ZEND_PARSE_PARAMETERS_END()
#define ZEND_PARSE_PARAMETERS_NONE()
#define Z_PARAM_STR_OR_LONG_OR_NULL(dest_str, dest_long, is_null)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
ZEND_API ZEND_COLD zend_object * zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code)
ZEND_API zval *ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
struct _zend_string zend_string
#define ZEND_ATTRIBUTE_CONST
#define UNEXPECTED(condition)
struct _zend_array HashTable
#define Z_STRLEN_P(zval_p)