no reason to include sys/random.h all the time (#684)

External integrations don't need sys/random.h in order to compile, remove the dependency.  Try to fix building on legacy MacOS versions.

Fixes Issue: #682
Fix By: Brad House (@bradh352)
pull/685/head
Brad House 11 months ago committed by GitHub
parent 2a6a420cb6
commit b377da2532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      CMakeLists.txt
  2. 7
      configure.ac
  3. 5
      include/ares_build.h.cmake
  4. 5
      include/ares_build.h.in
  5. 3
      src/lib/ares_config.h.cmake
  6. 7
      src/lib/ares_rand.c
  7. 4
      src/lib/setup_once.h

@ -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()

@ -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 <stdio.h>
#include <stdlib.h>
#ifdef HAVE_AVAILABILITYMACROS_H
# include <AvailabilityMacros.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#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

@ -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 <sys/types.h>
#endif
#ifdef CARES_HAVE_SYS_RANDOM_H
# include <sys/random.h>
#endif
#ifdef CARES_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif

@ -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 <sys/types.h>
#endif
#ifdef CARES_HAVE_SYS_RANDOM_H
# include <sys/random.h>
#endif
#ifdef CARES_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif

@ -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

@ -28,6 +28,13 @@
#include "ares.h"
#include "ares_private.h"
#include <stdlib.h>
/* Older MacOS versions require including AvailabilityMacros.h before
* sys/random.h */
#ifdef HAVE_AVAILABILITYMACROS_H
# include <AvailabilityMacros.h>
#endif
#ifdef HAVE_SYS_RANDOM_H
# include <sys/random.h>
#endif

@ -95,10 +95,6 @@
# endif
#endif
#ifdef HAVE_SYS_RANDOM_H
# include <sys/random.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif

Loading…
Cancel
Save