Skip to content
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
1,693 changes: 851 additions & 842 deletions docs/bootstrap-inventory.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Auto-generated by `script/capability-matrix.php`. Do not edit by hand.
| `getopt` | yes | yes | yes | standard | JIT PHPT |
| `getprotobyname` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
| `getprotobynumber` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
| `getrandmax` | yes | yes | yes | standard | |
| `getrandmax` | yes | yes | yes | standard | JIT PHPT |
| `getrusage` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
| `getservbyname` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
| `getservbyport` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
Expand Down Expand Up @@ -513,6 +513,7 @@ Auto-generated by `script/capability-matrix.php`. Do not edit by hand.
| `mktime` | yes | yes | yes | standard | JIT PHPT |
| `modf` | yes | yes | yes | standard | AOT PHPT |
| `move_uploaded_file` | yes | yes | yes | standard | nested $_FILES + multipart web runtime (#52, #87); 006-FileUploadWeb; FILE_UPLOAD_WEB_AOT_SMOKE_GATE (#2012); FILE_UPLOAD_WEB_DEPLOY_SMOKE_GATE (#2028); JIT PHPT; AOT PHPT |
| `mt_getrandmax` | yes | yes | yes | standard | JIT PHPT |
| `mt_rand` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
| `mt_srand` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
| `natcasesort` | yes | yes | yes | standard | JIT PHPT; AOT PHPT |
Expand Down
1 change: 1 addition & 0 deletions docs/stdlib-jit-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Auto-generated by `script/audit-stdlib-jit.php`. Regenerate: `php script/audit-s
- `get_declared_variables` — `ext/standard/get_declared_variables_.php`
- `get_defined_vars` — `ext/standard/get_defined_vars_.php`
- `getrandmax` — `ext/standard/getrandmax.php`
- `mt_getrandmax` — `ext/standard/mt_getrandmax.php`
- `gzputs` — `ext/standard/gzputs.php`
- `parse_ini_file` — `ext/standard/parse_ini_file.php`
- `pfsockopen` — `ext/standard/pfsockopen.php`
Expand Down
1 change: 1 addition & 0 deletions ext/standard/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public function getFunctions(): array
new mt_srand(),
new srand(),
new getrandmax(),
new mt_getrandmax(),
new lcg_value(),
new uniqid(),
new str_pad(),
Expand Down
39 changes: 39 additions & 0 deletions ext/standard/mt_getrandmax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace PHPCompiler\ext\standard;

use PHPCompiler\Frame;
use PHPCompiler\Func\Internal;
use PHPCompiler\JIT\Context;
use PHPCompiler\JIT\Variable as JITVariable;
use PHPLLVM\Value;

/**
* mt_getrandmax() — MT upper bound (php-src ext/random/random.c, #17228).
*/
final class mt_getrandmax extends Internal
{
public function __construct()
{
parent::__construct('mt_getrandmax');
}

public function execute(Frame $frame): void
{
$this->requireExactArgCount($frame, 'mt_getrandmax', 0);
if (null === $frame->returnVar) {
return;
}
$frame->returnVar->int(VmMt19937::PHP_MT_RAND_MAX);
}

public function call(Context $context, JITVariable ...$args): Value
{
$this->requireExactJitArgCount($context, $args, 'mt_getrandmax', 0);
$i64 = $context->getTypeFromString('int64');

return $i64->constInt(VmMt19937::PHP_MT_RAND_MAX, false);
}
}
18 changes: 18 additions & 0 deletions test/compliance/cases/stdlib/mt_getrandmax.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
stdlib mt_getrandmax() — MT_RAND_MAX parity (#17228, ext/random/random.c)
--FILE--
<?php
echo function_exists('mt_getrandmax') ? "mt_getrandmax=yes\n" : "mt_getrandmax=no\n";
echo mt_getrandmax(), "\n";
echo getrandmax() === mt_getrandmax() ? "same_as_getrandmax=yes\n" : "same_as_getrandmax=no\n";
try {
mt_getrandmax(1);
echo "argcount=uncaught\n";
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
}
--EXPECT--
mt_getrandmax=yes
2147483647
same_as_getrandmax=yes
mt_getrandmax() expects exactly 0 arguments, 1 given
18 changes: 18 additions & 0 deletions test/compliance/cases/stdlib/mt_getrandmax_jit.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
stdlib mt_getrandmax() JIT — MT_RAND_MAX parity (#17228, ext/random/random.c)
--FILE--
<?php
echo function_exists('mt_getrandmax') ? "mt_getrandmax=yes\n" : "mt_getrandmax=no\n";
echo mt_getrandmax(), "\n";
echo getrandmax() === mt_getrandmax() ? "same_as_getrandmax=yes\n" : "same_as_getrandmax=no\n";
try {
mt_getrandmax(1);
echo "argcount=uncaught\n";
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
}
--EXPECT--
mt_getrandmax=yes
2147483647
same_as_getrandmax=yes
mt_getrandmax() expects exactly 0 arguments, 1 given
14 changes: 14 additions & 0 deletions test/repro/maintainer_gap_mt_getrandmax_missing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

echo function_exists('mt_rand') ? "mt_rand=yes\n" : "mt_rand=no\n";
echo function_exists('mt_getrandmax') ? "mt_getrandmax=yes\n" : "mt_getrandmax=no\n";
echo mt_getrandmax(), "\n";

try {
mt_getrandmax(1);
echo "argcount=uncaught\n";
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
}
1 change: 1 addition & 0 deletions test/selfhost/compiler_lib_spine_smoke/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,7 @@
require_once __DIR__.'/../../../ext/standard/getprotobyname.php';
require_once __DIR__.'/../../../ext/standard/getprotobynumber.php';
require_once __DIR__.'/../../../ext/standard/getrandmax.php';
require_once __DIR__.'/../../../ext/standard/mt_getrandmax.php';
require_once __DIR__.'/../../../ext/standard/getrusage.php';
require_once __DIR__.'/../../../ext/standard/getservbyname.php';
require_once __DIR__.'/../../../ext/standard/getservbyport.php';
Expand Down
1 change: 1 addition & 0 deletions test/unit/BootstrapSelfhostBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ final class BootstrapSelfhostBundleTest extends TestCase
'ext/standard/VmCombinedLcg.php',
'ext/standard/VmMt19937.php',
'ext/standard/getrandmax.php',
'ext/standard/mt_getrandmax.php',
'ext/standard/lcg_value.php',
'ext/standard/mt_rand.php',
'ext/standard/mt_srand.php',
Expand Down
Loading