Skip to content

Commit

Permalink
Fix compilation for PHP84+
Browse files Browse the repository at this point in the history
PHP changed some includes for PHP8.4. This commit also adds php8.4-rc to the CI

Reported-by: rainerjung
  • Loading branch information
jvoisin committed Jul 9, 2024
1 parent 1f349ea commit 6ca65b6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
container:
- php:8.4-rc
- php:8.3
- php:8.2
- php:8.1
Expand Down
10 changes: 10 additions & 0 deletions src/php_snuffleupagus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/sp_harden_rand.h
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Set a custom session handler
--SKIPIF--
<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
<?php if (!extension_loaded("session")) print "skip"; ?>
<?php if (PHP_VERSION_ID >= 80400) print "skip"; /* Calling session_set_save_handler() with more than 2 arguments is deprecated */ ?>
--EXTENSIONS--
session
--INI--
Expand Down
1 change: 0 additions & 1 deletion src/tweetnacl.c
Original file line number Diff line number Diff line change
@@ -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) ?
Expand Down

0 comments on commit 6ca65b6

Please sign in to comment.