Move JIT check to BigInteger

This commit is contained in:
Daniil Gentili 2023-09-20 14:36:32 +02:00
parent 866cc78fbd
commit e113bb35e7
No known key found for this signature in database
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 12 additions and 11 deletions

View File

@ -29,6 +29,7 @@ namespace phpseclib3\Math;
use phpseclib3\Exception\BadConfigurationException;
use phpseclib3\Math\BigInteger\Engines\Engine;
use UnexpectedValueException;
/**
* Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256
@ -135,6 +136,16 @@ class BigInteger implements \JsonSerializable
private static function initialize_static_variables()
{
if (!isset(self::$mainEngine)) {
// see https://github.com/php/php-src/issues/11917
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && function_exists('opcache_get_status') && !defined('PHPSECLIB_ALLOW_JIT')) {
$status = opcache_get_status();
if ($status && isset($status['jit']) && $status['jit']['enabled'] && $status['jit']['on']) {
throw new UnexpectedValueException(
'JIT on Windows is not currently supported'
);
}
}
$engines = [
['GMP', ['DefaultEngine']],
['PHP64', ['OpenSSL']],

View File

@ -19,14 +19,4 @@ if (extension_loaded('mbstring')) {
'is not supported by phpseclib.'
);
}
}
// see https://github.com/php/php-src/issues/11917
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && function_exists('opcache_get_status') && !defined('PHPSECLIB_ALLOW_JIT')) {
$status = opcache_get_status();
if ($status && isset($status['jit']) && $status['jit']['enabled'] && $status['jit']['on']) {
throw new UnexpectedValueException(
'JIT on Windows is not currently supported'
);
}
}
}