Commit graph

181 commits

Author SHA1 Message Date
David CARLIER
e91d2c719f
zend: ZEND_NONSTRING for clang >= 20 support (#19193) 2025-07-20 22:27:06 +01:00
David Carlier
2c42479890
Merge branch 'PHP-8.4' 2025-07-18 18:02:46 +01:00
David Carlier
f1a77c0198
Merge branch 'PHP-8.3' into PHP-8.4 2025-07-18 18:02:02 +01:00
Petr Sumbera
be09985c87
Fix GH-19169: ZEND_STATIC_ASSERT for -std=c++17
needs to define ZEND_STATIC_ASSERT to appropriate C++ static_assert
instead of the C version.
2025-07-18 18:00:24 +01:00
Calvin Buckley
964a404451
Use C23 unreachable() when possible (#19077)
This is a macro defined in stddef, which is already included in this
header. Since this is a macro, we can just check for the define rather
than add any additional build system checks.

Fixes GH-18975
2025-07-09 11:27:25 -03:00
Niels Dossche
8d116a4ba1
Implement GH-15483: Use C23 memset_explicit() for ZEND_SECURE_ZERO() if available (#18713) 2025-06-29 14:29:28 +02:00
Daniil Gentili
591b3249da
Do not use RTLD_DEEPBIND if dlmopen is available (#18612)
DL_LOAD now doesn't use RTLD_DEEPBIND deepbind anymore on platforms
where dlmopen with LM_ID_NEWLM is available:
this means shared library symbol isolation (if needed) must be enabled on
the user side when requiring libphp.so, by using dlmopen with LM_ID_NEWLM
instead of dlopen.
RTLD_DEEPBIND is still enabled when the Apache SAPI is in use.

Closes GH-10670.
2025-06-23 21:44:58 +02:00
Niels Dossche
3d51ba3479
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix ZEND_NONSTRING attribute for data_file.c
2025-05-28 19:50:06 +02:00
Niels Dossche
ea69276fd5
Fix GH-17687: initializer-string for array of ... warnings
Starting with gcc 15 the warning `-Wunterminated-string-initialization`
is enabled by default. We make now use of the `nonstring` attribute to
silence the warning for the cases where this is intended.

Closes GH-18603.
2025-05-27 20:28:29 +02:00
Christoph M. Becker
252dd1e9f0
Building ext/intl fails with MSVC /std:c11 (#17179)
A previous fix to be able to build C++ extensions with MSVC[1], was
based on the assumption that `max_align_t` would be defined in stddef.h
on Windows.  That was plain wrong; there is no such typedef (or macro).

Thus we revert that fix, and instead make an exception for Windows,
where we always use the fallback definition, which should work fine on
Windows.

[1] <ab449a7e46>
2025-02-20 15:14:58 +01:00
David CARLIER
b296712403
zend: gcc 15 will support counted_by(x) instead. (#17790)
gcc gave up on the initial patchset for `element_count` and went
by `counted_by` since last october.
2025-02-14 12:22:10 +00:00
Christoph M. Becker
300811f1e2
Remove support for unsupported MSVC versions (GH-17128)
As of PHP 8.4.0, MSVC >= 1920 (aka. Visual Studio 2019 RTW 16.0) is
required anyway[1], so we can clean up a bit.

[1] <b3d6414b87>
2024-12-12 19:50:14 +01:00
Ilija Tovilo
fbb97aa6fc
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix unstable get_iterator pointer for hooked classes in shm on Windows
2024-12-09 17:14:46 +01:00
Ilija Tovilo
792f63df45
Fix unstable get_iterator pointer for hooked classes in shm on Windows
Closes GH-17034
2024-12-09 17:14:19 +01:00
Ilija Tovilo
fb257ee83c
Upgrade master to Ubuntu 24.04 (GH-16704) 2024-11-07 16:32:45 +01:00
Christoph M. Becker
836a162089
Don't fiddle with NDEBUG in C code (GH-16511)
* Don't fiddle with NDEBUG in C code

It is way to late to do this in php.h, since assert.h has already been
included.  Even pushing that down to zend_portability.h may not have
the desired effect.  Instead we define or undefine NDEBUG as CFLAG, so
that it works in all circumstances.

As a last resort we fail at build time, if `NDEBUG` is defined when
`ZEND_DEBUG` is enabled.

We also remove the useless workaround in zend_test to include assert.h
again, since that usually won't have any effect anyway.

Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2024-10-27 18:20:59 +01:00
Christoph M. Becker
825509ee9e
Drop superfluous LONG_MAX/LONG_MIN fallback definitions (GH-15667)
Both macros are supposed to be defined in limits.h (C99) and as such it
is superfluous to provide fallback definitions.  Even worse, because
these fallback definitions didn't cater to LP64, ILP64 and SILP64 data
models (and maybe some rather uncommon ones), but just assumed ILP32,
they are confusing.
2024-09-27 17:34:54 +02:00
Christoph M. Becker
f16cb1866a
Fix ZEND_FASTCALL definition wrt. x64 Windows clang builds (GH-15425)
As is, MSVC uses `__vectorcall`, but clang uses `__cdecl`.  This
obviously is bad for interoperability (and causes link issues), and is
likely worse for FFI which offers some limited (but likely sufficient
for our purposes) support for `__vectorcall` on Windows.

Since clang claims to support `__vectorcall` as of 3.6.0, and we bumped
the requirements to clang 4.0.0 already, there shouldn't be any issues.
2024-08-18 12:20:09 +02:00
Christoph M. Becker
ab449a7e46
Add missing cstddef include for C++ builds
Closes GH-15096.
2024-07-25 14:33:03 +02:00
Saki Takamachi
8a4a30469a
Zend: Add ZEND_BYTES_SWAP32/ZEND_BYTES_SWAP64 (#14910) 2024-07-22 17:57:16 +09:00
David CARLIER
8d597150ee
zend build making sigjmp_buf and api check as mandatory. (#14942)
* zend build making sigjmp_buf and api check as mandatory.

all unixes support it since long time, the few which don't do not meet
the requirements to build php anyway (minix, dietlibc, ...).
2024-07-17 22:18:35 +01:00
Peter Kokot
9e94d2b040
Autotools: Refactor builtin checks (#14835)
This creates a single M4 macro PHP_CHECK_BUILTIN and removes other
PHP_CHECK_BUILTIN_* macros. Checks are wrapped in AC_CACHE_CHECK and
PHP_HAVE_BUILTIN_* CPP macro definitions are defined to 1 if builtin
is found and undefined if not.

This also changes all PHP_HAVE_BUILTIN_ symbols to be either undefined
or defined (to value 1) and syncs all #if/ifdef/defined usages of them
in the php-src code. This way it is simpler to use them because they
don't need to be defined to value 0 on Windows, for example. This is
done as previous usages in php-src were mixed and on many places they
were only checked with ifdef.
2024-07-08 21:25:16 +02:00
Peter Kokot
d7ddf83dde
Autotools: Refactor AVX-512 checks (#14831)
* Autotools: Refactor AVX-512 checks

- CS synced
- checks wrapped in AC_CACHE_CHECK
- CPP macros PHP_HAVE_AVX512_SUPPORTS and PHP_HAVE_AVX512_VBMI_SUPPORTS
  are now either defined to 1 or undefined to avoid manual defining on
  Windows (previously they should be either 0 or 1)

* [skip ci] Add basic macros help texts
2024-07-05 15:18:26 +02:00
Peter Kokot
a6b5439e2e
Fix warnings function declaration isn't a prototype (#14577)
This fixes the -Wstrict-prototypes warnings that might pop up in certain
builds.
2024-06-15 21:27:56 +02:00
Arnaud Le Blanc
d1048a0869
Add zend_random_bytes(), zend_random_bytes_insecure() functions (#14054)
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2024-06-12 17:27:01 +02:00
Arnaud Le Blanc
44c199ce6b
random: Make php_random_bytes() useable early during engine startup (#14291)
php_random_bytes() can now be used before RANDOM_G() is initialized
2024-05-30 17:24:34 +02:00
Ilija Tovilo
529a71ff2e
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix __SANITIZE_ADDRESS__ redeclaration warning
2024-04-29 16:14:24 +02:00
Ilija Tovilo
5bac4a6471
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix __SANITIZE_ADDRESS__ redeclaration warning
2024-04-29 16:14:16 +02:00
Ilija Tovilo
d670e131df
Fix __SANITIZE_ADDRESS__ redeclaration warning 2024-04-29 16:13:49 +02:00
Ilija Tovilo
2f894389b6
Revert "Use __attribute__((assume())) in ZEND_ASSUME when available"
This reverts commit bf4ec8bd9d.

Partial revert, keep the phpdbg changes.
2024-02-08 11:59:36 +01:00
Peter Kokot
e76f9e2b50
Remove DARWIN symbol (#13346)
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.
2024-02-07 21:07:48 +01:00
Ilija Tovilo
bf4ec8bd9d
Use __attribute__((assume())) in ZEND_ASSUME when available
Closes GH-13171
2024-01-19 09:25:55 +01:00
David CARLIER
cc2bf11951
zend: introducing ZEND_ELEMENT_COUNT for struct's dynamic arrays. (#12650)
zend: introducing ZEND_ELEMENT_COUNT for struct's dynamic and flexible arrays.

It is mostly for ubsan and helping array bound checking.
2023-11-13 12:42:45 +00:00
Ilija Tovilo
94c1e559f9
Merge branch 'PHP-8.3'
* PHP-8.3:
  Implement diagnostic ignore macro for Clang
2023-10-18 17:38:12 +02:00
Ilija Tovilo
80b4c73030
Implement diagnostic ignore macro for Clang
Newer versions of Clang now also complain about -Wscript-prototypes for included
headers.

Closes GH-12467
2023-10-18 17:37:15 +02:00
Ilija Tovilo
62e2402534
Use autoconf for recognizing __builtin_unreachable() (#12266)
Older versions of GCC don't support __has_builtin(), but do support
__builtin_unreachable().
2023-09-22 11:53:09 +02:00
Ilija Tovilo
37ce7199f2
Use __builtin_unreachable() directly in ZEND_UNREACHABLE
ZEND_UNREACHABLE() currently expands to the following in GCC:

    if (__builtin_expect(!(0), 0)) __builtin_unreachable();

Even though the branch is always executed, GCC does not recognize the outer
branch as unreachable. Removing the if fixes some unexpected warnings.

Closes GH-12248
2023-09-20 15:44:02 +02:00
Tony Su
bf123da562
[Zend]: Fix unnecessary alignment in ZEND_CALL_FRAME_SLOT macro (#10988)
Alignment is not necessary while calculating slots reserved for
zend_execute_data and _zend_vm_stack.

ZEND_STATIC_ASSERT ensures the correct alignment while code
compilation. Credit is to Ilija Tovilo.

PR: https://github.com/php/php-src/pull/10988

Signed-off-by: Tony Su <tao.su@intel.com>
Reviewed-by  : Ilija Tovilo
Reviewed-by  : Dmitry Stogov
Reviewed-by  : Niels Dossche
2023-04-04 12:09:38 +02:00
Ilija Tovilo
d98963a071
Switch to Ubuntu 22.04 for GitHub actions jobs
Closes GH-10814
2023-03-10 00:17:23 +01:00
Max Kellermann
413844d626
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
2023-02-18 19:31:28 +00:00
Frank Du
a9437ceb6f
base64: add avx512 and vbmi version. (#6361)
1. Implementation based on https://github.com/WojciechMula/base64simd
2. Only runtime path is added to reduce the complexity of SIMD variants.
3. Expand test case to cover SIMD implementation.

Signed-off-by: Frank Du <frank.du@intel.com>
2023-02-13 03:30:47 +00:00
David CARLIER
90b0e77921
GNU compilers remove hot attribute proposal. (#8922)
While the cold attribute has its place, the hot one however
does one have real justification for use, even more so with
modern toolchains.
2023-01-25 19:51:22 +00:00
Christoph M. Becker
2d3427c507
Revert "#include cleanup (#10216)"
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit e628c66f9d.
2023-01-16 12:29:41 +01:00
George Peter Banyard
d7f624258d
Merge branch 'PHP-8.2'
* PHP-8.2:
  fix: indirect_return compilation warning
2023-01-10 15:23:44 +00:00
George Peter Banyard
c936c02119
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  fix: indirect_return compilation warning
2023-01-10 15:23:35 +00:00
Kévin Dunglas
55514a1119
fix: indirect_return compilation warning
Closes GH-10274

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-10 15:23:15 +00:00
Max Kellermann
e628c66f9d
#include cleanup (#10216)
Shift header include

In the C file, include the header first so missing #includes are
detected by the compiler, and use lighter header dependencies in the
header, to speed up compile times.
2023-01-04 13:24:28 +00:00
David CARLIER
cf503eb374
porting ZEND_ASSUME for clang for the optimiser with (#9651)
a given condition.

using `__builtin_assume` instead of the actual generic solution,
 disable `-Wassume` warning for the ZEND_ASSERT cases.
2022-10-03 22:58:06 +01:00
David Carlier
db64c1cb70 zend introduce const GNUC attribute. sub optimisation where there is no pointers, nor particular memory layout, thread local/volatile ... involved. usage concealed for now into little pack helpers.
Closes #9326.
2022-08-15 19:49:24 +01:00
David CARLIER
f51fbf9fc4
zend allocators adding __declspec allocator for windows. (#9253)
does not affect the performance, however making those custom calls more meaningful
 for Event Tracing/Visual Studio.
2022-08-05 12:26:35 +01:00