diff options
author | Sergei Nikulov <sergey.nikulov@gmail.com> | 2019-01-15 12:50:18 +0300 |
---|---|---|
committer | Sergei Nikulov <snikulov@users.noreply.github.com> | 2019-01-16 11:39:34 +0300 |
commit | 99c2e7e5542380bcf416fdbcf4f895c158f5cede (patch) | |
tree | 5a69ae1ca7781796dcee531f84f3bb5f6a1bb2b6 /CMake/OtherTests.cmake | |
parent | 26d7f0094aaf5458ab496a8ec84210aab64d63b5 (diff) | |
download | curl-99c2e7e5542380bcf416fdbcf4f895c158f5cede.tar.gz |
cmake: updated check for HAVE_POLL_FINE to match autotools
Diffstat (limited to 'CMake/OtherTests.cmake')
-rw-r--r-- | CMake/OtherTests.cmake | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake index ce6d3e13a..c180a5888 100644 --- a/CMake/OtherTests.cmake +++ b/CMake/OtherTests.cmake @@ -177,20 +177,48 @@ int main(void) { return 0; }" HAVE_STRUCT_TIMEVAL) - -include(CheckCSourceRuns) -# See HAVE_POLL in CMakeLists.txt for why poll is disabled on macOS -if(NOT APPLE) - set(CMAKE_REQUIRED_FLAGS) +if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + # if not cross-compilation... + include(CheckCSourceRuns) + set(CMAKE_REQUIRED_FLAGS "") if(HAVE_SYS_POLL_H) set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H") + elseif(HAVE_POLL_H) + set(CMAKE_REQUIRED_FLAGS "-DHAVE_POLL_H") endif() check_c_source_runs(" + #include <stdlib.h> + #include <sys/time.h> + #ifdef HAVE_SYS_POLL_H # include <sys/poll.h> + #elif HAVE_POLL_H + # include <poll.h> #endif - int main(void) { - return poll((void *)0, 0, 10 /*ms*/); + + int main(void) + { + if(0 != poll(0, 0, 10)) { + return 1; /* fail */ + } + else { + /* detect the 10.12 poll() breakage */ + struct timeval before, after; + int rc; + size_t us; + + gettimeofday(&before, NULL); + rc = poll(NULL, 0, 500); + gettimeofday(&after, NULL); + + us = (after.tv_sec - before.tv_sec) * 1000000 + + (after.tv_usec - before.tv_usec); + + if(us < 400000) { + return 1; + } + } + return 0; }" HAVE_POLL_FINE) endif() |