Skip to content

Commit 3b951e7

Browse files
authored
Rename HAVE_DECL_ARC4RANDOM_BUF to HAVE_ARC4RANDOM_BUF (#14565)
AC_CHECK_DECLS defines HAVE_DECL_ARC4RANDOM_BUF to 0 or 1. On Windows this isn't defined to 0. To avoid the undefined state, the AC_CHECK_DECL is used to manually define the HAVE_ARC4RANDOM_BUF to 1 if declaration is found, otherwise undefined. In the future on current platforms, also AC_CHECK_FUNCS can be used instead since the arc4random_buf is located in default libraries (C) with declaration available in headers.
1 parent 37488d6 commit 3b951e7

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ext/random/config.m4

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
dnl
2-
dnl Check for arc4random on BSD systems
3-
dnl
4-
AC_CHECK_DECLS([arc4random_buf])
1+
AC_CHECK_DECL([arc4random_buf],
2+
[AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1],
3+
[Define to 1 if you have the 'arc4random_buf' function.])])
54

65
dnl
76
dnl Check for CCRandomGenerateBytes

ext/random/csprng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes_ex(void *bytes, size_
8585
snprintf(errstr, errstr_size, "Failed to retrieve randomness from the operating system (CCRandomGenerateBytes)");
8686
return FAILURE;
8787
}
88-
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001 && __NetBSD_Version__ < 1000000000) || \
88+
#elif defined(HAVE_ARC4RANDOM_BUF) && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001 && __NetBSD_Version__ < 1000000000) || \
8989
defined(__APPLE__))
9090
/*
9191
* OpenBSD until there is a valid equivalent

0 commit comments

Comments
 (0)