1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

493 Commits

Author SHA1 Message Date
Peter Kokot
f17c5ad83b Windows build: Add new function CHECK_HEADER() (#21191)
The current function `CHECK_HEADER_ADD_INCLUDE()` automatically defines
`HAVE_<HEADER_NAME_H>` preprocessor macros, which makes it difficult to
sync with other build systems. Specially, if some `HAVE_` macro is used
in the code and this function defines this macro but Autotools doesn't.

The new `CHECK_HEADER()` function behaves similar except it doesn't
define the `HAVE_<HEADER_NAME_H>` preprocessor macro.

This removes the following unused compile definitions:

HAVE_ARGON2_H
HAVE_AVIF_H
HAVE_BZLIB_H
HAVE_CAPSTONE_CAPSTONE_H
HAVE_CURL_EASY_H
HAVE_DB_H
HAVE_DECODE_H
HAVE_DEPOT_H
HAVE_EDITLINE_READLINE_H
HAVE_ENCHANT_H
HAVE_ENCODE_H
HAVE_FFI_H
HAVE_FIREBIRD_INTERFACE_H
HAVE_FT2BUILD_H
HAVE_GD_H
HAVE_GLIB_H
HAVE_GMP_H
HAVE_HTTPD_H
HAVE_IBASE_H
HAVE_IR_IR_H
HAVE_KECCAKHASH_H
HAVE_LBER_H
HAVE_LDAP_H
HAVE_LIBEXSLT_EXSLT_H
HAVE_LIBINTL_H
HAVE_LIBPQ_FE_H
HAVE_LIBTIDY_TIDY_H
HAVE_LIBXML_PARSER_H
HAVE_LIBXML_TREE_H
HAVE_LIBXML_XMLWRITER_H
HAVE_LIBXSLT_XSLT_H
HAVE_LMDB_H
HAVE_MBSTRING_H
HAVE_MYSQL_H
HAVE_ONIGURUMA_H
HAVE_OPENSSL_SSL_H
HAVE_PNG_H
HAVE_SNMP_H
HAVE_SODIUM_H
HAVE_SQLITE3_H
HAVE_SQLITE3EXT_H
HAVE_SYBFRONT_H
HAVE_TIDY_H
HAVE_TIDY_TIDY_H
HAVE_TIDYBUFFIO_H
HAVE_TIMELIB_CONFIG_H
HAVE_UNICODE_USPOOF_H
HAVE_UNICODE_UTF_H
HAVE_XPM_H
HAVE_ZIP_H
HAVE_ZIPCONF_H
HAVE_ZLIB_H

The following compile definitions are defined explicitly:

- HAVE_ICONV_H
- HAVE_MSCOREE_H
- HAVE_SQL_H
- HAVE_SQLEXT_H

Additionally, the `SETUP_OPENSSL()` function doesn't accept the 6th
argument anymore.
2026-03-03 20:06:40 +01:00
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Tim Düsterhus
ce566f2663 gmp: Use true / false instead of 1 / 0 when assigning to bool
Changes done with Coccinelle:

    @@
    bool b;
    @@

    - b = 0
    + b = false

    @@
    bool b;
    @@

    - b = 1
    + b = true
2025-09-24 18:51:40 +02:00
Gina Peter Banyard
37549e4563 ext/gmp: Remove bool type coercions in tests 2025-06-21 22:19:37 +02:00
Florian Moser
90da4821a2 ext/gmp: Add GMP ECC test (#18363)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
2025-05-05 14:10:29 +01:00
Niels Dossche
a142f10aa1 Don't evaluate GMP comparison multiple times (#18321)
ZEND_THREEWAY_COMPARE evaluates its operands multiple times.
2025-04-14 11:19:14 +02:00
Gina Peter Banyard
c5edf94003 ext/gmp: Use zend_result type instead of int type 2025-04-11 22:53:20 +01:00
David CARLIER
05a155782b ext/gmp: use zend_object_alloc instead to initialize GMP instances. (#17822) 2025-02-15 19:09:36 +00:00
brainpower
47942be18d ext/gmp: add test for uses of gmp_pow with number sizes commonly used in cryptography (#16896)
With common number sizes used there

---------

Co-authored-by: Florian Moser <git@famoser.ch>
2024-12-04 16:17:00 +00:00
Gina Peter Banyard
f8547b1d97 ext/gmp: Check for valid bit index/start consistently 2024-11-29 16:55:38 +00:00
David Carlier
424ba0f2ff Finish reverting gmp_pow overflow check 2024-11-27 23:34:48 +00:00
Niels Dossche
0833f2376e Use specialised zend_new_pair() function to return array pairs in gmp
This is a bit faster, and more readable.
2024-11-27 23:34:23 +00:00
David Carlier
7b9b832be5 Merge branch 'PHP-8.4' 2024-11-27 19:55:04 +00:00
David Carlier
bceb3adb42 Merge branch 'PHP-8.3' into PHP-8.4 2024-11-27 19:54:23 +00:00
David Carlier
841e54daee Merge branch 'PHP-8.2' into PHP-8.3 2024-11-27 19:54:06 +00:00
David Carlier
7e8d6f941c Revert "ext/gmp: gmp_pow fix FPE with large values."
This reverts commit d70b7811b0.
2024-11-27 19:52:07 +00:00
David Carlier
45140e527f Revert "ext/gmp: gmp_pow fix FPE with large values."
This reverts commit e0a0e216a9.
2024-11-27 19:52:04 +00:00
Gina Peter Banyard
eaffa1150a ext/gmp: Compare object CE to gmp_ce directly
The GMP class is now final, therefore we don't need to use the instanceof function.
2024-11-27 19:08:50 +00:00
Gina Peter Banyard
313886e22b ext/gmp: Refactor op overloading for ZEND_BW_NOT
The only way for the do_operation object handler to be called for unary operations is when the zval is an object.
Therefore we know we have a zval of the correct type and there is no need to check for it.
2024-11-27 19:08:50 +00:00
Gina Peter Banyard
0800c68be6 ext/gmp: Remove redundant parenthesis 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
0b5b9472ff Normalize gmp_cmp() to -1/0/+1 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
89eaa1fe5f ext/gmp: Refactor gmp_cmp() test 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
601f6cd54d ext/gmp: Use new parsing mechanism in comparison operator overloading
This removes the last usages of the old GMP_FETCH API
2024-11-27 15:10:49 +00:00
Gina Peter Banyard
92ff44da12 ext/gmp: Use new parsing API in shift helper 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
0831608c8b ext/gmp: Add weak mode support for parsing 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
27044108d3 ext/gmp: Convert GMP operator overloading to new parsing mechanism 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
8b2cd8fd2d ext/gmp: Start refactoring operator overloading to use new parsing mechanism 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
2681da4531 ext/gmp: Refactor gmp_fact() to use new ZPP specifier
Not sure it is the best approach to do this one however
2024-11-27 15:10:49 +00:00
Gina Peter Banyard
5199904c57 ext/gmp: Remove now unused FETCH_GMP_ZVAL_DEP_DEP macro 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
fabfb6fe00 ext/gmp: Refactor gmp_divexact() and gmp_mod() to use custom ZPP specifier 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
8e9b944a83 ext/gmp: Refactor gmp_div_(q|r)() to use new ZPP specifier 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
1f5ba59b61 ext/gmp: Refactor gmp_div_qr() to use new ZPP specifier 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
376c148fb8 ext/gmp: Refactor gmp_random_range() to use new ZPP specifier 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
3964efd729 ext/gmp: Use new specifier for gmp_cmp()
It seems that this also now normalizes the return value
2024-11-27 15:10:49 +00:00
Gina Peter Banyard
1e3876039f ext/gmp: Refactor generation of some binary GMP functions 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
a9e2a96e69 ext/gmp: Refactor generation of unary GMP functions 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
10003a3f5d ext/gmp: Use new custom ZPP specifier 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
290f69662a ext/gmp: Create custom Fast ZPP specifier to parse into mpz_ptr
We define module globals to be used with ZPP, which also avoids excessive initializing and clearing of variables,
something recommended by the GMP documentation.
2024-11-27 15:10:49 +00:00
Gina Peter Banyard
2313a465b6 Inline gmp_unary_opl() as it was only used once
That use being gmp_popcount()
2024-11-27 15:10:49 +00:00
Gina Peter Banyard
9ee1265e0c ext/gmp: Use Fast ZPP for GMP functions 2024-11-27 15:10:49 +00:00
Gina Peter Banyard
57ae2c9530 ext/gmp: Split out non-existent inverse modulo cases 2024-11-27 15:10:49 +00:00
Christoph M. Becker
bd6b9df5dd Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16890: array_sum() with GMP can loose precision (LLP64)
2024-11-25 12:55:58 +01:00
Christoph M. Becker
cfcf5cfde8 Fix GH-16890: array_sum() with GMP can loose precision (LLP64)
We must use `mpz_fits_si_p()` instead of `mpz_fits_slong_p()` since the
latter is not suitable for LLP64 data models.

libgmp, however, does not define `mpz_fits_si_p()` (which is an mpir
addition), so we use `mpz_fits_slong_p()` there which should be fine.

Closes GH-16891.
2024-11-25 12:55:09 +01:00
Gina Peter Banyard
9e2367f29f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/gmp: Fix segfault when null is encountered on an overloaded operator
  ext/gmp: Add behavioural tests for operator overloading
2024-11-02 17:41:27 +00:00
Gina Peter Banyard
65d42342a1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/gmp: Fix segfault when null is encountered on an overloaded operator
  ext/gmp: Add behavioural tests for operator overloading
2024-11-02 17:40:41 +00:00
Gina Peter Banyard
5253647500 ext/gmp: Fix segfault when null is encountered on an overloaded operator
And various other issues like inconsistent type errors

Closes GH-16015
2024-11-02 17:36:32 +00:00
Gina Peter Banyard
fe02fd5095 ext/gmp: Add behavioural tests for operator overloading 2024-11-02 17:32:43 +00:00
David Carlier
9ee204f2e3 Merge branch 'PHP-8.3' into PHP-8.4 2024-10-25 14:05:16 +01:00
David Carlier
aa38bbed40 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-25 14:05:07 +01:00
David Carlier
e0a0e216a9 ext/gmp: gmp_pow fix FPE with large values.
even without sanitizers, it is reproducible but with the following

```
<?php
$g = gmp_init(256);
var_dump(gmp_pow($g, PHP_INT_MAX));
```

we get this

```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==286922==ERROR: AddressSanitizer: FPE on unknown address 0x03e8000460ca (pc 0x7faf6c69de5c bp 0x400000000000004 sp 0x7ffe9843c740 T0)
    #0 0x7faf6c69de5c in __pthread_kill_implementation nptl/pthread_kill.c:44
    #1 0x7faf6c649c81 in __GI_raise ../sysdeps/posix/raise.c:26
    #2 0x7faf6db9386c in __gmp_exception (/lib/x86_64-linux-gnu/libgmp.so.10+0xd86c) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #3 0x7faf6db938d3 in __gmp_overflow_in_mpz (/lib/x86_64-linux-gnu/libgmp.so.10+0xd8d3) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #4 0x7faf6dbac95c in __gmpz_realloc (/lib/x86_64-linux-gnu/libgmp.so.10+0x2695c) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #5 0x7faf6dba9038 in __gmpz_n_pow_ui (/lib/x86_64-linux-gnu/libgmp.so.10+0x23038) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #6 0x5565ae1ccd9f in zif_gmp_pow /home/dcarlier/Contribs/php-src/ext/gmp/gmp.c:1286
    #7 0x5565aee96ea9 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:1312
    #8 0x5565af144320 in execute_ex /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:56075
    #9 0x5565af160f07 in zend_execute /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:60439
    #10 0x5565aed6fafe in zend_execute_scripts /home/dcarlier/Contribs/php-src/Zend/zend.c:1842
    #11 0x5565aeae70a8 in php_execute_script /home/dcarlier/Contribs/php-src/main/main.c:2578
    #12 0x5565af532f4e in do_cli /home/dcarlier/Contribs/php-src/sapi/cli/php_cli.c:964
    #13 0x5565af535877 in main /home/dcarlier/Contribs/php-src/sapi/cli/php_cli.c:1334
    #14 0x7faf6c633d67 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #15 0x7faf6c633e24 in __libc_start_main_impl ../csu/libc-start.c:360
    #16 0x5565adc04040 in _start (/home/dcarlier/Contribs/php-src/sapi/cli/php+0x2604040) (BuildId: 949049955bdf8b7197390b1978a1dfc3ef6fdf38)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE nptl/pthread_kill.c:44 in __pthread_kill_implementation
==286922==ABORTING
```

close GH-16384
2024-10-25 14:04:47 +01:00