mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
bpo-34170: Add Python/coreconfig.c for _PyCoreConfig (GH-8607)
* Add Include/coreconfig.h * Move config_*() and _PyCoreConfig_*() functions from Modules/main.c to a new Python/coreconfig.c file. * Inline _Py_ReadHashSeed() into config_init_hash_seed() * Move global configuration variables to coreconfig.c
This commit is contained in:
parent
cfc8831f5e
commit
6c785c0ebd
14 changed files with 1314 additions and 1288 deletions
|
@ -538,35 +538,6 @@ _PyOS_URandomNonblock(void *buffer, Py_ssize_t size)
|
|||
return pyurandom(buffer, size, 0, 1);
|
||||
}
|
||||
|
||||
int
|
||||
_Py_ReadHashSeed(const char *seed_text,
|
||||
int *use_hash_seed,
|
||||
unsigned long *hash_seed)
|
||||
{
|
||||
Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
|
||||
/* Convert a text seed to a numeric one */
|
||||
if (seed_text && *seed_text != '\0' && strcmp(seed_text, "random") != 0) {
|
||||
const char *endptr = seed_text;
|
||||
unsigned long seed;
|
||||
seed = strtoul(seed_text, (char **)&endptr, 10);
|
||||
if (*endptr != '\0'
|
||||
|| seed > 4294967295UL
|
||||
|| (errno == ERANGE && seed == ULONG_MAX))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
/* Use a specific hash */
|
||||
*use_hash_seed = 1;
|
||||
*hash_seed = seed;
|
||||
}
|
||||
else {
|
||||
/* Use a random hash */
|
||||
*use_hash_seed = 0;
|
||||
*hash_seed = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
_PyInitError
|
||||
_Py_HashRandomization_Init(const _PyCoreConfig *config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue