summaryrefslogtreecommitdiff
path: root/config.h.cmake
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2015-05-25 18:05:41 -0400
committerAllen Winter <allen.winter@kdab.com>2015-05-25 18:05:41 -0400
commiteee806c912310ed179f8571f008a1f750aabe492 (patch)
tree1e9caecebaa2efe774f09259613f380f0548be4c /config.h.cmake
parent6ad3669273c52e0354c874ee6b01dea7ce9c39c5 (diff)
downloadlibical-git-eee806c912310ed179f8571f008a1f750aabe492.tar.gz
cmake discovery for sleep(), Sleep(), nanosleep(), usleep()
Diffstat (limited to 'config.h.cmake')
-rw-r--r--config.h.cmake41
1 files changed, 41 insertions, 0 deletions
diff --git a/config.h.cmake b/config.h.cmake
index e6905125..8276ef37 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -42,6 +42,18 @@
/* Define to 1 if you have the <pthread.h> header file. */
#cmakedefine HAVE_PTHREAD_H 1
+/* Define to 1 if you have the Windows `Sleep' function. */
+#cmakedefine HAVE_WINSLEEP 1
+
+/* Define to 1 if you have the Unix `sleep' function. */
+#cmakedefine HAVE_UNIXSLEEP 1
+
+/* Define to 1 if you have the `nanosleep' function. */
+#cmakedefine HAVE_NANOSLEEP 1
+
+/* Define to 1 if you have the `usleep' function. */
+#cmakedefine HAVE_USLEEP 1
+
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF 1
@@ -260,6 +272,35 @@ typedef unsigned int wint_t;
#endif
#include <stdio.h>
+/* sleep: function to sleep for a specified time */
+#if defined(HAVE_WINSLEEP)
+#include <windows.h>
+#if defined(sleep)
+#undef sleep
+#endif
+#define sleep(n) (Sleep((n)*1000))
+#else
+#if !defined(HAVE_UNIXSLEEP)
+#error "No function to go to sleep available"
+#else
+#include <unistd.h>
+#endif
+#endif
+
+/* nanosleep: function for high resolution sleeping */
+#if defined(HAVE_NANOSLEEP)
+#include <time.h>
+#endif
+
+/* usleep: deprecated, but useful if nanosleep is unavailable */
+#if defined(HAVE_USLEEP)
+#include <unistd.h>
+#endif
+
+#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_USLEEP)
+#error "No function for high resolution timing available"
+#endif
+
/* stat: function to get status info on a file */
#if defined(HAVE__STAT)
#define stat _stat