From e113bb35e76c657705063181af758f529c7ed77e Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 20 Sep 2023 14:36:32 +0200 Subject: [PATCH] Move JIT check to BigInteger --- phpseclib/Math/BigInteger.php | 11 +++++++++++ phpseclib/bootstrap.php | 12 +----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index c6609e4d..99690817 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -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']], diff --git a/phpseclib/bootstrap.php b/phpseclib/bootstrap.php index b794d549..c84c60dc 100644 --- a/phpseclib/bootstrap.php +++ b/phpseclib/bootstrap.php @@ -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' - ); - } -} +} \ No newline at end of file