summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ConfigureChecks.cmake4
-rw-r--r--config.h.cmake41
-rw-r--r--src/test/copycluster.c4
-rw-r--r--src/test/recur.c2
-rw-r--r--src/test/regression-recur.c2
-rw-r--r--src/test/regression-storage.c2
-rw-r--r--src/test/regression.c21
-rw-r--r--src/test/testmime.c6
8 files changed, 62 insertions, 20 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 60745083..b2bc6757 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -17,6 +17,7 @@ if(WIN32 AND MSVC)
check_function_exists(_getpid HAVE__GETPID) #Windows <process.h>
check_function_exists(_mkdir HAVE__MKDIR) #Windows <direct.h>
check_function_exists(_open HAVE__OPEN) #Windows <io.h>
+ check_function_exists(Sleep, HAVE_WINSLEEP) #Windows <windows.h>
check_function_exists(_snprintf HAVE__SNPRINTF) #Windows <stdio.h>
check_function_exists(_stat HAVE__STAT) #Windows <sys/types.h>,<sys/stat.h>
check_function_exists(_strdup HAVE__STRDUP) #Windows <string.h>
@@ -33,6 +34,8 @@ else()
check_function_exists(gmtime_r HAVE_GMTIME_R) #Unix <time.h>
check_function_exists(mkdir HAVE_MKDIR) #Unix <sys/stat.h>,<sys/types.h>
check_function_exists(open HAVE_OPEN) #Unix <sys/stat.h>,<sys/types.h>,<fcntl.h>
+ check_function_exists(sleep HAVE_UNIXSLEEP) #Unix <unistd.h>
+ check_function_exists(nanosleep HAVE_NANOSLEEP) #Unix <time.h>
check_function_exists(signal HAVE_SIGNAL) #Unix <signal.h>
check_function_exists(snprintf HAVE_SNPRINTF) #Unix <stdio.h>
check_function_exists(stat HAVE_STAT) #Unix <sys/stat.h>,<sys/types.h>,<unistd.h>
@@ -41,6 +44,7 @@ else()
check_function_exists(strncasecmp HAVE_STRNCASECMP) #Unix <strings.h>
check_function_exists(read HAVE_READ) #Unix <unistd.h>
check_function_exists(unlink HAVE_UNLINK) #Unix <unistd.h>
+ check_function_exists(usleep HAVE_USLEEP) #Unix <unistd.h>
check_function_exists(waitpid HAVE_WAITPID) #Unix <sys/types.h>,<sys/wait.h>
check_function_exists(write HAVE_WRITE) #Unix <unistd.h>
endif()
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
diff --git a/src/test/copycluster.c b/src/test/copycluster.c
index 8fa16bb6..0d77d2f3 100644
--- a/src/test/copycluster.c
+++ b/src/test/copycluster.c
@@ -64,7 +64,7 @@ int main(int c, char *argv[]){
/*icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);*/
#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
- signal(SIGALRM,sig_alrm);
+ (void)signal(SIGALRM,sig_alrm);
alarm(10);
#endif
clusterin = icalfileset_new(argv[1]);
@@ -111,7 +111,7 @@ int main(int c, char *argv[]){
}
- printf("Transfered %d components\n",count);
+ printf("Transferred %d components\n",count);
icalset_free(clusterin);
diff --git a/src/test/recur.c b/src/test/recur.c
index 365aaca2..04afd06c 100644
--- a/src/test/recur.c
+++ b/src/test/recur.c
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
- signal(SIGALRM,sig_alrm);
+ (void)signal(SIGALRM,sig_alrm);
#endif
if (argc <= 1){
diff --git a/src/test/regression-recur.c b/src/test/regression-recur.c
index be76ab51..91d224d3 100644
--- a/src/test/regression-recur.c
+++ b/src/test/regression-recur.c
@@ -95,7 +95,7 @@ void test_recur_file()
icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
- signal(SIGALRM,sig_alrm);
+ (void)signal(SIGALRM,sig_alrm);
#endif
file = getenv("ICAL_RECUR_FILE");
if (!file)
diff --git a/src/test/regression-storage.c b/src/test/regression-storage.c
index 44114928..227f06a7 100644
--- a/src/test/regression-storage.c
+++ b/src/test/regression-storage.c
@@ -520,7 +520,7 @@ int vcalendar_init(struct calendar **rcal, char *vcalendar, char *title)
int get_title(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey)
{
icalcomponent *cl;
- char title[255];
+ static char title[255];
_unused(dbp);
_unused(pkey);
diff --git a/src/test/regression.c b/src/test/regression.c
index 57df5ac2..fb098758 100644
--- a/src/test/regression.c
+++ b/src/test/regression.c
@@ -2872,17 +2872,18 @@ void test_fileset()
#endif
}
-void microsleep(int us)
+void microsleep(int us) /*us is in microseconds */
{
-#ifndef _WIN32
- struct timeval tv;
-
- tv.tv_sec = 0;
- tv.tv_usec = us;
-
- select(0,0,0,0,&tv);
-#else
- Sleep(us);
+#if defined(HAVE_NANOSLEEP)
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = us * 1000; /* convert from microseconds to nanoseconds */
+
+ nanosleep(&ts, NULL);
+#elif defined(HAVE_USLEEP)
+ usleep(us);
+#else /*Windows Sleep is useless for microsleeping*/
+#error missing a microsleep capability here
#endif
}
diff --git a/src/test/testmime.c b/src/test/testmime.c
index 4cc3145c..271f74fc 100644
--- a/src/test/testmime.c
+++ b/src/test/testmime.c
@@ -318,11 +318,7 @@ int main(int argc, char* argv[])
}
if (opt.sleep != 0){
-#ifdef WIN32
- Sleep(opt.sleep*1000);
-#else
- sleep(opt.sleep);
-#endif
+ sleep((unsigned int)opt.sleep);
}
if( opt.input_file != 0){