This removes the unused and obsolete Zend/zend_istdiostream.h header and
symbols on Windows:
- HAVE_STDIOSTR_H
- HAVE_CLASS_ISTDIOSTREAM
- istdiostream
The ext/pdo_mysql symbol has been once used together with the removed
ext/mysql extension and isn't defined on Windows neither used in the
code anymore.
- CONFIGURATION_FILE_PATH
Removed via 2cf1b8d345.
- DISCARD_PATH
Used for the --enable-discard-path CGI configure option and converted
to INI configuration. Removed via
06f43b30c1.
- HAVE_ERRMSG_H
Removed via fd1578c196.
- HAVE_REGCOMP
Used for regcomp function.
- HAVE_RINT
Used for rint function.
- NEED_ISBLANK
Windows ctype.h once didn't have C99 isblank() function. Cannot be
found on current Windows systems anymore, neither was used in PHP at
least since PHP 4.0.
- PHP_URL_FOPEN
Removed via cae27179ce.
- REGEX
Not used in current code.
- HSREGEX
Not used in current code.
- USE_CONFIG_FILE
Symbol was once defined by the --with-config-file-path configure
option.
Adds support for "Caseless restricted" matching added in PCRE2lib
10.43 with the "r" modifier.
This is `PCRE2_EXTRA_CASELESS_RESTRICT` in PCRE2. This is an "extra"
option, which means it is not possible to pass this option as
pcre2_compile() function parameter.
This option is passed in a pcre2_set_compile_extra_options() call.
Previously, these extra options are set at php_pcre_init_pcre2(),
but after this change, it is possible to customize the options
by adding bits to `eoptions` in pcre_get_compiled_regex_cache_ex().
The tests for this change are ported from upstream test suite[^1].
[^1]: https://github.com/PCRE2Project/pcre2/commit/c13d54f6581#diff-8c8312e4eb2d35bb16485404b7b5cc0eaef0bca1aa95ff5febf6a1890048305c
* random: Expose xoshiro256**'s seeding functions
* random: Expose pcgoneseq128xslrr64's seeding functions
* random: Expose Mt19937's seeding functions
* random: Expose CombinedLCG's seeding functions
* random: Call php_random_mt19937_seed32 to seed the global Mt19937
This avoids the function pointer indirection and improves type safety.
* random: NULL the generic seeding function
Different engines work quite differently, it is not useful to attempt to seed
them in a generic way using a 64 bit integer. As an example Mt19937 completely
ignores the upper 32 bits.
* random: Remove the `seed` member from `php_random_algo`
See the explanation in the previous commit for the reasoning. This member is
unused since the previous commit and was not consistently available even before
that (specifically for the Secure engine).
* UPGRADING.INTERNALS
* random: Remove useless cast in `php_mt_srand()`
The PHP_CHECK_GCC_ARG has been already removed in PHP 8.0 and this also
removes the error emitting wrapper.
Patches for the solr and vld extensions have been sent upstream.
* random: Remove `php_random_status`
Since 162e1dce98, the `php_random_status` struct
contains just a single `void*`, resulting in needless indirection when
accessing the engine state and thus decreasing readability because of the
additional non-meaningful `->state` references / the local helper variables.
There is also a small, but measurable performance benefit:
<?php
$e = new Random\Engine\Xoshiro256StarStar(0);
$r = new Random\Randomizer($e);
for ($i = 0; $i < 15; $i++)
var_dump(strlen($r->getBytes(100000000)));
goes from roughly 3.85s down to 3.60s.
The names of the `status` variables have not yet been touched to keep the diff
small. They will be renamed to the more appropriate `state` in a follow-up
cleanup commit.
* Introduce `php_random_algo_with_state`
On some systems (Haiku) the math library is part of the C library and it
doesn't need to be explicitly prepended to LIBS. The redundant HAVE_LIBM
symbol defined by the AC_CHECK_LIB has been removed.
AC_SEARCH_LIBS can be used to check for dlopen and if dl library needs
to be prepended to LIBS. The dlsym is available with the same scope as
dlopen (if dlopen is present, also dlsym is). The redundant HAVE_DLOPEN
and HAVE_DLSYM symbols have been removed.
Instead of the project macro, the sockaddr_storage and sockaddr.sa_len
can be checked with the AC_CHECK_TYPES and AC_CHECK_MEMBERS by including
the sys/socket.h. Some systems (~1988) didn't include the sys/types.h in
the socket.h (obsolete on current systems).
These macros by default define the HAVE_STRUCT_SOCKADDR_STORAGE and
HAVE_STRUCT_SOCKADDR_SA_LEN.
The struct flock is defined in fcntl.h, if system has it. This removes
redundant PHP_STRUCT_FLOCK M4 macro in favor of the AC_CHECK_TYPES,
which by default defines symbol HAVE_STRUCT_FLOCK.
This macro is obsolete in favor of the PHP_ARG_WITH macro. It was once
used in combination with the AC_ARG_WITH macro to determine, whether the
extension has been configured as shared.
PHP_DEFINE was introduced with the PHP 5 build system
9d9d39a0de and then refactored via
350de12bc2.
This was once used to put defined constants into a single file to have
more fine-graned dependencies (atomic includes). Since no known PHP
extension is using this and it makes very little sense to use this, this
M4 macro can be removed in favor of the Autoconf native way using
AC_DEFINE and the usual included files php_config.h and config.h.
- Generated unused include directory removed
- Remove include dir from DEFS
- Remove also include dir from PDO checks
SunOS 4.1.4 from 1994 didn't have fclose declared in standard header
stdio.h. This doesn't need to be checked anymore, as fclose is part of
the C89+ standard and declaration is present on Solaris 10 (SunOS 5.10)
and later.
When targeting Darwin systems (macOS, etc.), the compiler defines the
__APPLE__ symbol, which should be sufficient and a more established
detection method practice in these cases.
* Refactor utsname.domainname struct member Autoconf check
Autoconf's AC_CHECK_MEMBERS macro (available since Autoconf 2.50) can be
used instead of the compile check. This was originally implemented for
IRIX compatibility, when Autoconf 2.13 didn't have the struct members
checking macro yet.
Macro by default here defines the HAVE_STRUCT_UTSNAME_DOMAINNAME symbol.
* Remove also redundant DARWIN symbol check
Checking in the configuration step also correctly detects missing struct
member on Darwin systems (macos...).
The imap extension has been moved to PECL. Adding a note about configure
options changes also in the UPGRADING.INTERNALS for easier build scripts
adjustments.
This allows consumers of just the CSPRNG to include a much smaller header. It
also allows to verify at a glance whether a source file might use non-secure
randomness.
This commit includes the new header wherever the CSPRNG is used, possibly
replacing the inclusion of php_random.h if nothing else is used, but also
includes it in the main php_random.h header for compatibility.
Somewhat related to 45f8cfaf10,
2b30f18708, and
b14dd85dca.
When ext/random was initially added in PHP 8.2, these headers started
“forwarding” to the new ext/random/php_random.h to reduce the impact on
existing extensions.
As master already contains some breaking changes of the internal API of
ext/random and as the last PHP version without ext/random will be EOL once
master is released, it appears appropriate to drop these headers now.
Instead of returning the generated `uint64_t` and providing the size (i.e. the
number of bytes of the generated value) out-of-band via the
`last_generated_size` member of the `php_random_status` struct, the `generate`
function is now expected to return a new `php_random_result` struct containing
both the `size` and the `result`.
This has two benefits, one for the developer:
It's no longer possible to forget setting `last_generated_size` to the correct
value, because it now happens at the time of returning from the function.
and the other benefit is for performance:
The `php_random_result` struct will be returned as a register pair, thus the
`size` will be directly available without reloading it from main memory.
Checking a simplified version of `php_random_range64()` on Compiler Explorer
(“Godbolt”) with clang 17 shows a single change in the resulting assembly
showcasing the improvement (https://godbolt.org/z/G4WjdYxqx):
- add rbp, qword ptr [r14]
+ add rbp, rdx
Empirical testing confirms a measurable performance increase for the
`Randomizer::getBytes()` method:
<?php
$e = new Random\Engine\Xoshiro256StarStar(0);
$r = new Random\Randomizer($e);
var_dump(strlen($r->getBytes(100000000)));
goes from 250ms (before the change) to 220ms (after the change). While
generating 100 MB of random data certainly is not the most common use case, it
confirms the theoretical improvement in practice.
This shrinks the struct from 80 bytes to 72 bytes.
This was unused internally, I did not find users externally via GitHub
search.
The intention for this was that it could be used for attaching extra
data as a 3rd party to a node. However, there are better mechanisms for
that like using actual objects.
* Update signature of pcre API
This changes the variables that are bools to actually be bools instead
of ints, which allows some additional optimization by the compiler (e.g.
removing some ternaries and move extensions).
It also gets rid of the use_flags argument because that's just the same
as flags == 0. This reduces the call frame.
* Use zend_string_release_ex where possible
* Remove duplicate symbols from strchr
* Avoid useless value conversions
* Use a raw HashTable* instead of a zval
* Move condition
* Make for loop cheaper by reusing a recently used value as start iteration index
* Remove useless condition
This can't be true if the second condition is true because it would
require the string to occupy the entire address space.
* Upgrading + remark
Commit d86314939c added an additional parameter to Z_PARAM_FUNC_EX.
To maintain compatibility with third-party extensions, we keep
Z_PARAM_FUNC_EX as it used to be, and add Z_PARAM_FUNC_EX2 instead.
This macro is no longer used within php-src since
60ace13f9c, it invokes undefined behavior
depending on the input and the corresponding MT_RAND_PHP mode was deprecated in
PHP 8.3.
Thus remove this macro. Any remaining non-php-src user should just inline it
into their code, but should ideally migrate to a non-biased scaler. In any case
the undefined behavior of the original implementation should be accounted for.