diff --git a/CMakeLists.txt b/CMakeLists.txt index 623b003d..9ab9b2e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ check_function_exists(class HAVE_CLASS) check_include_files(dlfcn.h HAVE_DLFCN_H) check_library_exists(dl dlopen "" HAVE_DLOPEN) check_include_files(dl.h HAVE_DL_H) -check_function_exists(getentropy HAVE_GETENTROPY) +check_symbol_exists(getentropy "sys/random.h" HAVE_DECL_GETENTROPY) check_library_exists(history append_history "" HAVE_LIBHISTORY) check_library_exists(readline readline "" HAVE_LIBREADLINE) check_function_exists(mmap HAVE_MMAP) @@ -152,7 +152,6 @@ check_include_files(poll.h HAVE_POLL_H) check_library_exists(dld shl_load "" HAVE_SHLLOAD) check_include_files(stdint.h HAVE_STDINT_H) check_include_files(sys/mman.h HAVE_SYS_MMAN_H) -check_include_files(sys/random.h HAVE_SYS_RANDOM_H) check_include_files(sys/select.h HAVE_SYS_SELECT_H) check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) diff --git a/config.h.cmake.in b/config.h.cmake.in index 04f75d42..552f126c 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -14,7 +14,7 @@ #cmakedefine HAVE_DL_H 1 /* Define to 1 if you have the `getentropy' function. */ -#cmakedefine HAVE_GETENTROPY 1 +#cmakedefine HAVE_DECL_GETENTROPY 1 /* Define if history library is there (-lhistory) */ #cmakedefine HAVE_LIBHISTORY 1 @@ -54,9 +54,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_MMAN_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_RANDOM_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SELECT_H 1 diff --git a/configure.ac b/configure.ac index 2169f78a..aefb9d18 100644 --- a/configure.ac +++ b/configure.ac @@ -298,19 +298,22 @@ dnl dnl Checks for header files. dnl AC_CHECK_HEADERS([stdint.h]) -AC_CHECK_HEADERS([sys/mman.h sys/random.h]) +AC_CHECK_HEADERS([sys/mman.h]) AC_CHECK_HEADERS([dl.h dlfcn.h]) AC_CHECK_HEADERS([glob.h]) AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes") dnl Checks for library functions. -AC_CHECK_FUNCS([getentropy mmap munmap]) + +AC_CHECK_FUNCS([mmap munmap]) AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */ #if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP) # undef /**/ HAVE_MMAP #endif]) +AC_CHECK_DECLS([getentropy], [], [], [#include ]) + dnl dnl Checks for inet libraries dnl diff --git a/dict.c b/dict.c index 1c0d6775..ccd8b542 100644 --- a/dict.c +++ b/dict.c @@ -929,11 +929,9 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) { #define WIN32_LEAN_AND_MEAN #include #include -#elif defined(HAVE_GETENTROPY) +#elif HAVE_DECL_GETENTROPY #include - #ifdef HAVE_SYS_RANDOM_H - #include - #endif + #include #else #include #endif @@ -962,7 +960,7 @@ xmlInitRandom(void) { if (!BCRYPT_SUCCESS(status)) xmlAbort("libxml2: BCryptGenRandom failed with error code %lu\n", GetLastError()); -#elif defined(HAVE_GETENTROPY) +#elif HAVE_DECL_GETENTROPY while (1) { if (getentropy(globalRngState, sizeof(globalRngState)) == 0) break; diff --git a/meson.build b/meson.build index 0da18f1a..79feac1a 100644 --- a/meson.build +++ b/meson.build @@ -235,7 +235,6 @@ config_h.set_quoted('LOCALEDIR', dir_locale) xml_check_headers = [ 'stdint.h', 'sys/mman.h', - 'sys/random.h', 'dl.h', 'dlfcn.h', 'glob.h', @@ -258,14 +257,14 @@ endforeach # library functions xml_check_functions = [ # fct | header - ['getentropy', 'sys/random.h'], - ['mmap', 'sys/mman.h'], - ['munmap', 'sys/mman.h'], + ['getentropy', 'sys/random.h', 'HAVE_DECL_GETENTROPY'], + ['mmap', 'sys/mman.h', 'HAVE_MMAP'], + ['munmap', 'sys/mman.h', 'HAVE_MUNMAP'], ] foreach function : xml_check_functions if cc.has_header_symbol(function[1], function[0]) - config_h.set10('HAVE_' + function[0].to_upper(), true) + config_h.set10(function[2], true) endif endforeach