Commit Graph

104 Commits

Author SHA1 Message Date
Max Kellermann
02690fe3c0 Zend/zend_types.h: move zend_string to zend_string.h
It is now possible to include only `zend_string.h` without
`zend_types.h`.
2023-02-26 14:16:53 +00:00
Max Kellermann
d6e95041e2 Zend/zend_types.h: move zend_rc_debug to zend_rc_debug.h
`zend_rc_debug` is not a type and does not really belong in
`zend_types.h`; this allows using `ZEND_RC_MOD_CHECK()` without
including the huge `zend_types.h` header and allows decoupling
circular header dependencies.
2023-02-26 14:16:53 +00:00
Niels Dossche
99b86141ae Introduce convenience macros for copying flags that hold when concatenating two strings
This abstracts away, and cleans up, the flag handling for properties of
strings that hold when concatenating two strings if they both hold that
property. (These macros also work with simply copies of strings because
a copy of a string can be considered a concatenation with the empty
string.) This gets rid of some branches and some repetitive code, and
leaves room for adding more flags like these in the future.
2023-02-05 14:32:50 +00:00
George Peter Banyard
64127b66c6 Concatenating two valid UTF-8 strings produces a valid UTF-8 string
The UTF-8 valid flag needs to be copied upon interning,
otherwise strings that are concatenated at compile time lose this information.

However, if previously this string was interned without the flag it is not added
E.g. in the case the string is an existing class name.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2023-02-02 12:02:36 +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
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
Alex Dowad
e2654a532a Mark default interned strings as valid UTF-8 where appropriate
Aside from being used by the pcre extension, various functions in
mbstring are faster if the input strings are known to be valid UTF-8.
We might as well mark the default interned strings (which are
initialized when PHP starts up) as valid UTF-8 where appropriate.
2023-01-03 09:02:21 +02:00
George Peter Banyard
be9adc4fbc
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix build with Valgrind without I_REPLACE_SONAME_FNNAME_ZU symbol
2022-05-07 16:48:23 +01:00
Martin Vobruba
b388e951b8
Fix build with Valgrind without I_REPLACE_SONAME_FNNAME_ZU symbol
Fixes #8453

