diff --git a/CMakeLists.txt b/CMakeLists.txt index 7108d04d..01c1c5d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,7 @@ CARES_FUNCTION_IN_LIBRARY (clock_gettime rt HAVE_LIBRT) # Look for necessary includes +CHECK_INCLUDE_FILES (AvailabilityMacros.h HAVE_AVAILABILITYMACROS_H) CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILES (sys/random.h HAVE_SYS_RANDOM_H) CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H) @@ -300,6 +301,7 @@ MACRO (CARES_EXTRAINCLUDE_IFSET var include) ENDIF () ENDMACRO () +CARES_EXTRAINCLUDE_IFSET (HAVE_AVAILABILITYMACROS_H AvailabilityMacros.h) CARES_EXTRAINCLUDE_IFSET (HAVE_STDBOOL_H stdbool.h) CARES_EXTRAINCLUDE_IFSET (HAVE_SYS_TYPES_H sys/types.h) CARES_EXTRAINCLUDE_IFSET (HAVE_ARPA_INET_H arpa/inet.h) @@ -633,9 +635,6 @@ ENDIF () IF (HAVE_SYS_TYPES_H) SET (CARES_HAVE_SYS_TYPES_H 1) ENDIF () -IF (HAVE_SYS_RANDOM_H) - SET (CARES_HAVE_SYS_RANDOM_H 1) -ENDIF() IF (HAVE_SYS_SOCKET_H) SET (CARES_HAVE_SYS_SOCKET_H 1) ENDIF() diff --git a/configure.ac b/configure.ac index 9a119e04..84df1966 100644 --- a/configure.ac +++ b/configure.ac @@ -409,6 +409,7 @@ dnl check for a few basic system headers we need AC_CHECK_HEADERS( malloc.h \ memory.h \ + AvailabilityMacros.h \ sys/types.h \ sys/time.h \ sys/select.h \ @@ -469,6 +470,9 @@ dnl *Sigh* these are needed in order for net/if.h to get properly detected. cares_all_includes=" #include #include +#ifdef HAVE_AVAILABILITYMACROS_H +# include +#endif #ifdef HAVE_SYS_UIO_H # include #endif @@ -756,9 +760,6 @@ dnl ares_build.h.in specific defines if test "x$ac_cv_header_sys_types_h" = "xyes" ; then CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_TYPES_H],[1]) fi -if test "x$ac_cv_header_sys_random_h" = "xyes" ; then - CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_RANDOM_H],[1]) -fi if test "x$ac_cv_header_sys_socket_h" = "xyes" ; then CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_SOCKET_H],[1]) fi diff --git a/include/ares_build.h.cmake b/include/ares_build.h.cmake index e2ab7173..da8a7e06 100644 --- a/include/ares_build.h.cmake +++ b/include/ares_build.h.cmake @@ -12,7 +12,6 @@ * files. We need to include some dependent headers that may be system specific * for C-Ares */ #cmakedefine CARES_HAVE_SYS_TYPES_H -#cmakedefine CARES_HAVE_SYS_RANDOM_H #cmakedefine CARES_HAVE_SYS_SOCKET_H #cmakedefine CARES_HAVE_WINDOWS_H #cmakedefine CARES_HAVE_WS2TCPIP_H @@ -25,10 +24,6 @@ # include #endif -#ifdef CARES_HAVE_SYS_RANDOM_H -# include -#endif - #ifdef CARES_HAVE_SYS_SOCKET_H # include #endif diff --git a/include/ares_build.h.in b/include/ares_build.h.in index b4a26d89..e55b39b0 100644 --- a/include/ares_build.h.in +++ b/include/ares_build.h.in @@ -12,7 +12,6 @@ * files. We need to include some dependent headers that may be system specific * for C-Ares */ #undef CARES_HAVE_SYS_TYPES_H -#undef CARES_HAVE_SYS_RANDOM_H #undef CARES_HAVE_SYS_SOCKET_H #undef CARES_HAVE_WINDOWS_H #undef CARES_HAVE_WS2TCPIP_H @@ -25,10 +24,6 @@ # include #endif -#ifdef CARES_HAVE_SYS_RANDOM_H -# include -#endif - #ifdef CARES_HAVE_SYS_SOCKET_H # include #endif diff --git a/src/lib/ares_config.h.cmake b/src/lib/ares_config.h.cmake index 4529eb94..da64de04 100644 --- a/src/lib/ares_config.h.cmake +++ b/src/lib/ares_config.h.cmake @@ -182,6 +182,9 @@ /* Define to 1 if you have the memory.h header file. */ #cmakedefine HAVE_MEMORY_H +/* Define to 1 if you have the AvailabilityMacros.h header file. */ +#cmakedefine HAVE_AVAILABILITYMACROS_H + /* Define to 1 if you have the MSG_NOSIGNAL flag. */ #cmakedefine HAVE_MSG_NOSIGNAL diff --git a/src/lib/ares_rand.c b/src/lib/ares_rand.c index 976d8ff6..a7a74c9a 100644 --- a/src/lib/ares_rand.c +++ b/src/lib/ares_rand.c @@ -28,6 +28,13 @@ #include "ares.h" #include "ares_private.h" #include + +/* Older MacOS versions require including AvailabilityMacros.h before + * sys/random.h */ +#ifdef HAVE_AVAILABILITYMACROS_H +# include +#endif + #ifdef HAVE_SYS_RANDOM_H # include #endif diff --git a/src/lib/setup_once.h b/src/lib/setup_once.h index 042a3aae..8341b348 100644 --- a/src/lib/setup_once.h +++ b/src/lib/setup_once.h @@ -95,10 +95,6 @@ # endif #endif -#ifdef HAVE_SYS_RANDOM_H -# include -#endif - #ifdef HAVE_SYS_SOCKET_H # include #endif