From 16865f29a9a8ec0d2d0cd822e3bc262a0d0d64ba Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 9 Jul 2024 15:17:19 +0200 Subject: [PATCH] Fix compilation for PHP84+ PHP changed some includes for PHP8.4. This commit also adds php8.4-rc to the CI Reported-by: rainerjung --- .github/workflows/builds.yml | 1 + src/php_snuffleupagus.h | 10 ++++++++++ src/sp_harden_rand.h | 2 -- src/tweetnacl.c | 1 - 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 7578bbee..72294f16 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: container: + - php:8.4-rc - php:8.3 - php:8.2 - php:8.1 diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index 6e035d40..b4d1be1f 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h @@ -42,6 +42,7 @@ #include "ext/standard/php_string.h" #include "ext/standard/php_var.h" #include "ext/session/php_session.h" +#include "ext/hash/php_hash.h" #include "php.h" #include "php_ini.h" #include "rfc1867.h" @@ -58,9 +59,11 @@ #error Snuffleupagus only works with PHP7+. You shouldn't use PHP5 anyway, \ since it's not supported anymore: https://secure.php.net/supported-versions.php #endif + #if PHP_VERSION_ID < 70200 typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); #endif + #if PHP_VERSION_ID >= 80000 #define TSRMLS_FETCH() #define TSRMLS_C @@ -70,6 +73,13 @@ typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); #endif #endif +#if PHP_VERSION_ID < 80200 +#include "ext/standard/php_rand.h" +#include "ext/standard/php_random.h" +#else +#include "ext/random/php_random.h" +#endif + #define SP_CONFIG_VALID 1 #define SP_CONFIG_INVALID 0 #define SP_CONFIG_NONE -1 diff --git a/src/sp_harden_rand.h b/src/sp_harden_rand.h index bbe9be49..0721da05 100644 --- a/src/sp_harden_rand.h +++ b/src/sp_harden_rand.h @@ -1,8 +1,6 @@ #ifndef __SP_HARDEN_RAND_H #define __SP_HARDEN_RAND_H -#include "ext/standard/php_rand.h" -#include "ext/standard/php_random.h" #include "zend_exceptions.h" int hook_rand(void); diff --git a/src/tweetnacl.c b/src/tweetnacl.c index 746cabc2..e6d6ed25 100644 --- a/src/tweetnacl.c +++ b/src/tweetnacl.c @@ -1,7 +1,6 @@ /* Since TweetNacl doesn't come with a `randombytes` implementation, we're using the one from PHP.*/ #include "php_snuffleupagus.h" -#include "ext/standard/php_random.h" static void randombytes(unsigned char *x, unsigned long long xlen) { assert(SIZE_MAX >= ULLONG_MAX); // max(size_t) > max(ull) ?