Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/scripts/download-bundled/blake3.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/ext/hash/blake3/upstream_blake3/c/blake3.h b/ext/hash/blake3/upstream_blake3/c/blake3.h
index 35f2bb9..59f68a7 100644
--- a/ext/hash/blake3/upstream_blake3/c/blake3.h
+++ b/ext/hash/blake3/upstream_blake3/c/blake3.h
@@ -44,6 +44,7 @@ typedef struct {
uint64_t chunk_counter;
uint8_t buf[BLAKE3_BLOCK_LEN];
uint8_t buf_len;
+ uint8_t padding_1[5];
uint8_t blocks_compressed;
uint8_t flags;
} blake3_chunk_state;
@@ -58,6 +59,7 @@ typedef struct {
// don't know whether more input is coming. This is different from how the
// reference implementation does things.
uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN];
+ uint8_t padding_2[7];
} blake3_hasher;

BLAKE3_API const char *blake3_version(void);
37 changes: 37 additions & 0 deletions .github/scripts/download-bundled/blake3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
set -ex
cd "$(dirname "$0")/../../.."

tmp_dir=/tmp/php-src-download-bundled/blake3
rm -rf "$tmp_dir"

revision=refs/tags/1.8.3

git clone --depth 1 --revision="$revision" https://github.com/BLAKE3-team/BLAKE3.git "$tmp_dir"

rm -rf ext/hash/blake3/upstream_blake3
mkdir ext/hash/blake3/upstream_blake3
cp -R "$tmp_dir"/c ext/hash/blake3/upstream_blake3
cp "$tmp_dir"/LICENSE_CC0 ext/hash/blake3/upstream_blake3

cd ext/hash/blake3/upstream_blake3

# remove unneeded files
rm -R c/blake3_c_rust_bindings
rm -R c/cmake
rm -R c/dependencies
rm c/.gitignore
rm c/blake3_tbb.cpp
rm c/blake3-config.cmake.in
rm c/CMakeLists.txt
rm c/CMakePresets.json
rm c/example.c
rm c/example_tbb.c
rm c/libblake3.pc.in
rm c/main.c
rm c/Makefile.testing
rm c/README.md
rm c/test.py

# patch customized files
git apply -v ../../../../.github/scripts/download-bundled/blake3.h.patch
13 changes: 13 additions & 0 deletions .github/workflows/verify-bundled-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths: &paths
- '.github/scripts/download-bundled/**'
- 'Zend/asm/**'
- 'ext/hash/blake3/upstream_blake3/**'
- 'ext/pcre/pcre2lib/**'
- 'ext/uri/uriparser/**'
pull_request:
Expand Down Expand Up @@ -34,6 +35,9 @@ jobs:
'boost-context':
- '.github/scripts/download-bundled/boost-context.*'
- 'Zend/asm/**'
blake3:
- '.github/scripts/download-bundled/blake3.*'
- 'ext/hash/blake3/upstream_blake3/**'
pcre2:
- '.github/scripts/download-bundled/pcre2.*'
- 'ext/pcre/pcre2lib/**'
Expand All @@ -50,6 +54,15 @@ jobs:
echo "::group::Verify files"
.github/scripts/test-directory-unchanged.sh Zend/asm
echo "::endgroup::"
- name: BLAKE3
if: ${{ !cancelled() && (steps.changes.outputs.blake3 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
run: |
echo "::group::Download"
.github/scripts/download-bundled/blake3.sh
echo "::endgroup::"
echo "::group::Verify files"
.github/scripts/test-directory-unchanged.sh 'ext/hash/blake3/upstream_blake3'
echo "::endgroup::"
- name: PCRE2
if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
run: |
Expand Down
1 change: 1 addition & 0 deletions README.REDIST.BINS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
20. Lexbor (ext/lexbor/lexbor) see ext/lexbor/LICENSE
21. Portions of libcperciva (ext/hash/hash_sha_{ni,sse2}.c) see the header in the source file
22. uriparser (ext/uri/uriparser) see ext/uri/uriparser/COPYING
23. BLAKE3 (ext/hash/blake3) see ext/hash/blake3/upstream_blake3/LICENSE_CC0

3. pcre2lib (ext/pcre)

Expand Down
97 changes: 97 additions & 0 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2510,6 +2510,103 @@ AC_DEFUN([PHP_REMOVE_OPTIMIZATION_FLAGS], [
CXXFLAGS=$(echo "$CXXFLAGS" | $SED -e "$sed_script")
])

dnl
dnl PHP_CHECK_ARM_NEON_SUPPORT
dnl
dnl check if we're compiling for ARM NEON
dnl
AC_DEFUN([PHP_CHECK_ARM_NEON_SUPPORT], [
AC_CACHE_CHECK([for ARM NEON support],ac_cv_target_arm_neon,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main(void) {
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
return 0;
#else
return 1;
#endif
}
]])],[
ac_cv_target_arm_neon=yes
],[
ac_cv_target_arm_neon=no
],[
ac_cv_target_arm_neon=no
])])
])


dnl
dnl PHP_CHECK_X86_TARGET
dnl
dnl check if we're compiling for x86/x86_64
dnl
AC_DEFUN([PHP_CHECK_X86_TARGET], [
AC_CACHE_CHECK([for x86 target],ac_cv_target_x86,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main(void) {
#if defined(__x86_64__) || defined(__i386__)
return 0;
#else
return 1;
#endif
}
]])],[
ac_cv_target_x86=yes
],[
ac_cv_target_x86=no
],[
ac_cv_target_x86=no
])])
])

dnl
dnl PHP_CHECK_WINDOWS_TARGET
dnl
dnl check if we're compiling for windows
dnl
AC_DEFUN([PHP_CHECK_WINDOWS_TARGET], [
AC_CACHE_CHECK([for windows target],ac_cv_target_windows,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main(void) {
#if defined(_WIN32)
return 0;
#else
return 1;
#endif
}
]])],[
ac_cv_target_windows=yes
],[
ac_cv_target_windows=no
],[
ac_cv_target_windows=no
])])
])

dnl
dnl PHP_CHECK_UNIX_TARGET
dnl
dnl check if we're compiling for a unix-ish target
dnl
AC_DEFUN([PHP_CHECK_UNIX_TARGET], [
AC_CACHE_CHECK([for unix-ish target],ac_cv_target_unix,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main(void) {
#if defined(unix) || defined(__unix) || defined(__unix__)
return 0;
#else
return 1;
#endif
}
]])],[
ac_cv_target_unix=yes
],[
ac_cv_target_unix=no
],[
ac_cv_target_unix=no
])])
])

dnl
dnl PHP_C_STANDARD_LIBRARY
dnl
Expand Down
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ PHP_EBCDIC
dnl Check whether the system byte ordering is bigendian.
PHP_C_BIGENDIAN

dnl Check if we're targeting x86 / x86_64
PHP_CHECK_X86_TARGET

dnl Check if we're targeting ARM Neon CPUs
PHP_CHECK_ARM_NEON_SUPPORT


dnl Check if we're targeting Windows
PHP_CHECK_WINDOWS_TARGET

dnl Check whether we're targeting a unix-ish system
PHP_CHECK_UNIX_TARGET

dnl Check whether writing to stdout works.
PHP_TEST_WRITE_STDOUT

Expand Down
121 changes: 121 additions & 0 deletions ext/hash/blake3/upstream_blake3/LICENSE_CC0
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
Loading
Loading