Skip to content

Commit

Permalink
getrandom support for DragonFlyBSD too.
Browse files Browse the repository at this point in the history
supported since the 5.7.x release, actually 5.8.x is the stable one.
  • Loading branch information
devnexen authored and nikic committed Jul 19, 2021
1 parent 052af90 commit ffc30c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/standard/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#ifdef __linux__
# include <sys/syscall.h>
#endif
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/param.h>
# if __FreeBSD__ && __FreeBSD_version > 1200000
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700)
# include <sys/random.h>
# endif
#endif
Expand Down Expand Up @@ -99,8 +99,8 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
#else
size_t read_bytes = 0;
ssize_t n;
#if (defined(__linux__) && defined(SYS_getrandom)) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000)
/* Linux getrandom(2) syscall or FreeBSD getrandom(2) function*/
#if (defined(__linux__) && defined(SYS_getrandom)) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(__DragonFly__) && __DragonFly_version >= 500700)
/* Linux getrandom(2) syscall or FreeBSD/DragonFlyBSD getrandom(2) function*/
/* Keep reading until we get enough entropy */
while (read_bytes < size) {
/* Below, (bytes + read_bytes) is pointer arithmetic.
Expand Down

0 comments on commit ffc30c5

Please sign in to comment.