Skip to content

Commit

Permalink
cmake: add missing checks
Browse files Browse the repository at this point in the history
- check for arc4random. To make rand.c use it accordingly.
- check for fcntl
- fix fseek detection
- add SIZEOF_CURL_SOCKET_T
- fix USE_UNIX_SOCKETS
- define HAVE_SNPRINTF to 1
- check for fnmatch
- check for sched_yield
- remove HAVE_GETPPID duplicate from curl_config.h
- add HAVE_SENDMSG

Ref: #11964

Co-authored-by: Viktor Szakats
Closes #11973
  • Loading branch information
bagder committed Sep 28, 2023
1 parent 2ba8049 commit 9b517c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMake/Platforms/WindowsCache.cmake
Expand Up @@ -52,6 +52,9 @@ if(NOT UNIX)
set(HAVE_GETHOSTNAME 1)
set(HAVE_LIBZ 0)

set(HAVE_ARC4RANDOM 0)
set(HAVE_FNMATCH 0)
set(HAVE_SCHED_YIELD 0)
set(HAVE_ARPA_INET_H 0)
set(HAVE_FCNTL_H 1)
set(HAVE_IFADDRS_H 0)
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -1102,8 +1102,10 @@ elseif(HAVE_LIBSOCKET)
endif()

check_symbol_exists(fchmod "${CURL_INCLUDES}" HAVE_FCHMOD)
check_symbol_exists(fnmatch "${CURL_INCLUDES};fnmatch.h" HAVE_FNMATCH)
check_symbol_exists(basename "${CURL_INCLUDES};string.h" HAVE_BASENAME)
check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
check_symbol_exists(sched_yield "${CURL_INCLUDES};sched.h" HAVE_SCHED_YIELD)
check_symbol_exists(socketpair "${CURL_INCLUDES}" HAVE_SOCKETPAIR)
check_symbol_exists(recv "${CURL_INCLUDES}" HAVE_RECV)
check_symbol_exists(send "${CURL_INCLUDES}" HAVE_SEND)
Expand All @@ -1116,6 +1118,8 @@ check_symbol_exists(stricmp "${CURL_INCLUDES};string.h" HAVE_STRICMP)
check_symbol_exists(strcmpi "${CURL_INCLUDES};string.h" HAVE_STRCMPI)
check_symbol_exists(memrchr "${CURL_INCLUDES};string.h" HAVE_MEMRCHR)
check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
check_symbol_exists(arc4random "${CURL_INCLUDES};stdlib.h" HAVE_ARC4RANDOM)
check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
check_symbol_exists(getppid "${CURL_INCLUDES}" HAVE_GETPPID)
check_symbol_exists(utimes "${CURL_INCLUDES}" HAVE_UTIMES)

Expand Down
28 changes: 23 additions & 5 deletions lib/curl_config.h.cmake
Expand Up @@ -159,6 +159,9 @@
/* Define to 1 if you have the alarm function. */
#cmakedefine HAVE_ALARM 1

/* Define to 1 if you have the arc4random function. */
#cmakedefine HAVE_ARC4RANDOM 1

/* Define to 1 if you have the <arpa/inet.h> header file. */
#cmakedefine HAVE_ARPA_INET_H 1

Expand All @@ -168,6 +171,9 @@
/* Define to 1 if you have the `fchmod' function. */
#cmakedefine HAVE_FCHMOD 1

/* Define to 1 if you have the `fnmatch' function. */
#cmakedefine HAVE_FNMATCH 1

/* Define to 1 if you have the `basename' function. */
#cmakedefine HAVE_BASENAME 1

Expand Down Expand Up @@ -195,6 +201,12 @@
/* Define to 1 if you have the freeaddrinfo function. */
#cmakedefine HAVE_FREEADDRINFO 1

/* Define to 1 if you have the fseeko function. */
#cmakedefine HAVE_FSEEKO 1

/* Define to 1 if you have the _fseeki64 function. */
#cmakedefine HAVE__FSEEKI64 1

/* Define to 1 if you have the ftruncate function. */
#cmakedefine HAVE_FTRUNCATE 1

Expand Down Expand Up @@ -231,9 +243,6 @@
/* Define to 1 if you have the `getpass_r' function. */
#cmakedefine HAVE_GETPASS_R 1

/* Define to 1 if you have the `getppid' function. */
#cmakedefine HAVE_GETPPID 1

/* Define to 1 if you have the `getpeername' function. */
#cmakedefine HAVE_GETPEERNAME 1

Expand Down Expand Up @@ -421,9 +430,15 @@
/* Define to 1 if you have the select function. */
#cmakedefine HAVE_SELECT 1

/* Define to 1 if you have the sched_yield function. */
#cmakedefine HAVE_SCHED_YIELD 1

/* Define to 1 if you have the send function. */
#cmakedefine HAVE_SEND 1

/* Define to 1 if you have the sendmsg function. */
#cmakedefine HAVE_SENDMSG 1

/* Define to 1 if you have the 'fsetxattr' function. */
#cmakedefine HAVE_FSETXATTR 1

Expand Down Expand Up @@ -458,7 +473,7 @@
#cmakedefine HAVE_SIGSETJMP 1

/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF
#cmakedefine HAVE_SNPRINTF 1

/* Define to 1 if struct sockaddr_in6 has the sin6_scope_id member */
#cmakedefine HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
Expand Down Expand Up @@ -646,6 +661,9 @@ ${SIZEOF_OFF_T_CODE}
/* The size of `curl_off_t', as computed by sizeof. */
${SIZEOF_CURL_OFF_T_CODE}

/* The size of `curl_socket_t', as computed by sizeof. */
${SIZEOF_CURL_SOCKET_T_CODE}

/* The size of `size_t', as computed by sizeof. */
${SIZEOF_SIZE_T_CODE}

Expand Down Expand Up @@ -720,7 +738,7 @@ ${SIZEOF_TIME_T_CODE}
#cmakedefine USE_MSH3 1

/* if Unix domain sockets are enabled */
#cmakedefine USE_UNIX_SOCKETS
#cmakedefine USE_UNIX_SOCKETS 1

/* Define to 1 if you are building a Windows target with large file support. */
#cmakedefine USE_WIN32_LARGE_FILES 1
Expand Down

0 comments on commit 9b517c8

Please sign in to comment.