php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_random.h File Reference
#include "php.h"
#include "php_random_csprng.h"
#include "php_random_uint128.h"

Go to the source code of this file.

Data Structures

struct  _php_random_status_state_mt19937
 
struct  _php_random_status_state_pcgoneseq128xslrr64
 
struct  _php_random_status_state_xoshiro256starstar
 
struct  _php_random_status_state_user
 
struct  _php_random_result
 
struct  _php_random_algo
 
struct  _php_random_algo_with_state
 
struct  _php_random_fallback_seed_state
 
struct  _php_random_engine
 
struct  _php_random_randomizer
 

Macros

#define PHP_MT_RAND_MAX   ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */
 
#define PHP_RANDOM_RANGE_ATTEMPTS   (50)
 
#define Z_RANDOM_ENGINE_P(zval)
 
#define Z_RANDOM_RANDOMIZER_P(zval)
 
#define phpext_random_ptr   &random_module_entry
 
#define RANDOM_G(v)
 

Typedefs

typedef struct _php_random_fallback_seed_state php_random_fallback_seed_state
 
typedef struct _php_random_status_state_mt19937 php_random_status_state_mt19937
 
typedef struct _php_random_status_state_pcgoneseq128xslrr64 php_random_status_state_pcgoneseq128xslrr64
 
typedef struct _php_random_status_state_xoshiro256starstar php_random_status_state_xoshiro256starstar
 
typedef struct _php_random_status_state_user php_random_status_state_user
 
typedef struct _php_random_result php_random_result
 
typedef struct _php_random_algo php_random_algo
 
typedef struct _php_random_algo_with_state php_random_algo_with_state
 
typedef struct _php_random_engine php_random_engine
 
typedef struct _php_random_randomizer php_random_randomizer
 

Enumerations

enum  php_random_mt19937_mode { MT_RAND_MT19937 = 0 , MT_RAND_PHP = 1 }
 

Functions

PHPAPI double php_combined_lcg (void)
 
PHPAPI uint64_t php_random_generate_fallback_seed (void)
 
PHPAPI uint64_t php_random_generate_fallback_seed_ex (php_random_fallback_seed_state *state)
 
PHPAPI void php_mt_srand (uint32_t seed)
 
PHPAPI uint32_t php_mt_rand (void)
 
PHPAPI zend_long php_mt_rand_range (zend_long min, zend_long max)
 
PHPAPI zend_long php_mt_rand_common (zend_long min, zend_long max)
 
PHPAPI voidphp_random_status_alloc (const php_random_algo *algo, const bool persistent)
 
PHPAPI voidphp_random_status_copy (const php_random_algo *algo, void *old_status, void *new_status)
 
PHPAPI void php_random_status_free (void *status, const bool persistent)
 
PHPAPI php_random_enginephp_random_engine_common_init (zend_class_entry *ce, zend_object_handlers *handlers, const php_random_algo *algo)
 
PHPAPI void php_random_engine_common_free_object (zend_object *object)
 
PHPAPI zend_objectphp_random_engine_common_clone_object (zend_object *object)
 
PHPAPI uint32_t php_random_range32 (php_random_algo_with_state engine, uint32_t umax)
 
PHPAPI uint64_t php_random_range64 (php_random_algo_with_state engine, uint64_t umax)
 
PHPAPI zend_long php_random_range (php_random_algo_with_state engine, zend_long min, zend_long max)
 
PHPAPI const php_random_algophp_random_default_algo (void)
 
PHPAPI voidphp_random_default_status (void)
 
PHPAPI zend_stringphp_random_bin2hex_le (const void *ptr, const size_t len)
 
PHPAPI bool php_random_hex2bin_le (zend_string *hexstr, void *dest)
 
PHPAPI void php_random_mt19937_seed32 (php_random_status_state_mt19937 *state, uint32_t seed)
 
PHPAPI void php_random_mt19937_seed_default (php_random_status_state_mt19937 *state)
 
PHPAPI void php_random_pcgoneseq128xslrr64_seed128 (php_random_status_state_pcgoneseq128xslrr64 *s, php_random_uint128_t seed)
 
PHPAPI void php_random_pcgoneseq128xslrr64_advance (php_random_status_state_pcgoneseq128xslrr64 *state, uint64_t advance)
 
PHPAPI void php_random_xoshiro256starstar_seed64 (php_random_status_state_xoshiro256starstar *state, uint64_t seed)
 
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 void php_random_xoshiro256starstar_jump (php_random_status_state_xoshiro256starstar *state)
 
