Skip to content

random: Remove internal aliases for the global Mt19937 functionality #14314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- The macro RAND_RANGE_BADSCALING() has been removed. The implementation
should either be inlined and undefined behavior fixed or it should be
replaced by a non-biased scaler.
- The php_srand() and php_rand() functions have been removed. These were
slim wrappers around the corresponding php_mt_srand() and php_mt_rand()
function since PHP 7.1, but using zend_long instead of uint32_t as their
input/output types. This made their behavior incompatible between 32-bit
and 64-bit builds of PHP. Users of these functions are encouraged to
migrate to one of the more modern engines provided since PHP 8.2. If that
is not possible, due to backwards compatibility requirements, then the
php_mt_srand() and php_mt_rand() functions should be called directly and
the values appropriately casted.
- The PHP_RAND_MAX and RAND_MAX constants corresponding to the removed
php_rand() have also been removed.
- The generate member of a php_random_algo is now expected to return
the new php_random_result struct, replacing the last_generated_size
member of the php_random_status struct and the generate_size member of
Expand Down
9 changes: 0 additions & 9 deletions ext/random/php_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ 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);

# ifndef RAND_MAX
# define RAND_MAX PHP_MT_RAND_MAX
# endif

# define PHP_RAND_MAX PHP_MT_RAND_MAX

PHPAPI void php_srand(zend_long seed);
PHPAPI zend_long php_rand(void);

typedef struct _php_random_status_state_combinedlcg {
int32_t state[2];
} php_random_status_state_combinedlcg;
Expand Down
14 changes: 0 additions & 14 deletions ext/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,20 +446,6 @@ PHPAPI zend_long php_mt_rand_common(zend_long min, zend_long max)
}
/* }}} */

/* {{{ php_srand */
PHPAPI void php_srand(zend_long seed)
{
php_mt_srand((uint32_t) seed);
}
/* }}} */

/* {{{ php_rand */
PHPAPI zend_long php_rand(void)
{
return php_mt_rand();
}
/* }}} */

/* {{{ Returns a value from the combined linear congruential generator */
PHP_FUNCTION(lcg_value)
{
Expand Down
Loading