Skip to content

Commit af551f6

Browse files
committed
random netbsd 10 update finally supporting getrandom syscall properly.
1 parent e951202 commit af551f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ext/random/random.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050

5151
#if HAVE_SYS_PARAM_H
5252
# include <sys/param.h>
53-
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700) || defined(__sun)
53+
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700) || \
54+
defined(__sun) || (defined(__NetBSD__) && __NetBSD_Version__ >= 1000000000)
5455
# include <sys/random.h>
5556
# endif
5657
#endif
@@ -503,12 +504,14 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
503504
}
504505
return FAILURE;
505506
}
506-
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001) || defined(__APPLE__) || defined(__GLIBC__))
507+
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001 && __NetBSD_Version__ < 1000000000) || \
508+
defined(__APPLE__) || defined(__GLIBC__))
507509
arc4random_buf(bytes, size);
508510
#else
509511
size_t read_bytes = 0;
510512
ssize_t n;
511-
# if (defined(__linux__) && defined(SYS_getrandom)) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(__DragonFly__) && __DragonFly_version >= 500700) || defined(__sun)
513+
# if (defined(__linux__) && defined(SYS_getrandom)) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(__DragonFly__) && __DragonFly_version >= 500700) || \
514+
defined(__sun) || (defined(__NetBSD__) && __NetBSD_Version__ >= 1000000000)
512515
/* Linux getrandom(2) syscall or FreeBSD/DragonFlyBSD getrandom(2) function*/
513516
/* Keep reading until we get enough entropy */
514517
while (read_bytes < size) {

0 commit comments

Comments
 (0)