PHPAPI void php_random_xoshiro256starstar_jump_long (php_random_status_state_xoshiro256starstar *state)
 
PHPAPI double php_random_gammasection_closed_open (php_random_algo_with_state engine, double min, double max)
 
PHPAPI double php_random_gammasection_closed_closed (php_random_algo_with_state engine, double min, double max)
 
PHPAPI double php_random_gammasection_open_closed (php_random_algo_with_state engine, double min, double max)
 
PHPAPI double php_random_gammasection_open_open (php_random_algo_with_state engine, double min, double max)
 
 PHP_MINIT_FUNCTION (random)
 
 PHP_MSHUTDOWN_FUNCTION (random)
 
 PHP_RINIT_FUNCTION (random)
 

Variables

PHPAPI const php_random_algo php_random_algo_mt19937
 
PHPAPI const php_random_algo php_random_algo_pcgoneseq128xslrr64
 
PHPAPI const php_random_algo php_random_algo_xoshiro256starstar
 
PHPAPI const php_random_algo php_random_algo_secure
 
PHPAPI const php_random_algo php_random_algo_user
 
PHPAPI zend_class_entryrandom_ce_Random_Engine
 
PHPAPI zend_class_entryrandom_ce_Random_CryptoSafeEngine
 
PHPAPI zend_class_entryrandom_ce_Random_RandomError
 
PHPAPI zend_class_entryrandom_ce_Random_BrokenRandomEngineError
 
PHPAPI zend_class_entryrandom_ce_Random_RandomException
 
PHPAPI zend_class_entryrandom_ce_Random_Engine_PcgOneseq128XslRr64
 
PHPAPI zend_class_entryrandom_ce_Random_Engine_Mt19937
 
PHPAPI zend_class_entryrandom_ce_Random_Engine_Xoshiro256StarStar
 
PHPAPI zend_class_entryrandom_ce_Random_Engine_Secure
 
PHPAPI zend_class_entryrandom_ce_Random_Randomizer
 
PHPAPI zend_class_entryrandom_ce_Random_IntervalBoundary
 
zend_module_entry random_module_entry
 
bool combined_lcg_seeded
 
bool mt19937_seeded
 
php_random_fallback_seed_state fallback_seed_state
 
int32_t combined_lcg [2]
 
php_random_status_state_mt19937 mt19937
 

Macro Definition Documentation

◆ PHP_MT_RAND_MAX

#define PHP_MT_RAND_MAX   ((zend_long) (0x7FFFFFFF)) /* (1<<31) - 1 */

Definition at line 50 of file php_random.h.

◆ PHP_RANDOM_RANGE_ATTEMPTS

#define PHP_RANDOM_RANGE_ATTEMPTS   (50)

Definition at line 57 of file php_random.h.

◆ phpext_random_ptr

#define phpext_random_ptr   &random_module_entry

Definition at line 191 of file php_random.h.

◆ RANDOM_G

#define RANDOM_G ( v)
Value:
uint32_t v
Definition cdf.c:1237
#define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v)
Definition zend_API.h:274

◆ Z_RANDOM_ENGINE_P

#define Z_RANDOM_ENGINE_P ( zval)
Value:
php_random_engine_from_obj(Z_OBJ_P(zval))
struct _zval_struct zval
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990

Definition at line 147 of file php_random.h.

◆ Z_RANDOM_RANDOMIZER_P

#define Z_RANDOM_RANDOMIZER_P ( zval)
Value:
php_random_randomizer_from_obj(Z_OBJ_P(zval));

Definition at line 149 of file php_random.h.

Typedef Documentation

◆ php_random_algo

◆ php_random_algo_with_state

◆ php_random_engine

◆ php_random_fallback_seed_state

◆ php_random_randomizer

◆ php_random_result

◆ php_random_status_state_mt19937

◆ php_random_status_state_pcgoneseq128xslrr64

◆ php_random_status_state_user

◆ php_random_status_state_xoshiro256starstar

Enumeration Type Documentation

◆ php_random_mt19937_mode

Enumerator
MT_RAND_MT19937 
MT_RAND_PHP 

Definition at line 52 of file php_random.h.

Function Documentation

◆ php_combined_lcg()

PHPAPI double php_combined_lcg ( void )

Definition at line 397 of file random.c.

◆ PHP_MINIT_FUNCTION()

PHP_MINIT_FUNCTION ( random )

Definition at line 729 of file random.c.

◆ PHP_MSHUTDOWN_FUNCTION()

PHP_MSHUTDOWN_FUNCTION ( random )

Definition at line 797 of file random.c.

◆ php_mt_rand()

