This patch saves one CPU instruction on each "_tsrm_ls_cache" access in ZTS CLI/CGI/FPM builds.
This reduce typical instruction sequence for EG(current_execute_data) access from 4 to 3 CPU instructions.
On Mac thread_local and __thread are not ABI compatible, in addition, thread_local
comes with additional overhead, __thread seems to be the most suitable linkage to use
regardless of c++/c
If TSRM is shut down and started again (something that phpdbg does),
then tsrmls_id needs to be reloaded everywhere. As tsrmls_id
update is a rare operation, doing that shouldn't be a problem.
TSRM configuration header file was once created by separate autoconf
build system for TSRM and is with the current code not directly needed
like this anymore.
We're not checking the return value and the NTS version of this
generates warnings. If we want to handle lock failures, we should
do a hard abort inside tsrm_env_lock() itself.
The `<signal.h>` header file is part of the standard C89 headers [1] and
on current systems can be included unconditionally.
Since file requires at least C89 or greater, the `HAVE_SIGNAL_H` symbol
defined by Autoconf in Zend.m4 [2] can be ommitted and simplifed.
The bundled libmagic (file) also ommits the usage of HAVE_SIGNAL_H since
5.35 however current version in PHP is very modified 5.34 version and
will be refactored separately. Check for HAVE_SIGNAL_H is therefore
still done in the configure.ac.
Refs:
[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
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.
If a C++11 source is compiled, thread_local is preferred. Furthermore,
at least GCC treats __thread vs. thread_local a different way and under
certain circumstances would refuse to compile __thread is a C++11 source.
This change is far behind in time, any up-to-date compiler supports C++11
and otherwise it won't take effect on lower versions.
This patch however does not drop support for the BeOS compatible variant, Haiku, see Github PR #2697 which is currently a WiP
I intentionally left out some fragments for BeOS in the build system for that seems to be bundles
Hereby, interned strings are supported in thread safe PHP. The patch
implements two types of interned strings
- interning per process, strings are not freed till process end
- interning per request, strings are freed at request end
There is no runtime interning.
With Opcache, all the permanent iterned strings are copied into SHM on
startup, additional copying into SHM might happen on demand.
gdb seems to be not always able to fetch the correct context for
thread locals. Thus, the "if (TSRMLS_CACHE)" clause causes gdb to
show crashes which aren't recognized neither with helgrind nor
in release builds. This is reproducable by setting breakpoints on
the exact line where PHP has a tsrm_get_ls_cache() call.