Skip to content

Commit

Permalink
[core] compile fix for Mac OS X 10.6 (old) (fixes #2773)
Browse files Browse the repository at this point in the history
Mac OS X 10.7 Lion introduces arc4random_buf()

(thx ryandesign)

x-ref:
  "Mac OS X build issue Undefined symbols"
  https://redmine.lighttpd.net/issues/2773
  • Loading branch information
gstrauss committed Nov 28, 2016
1 parent e628fc3 commit df61f19
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ if 1:
getuid select signal pathconf madvise prctl\
writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton \
memset_s explicit_bzero clock_gettime \
getentropy arc4random jrand48 srandom getloadavg'))
getentropy arc4random_buf jrand48 srandom getloadavg'))
checkFunc(autoconf, 'getrandom', 'linux/random.h')

checkTypes(autoconf, Split('pid_t size_t off_t'))
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop inet_pton issetugid memset mmap
getuid select signal pathconf madvise posix_fadvise posix_madvise \
writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
memset_s explicit_bzero clock_gettime \
getentropy arc4random jrand48 srandom getloadavg])
getentropy arc4random_buf jrand48 srandom getloadavg])
AC_CHECK_HEADERS([linux/random.h],[
AC_CHECK_FUNC([getrandom], AC_DEFINE([HAVE_GETRANDOM], [1], [getrandom]))
])
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ set(CMAKE_EXTRA_INCLUDE_FILES)
check_type_size(long SIZEOF_LONG)
check_type_size(off_t SIZEOF_OFF_T)

check_function_exists(arc4random HAVE_ARC4RANDOM)
check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF)
check_function_exists(chroot HAVE_CHROOT)
check_function_exists(epoll_ctl HAVE_EPOLL_CTL)
check_function_exists(fork HAVE_FORK)
Expand Down
4 changes: 2 additions & 2 deletions src/rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void li_rand_reseed (void)
u = ((unsigned int)xsubi[0] << 16) | xsubi[1];
}
else {
#ifdef HAVE_ARC4RANDOM
#ifdef HAVE_ARC4RANDOM_BUF
u = arc4random();
arc4random_buf(xsubi, sizeof(xsubi));
#else
Expand Down Expand Up @@ -155,7 +155,7 @@ int li_rand (void)
int i;
if (-1 != RAND_pseudo_bytes((unsigned char *)&i, sizeof(i))) return i;
#endif
#ifdef HAVE_ARC4RANDOM
#ifdef HAVE_ARC4RANDOM_BUF
return (int)arc4random();
#elif defined(HAVE_SRANDOM)
/* coverity[dont_call : FALSE] */
Expand Down

0 comments on commit df61f19

Please sign in to comment.