PHPAPI uint32_t php_mt_rand ( void )

Definition at line 448 of file random.c.

◆ php_mt_rand_common()

PHPAPI zend_long php_mt_rand_common ( zend_long min,
zend_long max )

Definition at line 463 of file random.c.

◆ php_mt_rand_range()

PHPAPI zend_long php_mt_rand_range ( zend_long min,
zend_long max )

Definition at line 455 of file random.c.

◆ php_mt_srand()

PHPAPI void php_mt_srand ( uint32_t seed)

Definition at line 441 of file random.c.

◆ php_random_bin2hex_le()

PHPAPI zend_string * php_random_bin2hex_le ( const void * ptr,
const size_t len )

Definition at line 332 of file random.c.

◆ php_random_default_algo()

PHPAPI const php_random_algo * php_random_default_algo ( void )

Definition at line 306 of file random.c.

◆ php_random_default_status()

PHPAPI void * php_random_default_status ( void )

Definition at line 313 of file random.c.

◆ php_random_engine_common_clone_object()

PHPAPI zend_object * php_random_engine_common_clone_object ( zend_object * object)

Definition at line 277 of file random.c.

◆ php_random_engine_common_free_object()

PHPAPI void php_random_engine_common_free_object ( zend_object * object)

Definition at line 269 of file random.c.

◆ php_random_engine_common_init()

PHPAPI php_random_engine * php_random_engine_common_init ( zend_class_entry * ce,
zend_object_handlers * handlers,
const php_random_algo * algo )

Definition at line 253 of file random.c.

◆ php_random_gammasection_closed_closed()

PHPAPI double php_random_gammasection_closed_closed ( php_random_algo_with_state engine,
double min,
double max )

Definition at line 102 of file gammasection.c.

◆ php_random_gammasection_closed_open()

PHPAPI double php_random_gammasection_closed_open ( php_random_algo_with_state engine,
double min,
double max )

Definition at line 74 of file gammasection.c.

◆ php_random_gammasection_open_closed()

PHPAPI double php_random_gammasection_open_closed ( php_random_algo_with_state engine,
double min,
double max )

Definition at line 134 of file gammasection.c.

◆ php_random_gammasection_open_open()

PHPAPI double php_random_gammasection_open_open ( php_random_algo_with_state engine,
double min,
double max )

Definition at line 162 of file gammasection.c.

◆ php_random_generate_fallback_seed()

PHPAPI uint64_t php_random_generate_fallback_seed ( void )

Definition at line 716 of file random.c.

◆ php_random_generate_fallback_seed_ex()

PHPAPI uint64_t php_random_generate_fallback_seed_ex ( php_random_fallback_seed_state * state)

Definition at line 644 of file random.c.

◆ php_random_hex2bin_le()

PHPAPI bool php_random_hex2bin_le ( zend_string * hexstr,
void * dest )

Definition at line 358 of file random.c.

◆ php_random_mt19937_seed32()

PHPAPI void php_random_mt19937_seed32 ( php_random_status_state_mt19937 * state,
uint32_t seed )
inline

Definition at line 128 of file engine_mt19937.c.

◆ php_random_mt19937_seed_default()

PHPAPI void php_random_mt19937_seed_default ( php_random_status_state_mt19937 * state)

Definition at line 240 of file engine_mt19937.c.

◆ php_random_pcgoneseq128xslrr64_advance()

PHPAPI void php_random_pcgoneseq128xslrr64_advance ( php_random_status_state_pcgoneseq128xslrr64 * state,
uint64_t advance )

Definition at line 117 of file engine_pcgoneseq128xslrr64.c.

◆ php_random_pcgoneseq128xslrr64_seed128()

PHPAPI void php_random_pcgoneseq128xslrr64_seed128 ( php_random_status_state_pcgoneseq128xslrr64 * s,
php_random_uint128_t seed )
inline

Definition at line 38 of file engine_pcgoneseq128xslrr64.c.

◆ php_random_range()

PHPAPI zend_long php_random_range ( php_random_algo_with_state engine,
zend_long min,
zend_long max )

Definition at line 293 of file random.c.

◆ php_random_range32()

PHPAPI uint32_t php_random_range32 ( php_random_algo_with_state engine,
uint32_t umax )

◆ php_random_range64()

PHPAPI uint64_t php_random_range64 ( php_random_algo_with_state engine,
uint64_t umax )

Definition at line 139 of file random.c.

◆ php_random_status_alloc()

PHPAPI void * php_random_status_alloc ( const php_random_algo * algo,
const bool persistent )

Definition at line 238 of file random.c.

