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:
Victor Stinner 2018-08-01 17:56:14 +02:00 committed by GitHub
parent cfc8831f5e
commit 6c785c0ebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 1314 additions and 1288 deletions

View file

@ -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)