From eee806c912310ed179f8571f008a1f750aabe492 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Mon, 25 May 2015 18:05:41 -0400 Subject: cmake discovery for sleep(), Sleep(), nanosleep(), usleep() --- config.h.cmake | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'config.h.cmake') 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 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 +/* sleep: function to sleep for a specified time */ +#if defined(HAVE_WINSLEEP) +#include +#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 +#endif +#endif + +/* nanosleep: function for high resolution sleeping */ +#if defined(HAVE_NANOSLEEP) +#include +#endif + +/* usleep: deprecated, but useful if nanosleep is unavailable */ +#if defined(HAVE_USLEEP) +#include +#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 -- cgit v1.2.1