Signed-off-by: George Peter Banyard <girgias@php.net>
2022-05-07 16:45:03 +01:00
George Peter Banyard
c2547ab7dc
Add some const qualifiers in zend_string/hash (#8304)
Co-authored-by: Levi Morrison <morrison.levi@gmail.com>
2022-04-20 15:56:51 +01:00
Max Kellermann
b9e895bca0
Replace memcmp() with zend_string functions (#8216)
* ext/oci8: use zend_string_equals()

Eliminate duplicate code.

* main/php_variables: use zend_string_equals_literal()

Eliminate duplicate code.

* Zend/zend_string: add zend_string_equals_cstr()

Allows eliminating duplicate code.

* Zend, ext/{opcache,standard}, main/output: use zend_string_equals_cstr()

Eliminate duplicate code.

* Zend/zend_string: add zend_string_starts_with()

* ext/{opcache,phar,spl,standard}: use zend_string_starts_with()

This adds missing length checks to several callers, e.g. in
cache_script_in_shared_memory().  This is important when the
zend_string is shorter than the string parameter, when memcmp()
happens to check backwards; this can result in an out-of-bounds memory
access.
2022-03-31 16:27:58 +02:00
Nikita Popov
4a4ae45a0b Fix bug #81142 by adding zend_string_init_existing_interned()
Add a new interned string handler that fetches an interned string
if it exists, but does not create one if it does not (and instead
returns a non-interned string).

This fixes bug #81142, by preventing the creating of new interned
strings for unserialized array keys.

Closes GH-7360.
2021-08-12 11:57:50 +02:00
Nikita Popov
a0c44fbaf1 Always define valgrind replacement symbol for zend_string_equal_val
The required symbol name seems to be very stable, so we can hardcode
a fallback. This avoids many false positives when PHP is not built
against valgrind.
2021-05-21 21:00:34 +02:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
Nikita Popov
4fb705a03d Add zend_string_concat2 API 2020-04-14 17:18:05 +02:00
Nikita Popov
d030ddb2cd Export the zend_string_concat3() API 2020-04-09 15:06:53 +02:00
Dmitry Stogov
5ffa5217fc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Check assert only when RC_DEBUG is enabled
2019-04-18 14:27:05 +03:00
Dmitry Stogov
3a04adce82 Check assert only when RC_DEBUG is enabled 2019-04-18 14:26:15 +03:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Dmitry Stogov
f80b1b0c56 Delay hash table allocation 2019-01-24 16:01:04 +03:00
jvoisin
fbdaabba62 Fix some sign-related issues in comparisons 2019-01-09 10:01:12 +01:00
Nikita Popov
12cbe930cd Merge branch 'PHP-7.3' 2018-11-13 12:31:44 +01:00
Jan Rękorajski
f76be1a0d6 Fix compilation on x32
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
2018-11-13 12:31:00 +01:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Dmitry Stogov
33e777acbf Improved shared interned strings handling. The previous implementation worked incorrectly in ZTS build. It changed strings only in function/class tables of one thread. Now all threads gets the same shared interned strings. Also, on shutdown, we don't try to replace SHM interned strings back to process strings, but delay dettachment of SHM instead. 2018-10-25 20:30:51 +03:00
Peter Kokot
be49d61b19 Remove old SVN keywords substitutions
When the PHP source code was versioned in Subversion, there was
possible to substitute certain keywords such as $Id$ with revision
number, last change time and author name. Such approach is not used
in Git so this patch removes these outdated artifacts from source
code files.
2018-06-16 13:04:30 +02:00
Dmitry Stogov
858d545ce6 micro optimization 2018-05-08 00:22:04 +03:00
Dmitry Stogov
cb464a53c8 Use "fastcall" calling convention 2018-04-04 01:12:59 +03:00
Dmitry Stogov
a795bd8265 Optimize zend_hash_real_init() 2018-03-23 00:13:45 +03:00
Dmitry Stogov
6f483dc94c Use macros to update specific parts of GC_TYPE_INFO() (direct assignments to GC_TYPE(), GC_FLAGS() and GC_INFO() are prohibited) 2018-02-28 00:52:12 +03:00
Dmitry Stogov
e43ac26356 Fixed string comparison (it may fail in case of not null-terminated strings) 2018-01-31 12:38:02 +03:00
Dmitry Stogov
53eb20f0cb Merge branch 'PHP-7.2'
* PHP-7.2:
  Restore initial values on graceful server restart.
2018-01-26 15:25:03 +03:00
Dmitry Stogov
aad12cb49c Restore initial values on graceful server restart. 2018-01-26 15:22:36 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Dmitry Stogov
4691cbe5d1 Fixed possible local assembler labels conflicts. 2017-12-20 21:44:24 +03:00
Nikita Popov
4e6b80ca54 Fix movzb operand size 2017-12-06 23:15:35 +01:00
Dmitry Stogov
1646042342 Use local labels 2017-12-06 17:47:30 +03:00
Dmitry Stogov
3beaf10289 Fixed gcc assembler constaints.
Added less efecient replacement functions for valgrind, to prevent warnings about uninitialized tail.
2017-12-06 15:32:31 +03:00
Dmitry Stogov
c019c131e8 Use unsigned comparison instructions 2017-12-05 02:41:12 +03:00
Dmitry Stogov
8305a73483 Implemented x86 and x86_64 assembler functions for zend_string equality check.
They take into account zend_string layout (value alignment and trailing padding) and perform comparison by double or quad words.
2017-12-04 23:40:54 +03:00
Dmitry Stogov
74c84cd7f0 Use zend_string_equal*() API for zend_string equality check instead of direct memcmp() usage. 2017-12-04 17:17:02 +03:00
Dmitry Stogov
26b2b27a25 Don't intern strings in-place if their refcoung greater than 1 2017-11-03 21:00:07 +03:00
Dmitry Stogov
f2b91b31e4 Switch back from "request" interned strings storage to "permanent" in MSHUTDOWN 2017-11-02 23:29:21 +03:00
Dmitry Stogov
49ea143bbd Encapsulate reference-counting primitives.
Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead.
Added mactros to validate reference-counting (disabled for now).
These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads.
2017-10-27 01:28:58 +03:00
Anatol Belski
efcce55360 Fix datatype 2017-10-19 10:26:39 +02:00
Dmitry Stogov
272f5a1716 Extend zend_string API to avoid reallocation in zend_string_init_interned() 2017-10-19 00:02:56 +03:00