mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-23 02:50:08 +03:00
build: Use AC_CHECK_DECLS/check_symbol_exists for getentropy
This assumes that getentropy is declared in sys/random.h. Should fix issues on iOS. See #774.
This commit is contained in:
parent
278fcf13b9
commit
e1657f3f27
@ -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)
|
||||
|
||||
|
@ -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 <sys/mman.h> header file. */
|
||||
#cmakedefine HAVE_SYS_MMAN_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/random.h> header file. */
|
||||
#cmakedefine HAVE_SYS_RANDOM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#cmakedefine HAVE_SYS_SELECT_H 1
|
||||
|
||||
|
@ -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 <sys/random.h>])
|
||||
|
||||
dnl
|
||||
dnl Checks for inet libraries
|
||||
dnl
|
||||
|
8
dict.c
8
dict.c
@ -929,11 +929,9 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
#elif defined(HAVE_GETENTROPY)
|
||||
#elif HAVE_DECL_GETENTROPY
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_SYS_RANDOM_H
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#include <sys/random.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#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;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user