◆ php_random_status_copy()

PHPAPI void * php_random_status_copy ( const php_random_algo * algo,
void * old_status,
void * new_status )

Definition at line 243 of file random.c.

◆ php_random_status_free()

PHPAPI void php_random_status_free ( void * status,
const bool persistent )

Definition at line 248 of file random.c.

◆ php_random_xoshiro256starstar_jump()

PHPAPI void php_random_xoshiro256starstar_jump ( php_random_status_state_xoshiro256starstar * state)

Definition at line 165 of file engine_xoshiro256starstar.c.

◆ php_random_xoshiro256starstar_jump_long()

PHPAPI void php_random_xoshiro256starstar_jump_long ( php_random_status_state_xoshiro256starstar * state)

Definition at line 171 of file engine_xoshiro256starstar.c.

◆ php_random_xoshiro256starstar_seed256()

PHPAPI void php_random_xoshiro256starstar_seed256 ( php_random_status_state_xoshiro256starstar * state,
uint64_t s0,
uint64_t s1,
uint64_t s2,
uint64_t s3 )
inline

Definition at line 85 of file engine_xoshiro256starstar.c.

◆ php_random_xoshiro256starstar_seed64()

PHPAPI void php_random_xoshiro256starstar_seed64 ( php_random_status_state_xoshiro256starstar * state,
uint64_t seed )
inline

Definition at line 93 of file engine_xoshiro256starstar.c.

◆ PHP_RINIT_FUNCTION()

PHP_RINIT_FUNCTION ( random )

Definition at line 806 of file random.c.

Variable Documentation

◆ combined_lcg

int32_t combined_lcg[2]

Definition at line 201 of file php_random.h.

◆ combined_lcg_seeded

bool combined_lcg_seeded

Definition at line 198 of file php_random.h.

◆ fallback_seed_state

php_random_fallback_seed_state fallback_seed_state

Definition at line 200 of file php_random.h.

◆ mt19937

Definition at line 202 of file php_random.h.

◆ mt19937_seeded

bool mt19937_seeded

Definition at line 199 of file php_random.h.

◆ php_random_algo_mt19937

PHPAPI const php_random_algo php_random_algo_mt19937
extern

Definition at line 231 of file engine_mt19937.c.

◆ php_random_algo_pcgoneseq128xslrr64

PHPAPI const php_random_algo php_random_algo_pcgoneseq128xslrr64
extern

Definition at line 108 of file engine_pcgoneseq128xslrr64.c.

◆ php_random_algo_secure

PHPAPI const php_random_algo php_random_algo_secure
extern

Definition at line 49 of file engine_secure.c.

◆ php_random_algo_user

PHPAPI const php_random_algo php_random_algo_user
extern

Definition at line 76 of file engine_user.c.

◆ php_random_algo_xoshiro256starstar

PHPAPI const php_random_algo php_random_algo_xoshiro256starstar
extern

Definition at line 157 of file engine_xoshiro256starstar.c.

◆ random_ce_Random_BrokenRandomEngineError

PHPAPI zend_class_entry* random_ce_Random_BrokenRandomEngineError
extern

◆ random_ce_Random_CryptoSafeEngine

PHPAPI zend_class_entry* random_ce_Random_CryptoSafeEngine
extern

◆ random_ce_Random_Engine

PHPAPI zend_class_entry* random_ce_Random_Engine
extern

◆ random_ce_Random_Engine_Mt19937

PHPAPI zend_class_entry* random_ce_Random_Engine_Mt19937
extern

◆ random_ce_Random_Engine_PcgOneseq128XslRr64

PHPAPI zend_class_entry* random_ce_Random_Engine_PcgOneseq128XslRr64
extern

◆ random_ce_Random_Engine_Secure

PHPAPI zend_class_entry* random_ce_Random_Engine_Secure
extern

◆ random_ce_Random_Engine_Xoshiro256StarStar

PHPAPI zend_class_entry* random_ce_Random_Engine_Xoshiro256StarStar
extern

◆ random_ce_Random_IntervalBoundary

PHPAPI zend_class_entry* random_ce_Random_IntervalBoundary
extern

◆ random_ce_Random_RandomError

PHPAPI zend_class_entry* random_ce_Random_RandomError
extern

◆ random_ce_Random_RandomException

PHPAPI zend_class_entry* random_ce_Random_RandomException
extern

◆ random_ce_Random_Randomizer

PHPAPI zend_class_entry* random_ce_Random_Randomizer
extern

◆ random_module_entry

zend_module_entry random_module_entry
extern

Definition at line 816 of file random.c.