summaryrefslogtreecommitdiffstats
path: root/Tests/CTestTestFdSetSize
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2022-06-24 18:19:01 (GMT)
committerRaul Tambre <raul@tambre.ee>2022-06-26 08:49:46 (GMT)
commit324ca5b489076e548258fb7acd9ed3c238406eda (patch)
tree4c397ca5463a261d5b28663112df290619ca163f /Tests/CTestTestFdSetSize
parent526d10139de4472333446a84859632861e7cea5a (diff)
downloadCMake-324ca5b489076e548258fb7acd9ed3c238406eda.zip
CMake-324ca5b489076e548258fb7acd9ed3c238406eda.tar.gz
CMake-324ca5b489076e548258fb7acd9ed3c238406eda.tar.bz2
Tests/CTestTestFdSetSize: Support plain POSIX
When compiling in ISO C mode functions from newer POSIX standards such as usleep() and nanosleep() aren't available. Fortunately select() allows timing out with microsecond precision.
Diffstat (limited to 'Tests/CTestTestFdSetSize')
-rw-r--r--Tests/CTestTestFdSetSize/sleep.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Tests/CTestTestFdSetSize/sleep.c b/Tests/CTestTestFdSetSize/sleep.c
index 2fb6490..d55cec6 100644
--- a/Tests/CTestTestFdSetSize/sleep.c
+++ b/Tests/CTestTestFdSetSize/sleep.c
@@ -1,7 +1,11 @@
#if defined(_WIN32)
# include <windows.h>
-#else
+#elif _XOPEN_SOURCE >= 500 || defined(_ALL_SOURCE)
# include <unistd.h>
+#else
+# include <time.h>
+
+# include <sys/select.h>
#endif
/* sleeps for 0.1 second */
@@ -9,8 +13,14 @@ int main(int argc, char** argv)
{
#if defined(_WIN32)
Sleep(100);
-#else
+#elif _XOPEN_SOURCE >= 500 || defined(_ALL_SOURCE)
usleep(100 * 1000);
+#else
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+
+ select(0, NULL, NULL, NULL, &tv);
#endif
return 0;
}