summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2015-05-25 17:12:46 -0400
committerAllen Winter <allen.winter@kdab.com>2015-05-25 17:12:46 -0400
commit6ad3669273c52e0354c874ee6b01dea7ce9c39c5 (patch)
tree22e9c00e1c8edc783919642acf0a7ed8c241ce8b
parent9c1e54f11ed4718e023b1af2b3224902db28ffb5 (diff)
downloadlibical-git-6ad3669273c52e0354c874ee6b01dea7ce9c39c5.tar.gz
cmake discovery for HAVE_SIGNAL and HAVE_ALARM
-rw-r--r--ConfigureChecks.cmake2
-rw-r--r--config.h.cmake16
-rw-r--r--src/test/copycluster.c10
-rw-r--r--src/test/recur.c8
-rw-r--r--src/test/regression-recur.c8
5 files changed, 31 insertions, 13 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 755a41db..60745083 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -26,12 +26,14 @@ if(WIN32 AND MSVC)
check_function_exists(_write HAVE__WRITE) #Windows <io.h>
else()
check_function_exists(access HAVE_ACCESS) #Unix <unistd.h>
+ check_function_exists(alarm HAVE_ALARM) #Unix <unistd.h>
check_function_exists(fork HAVE_FORK) #Unix <unistd.h>
check_function_exists(getpid HAVE_GETPID) #Unix <unistd.h>
check_function_exists(getpwent HAVE_GETPWENT) #Unix <sys/types.h>,<pwd.h>
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(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>
check_function_exists(strdup HAVE_STRDUP) #Unix <string.h>
diff --git a/config.h.cmake b/config.h.cmake
index 5faed9e2..e6905125 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -129,6 +129,12 @@
/* Define to 1 if you have the `unsetenv' function. */
#cmakedefine HAVE_UNSETENV 1
+/* Define to 1 if you have the `alarm' function. */
+#cmakedefine HAVE_ALARM 1
+
+/* Define to 1 if you have the `signal' function. */
+#cmakedefine HAVE_SIGNAL 1
+
/* Define to 1 if you have the `waitpid' function. */
#cmakedefine HAVE_WAITPID 1
@@ -408,6 +414,16 @@ typedef ssize_t IO_SSIZE_T;
#endif
#endif
+/* alarm - function to set and alarm for delivering a signal */
+#if defined(HAVE_ALARM)
+#include <unistd.h>
+#endif
+
+/* signal - signal handling function */
+#if defined(HAVE_SIGNAL)
+#include <signal.h>
+#endif
+
/* waitpid - system function waiting on a process */
#if defined(HAVE_WAITPID)
#include <sys/types.h>
diff --git a/src/test/copycluster.c b/src/test/copycluster.c
index d775e891..8fa16bb6 100644
--- a/src/test/copycluster.c
+++ b/src/test/copycluster.c
@@ -28,7 +28,7 @@
#include <stdlib.h>
-#if defined(SIGALRM)
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
static void sig_alrm(int i)
{
_unused(i);
@@ -63,12 +63,12 @@ int main(int c, char *argv[]){
/*icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);*/
-#if defined(SIGALRM)
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
signal(SIGALRM,sig_alrm);
alarm(10);
#endif
clusterin = icalfileset_new(argv[1]);
-#if defined(SIGALRM)
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(0);
#endif
if (clusterin == 0){
@@ -80,11 +80,11 @@ int main(int c, char *argv[]){
}
if (!tostdout){
-#if defined(SIGALRM)
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(10);
#endif
clusterout = icalfileset_new(argv[2]);
-#if defined(SIGALRM)
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(0);
#endif
if (clusterout == 0){
diff --git a/src/test/recur.c b/src/test/recur.c
index e83ae5d1..365aaca2 100644
--- a/src/test/recur.c
+++ b/src/test/recur.c
@@ -31,7 +31,7 @@
#include <stdlib.h>
-#ifndef WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
static void sig_alrm(int i)
{
_unused(i);
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
-#ifndef WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
signal(SIGALRM,sig_alrm);
#endif
@@ -77,11 +77,11 @@ int main(int argc, char *argv[])
exit(1);
}
-#ifndef WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(300); /* to get file lock */
#endif
cin = icalfileset_new(file);
-#ifndef WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(0);
#endif
diff --git a/src/test/regression-recur.c b/src/test/regression-recur.c
index 3c5a5757..be76ab51 100644
--- a/src/test/regression-recur.c
+++ b/src/test/regression-recur.c
@@ -28,7 +28,7 @@
#include <stdlib.h>
-#ifndef _WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
static void sig_alrm(int i)
{
_unused(i);
@@ -94,18 +94,18 @@ void test_recur_file()
icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
-#ifndef _WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
signal(SIGALRM,sig_alrm);
#endif
file = getenv("ICAL_RECUR_FILE");
if (!file)
file = TEST_DATADIR "/recur.txt";
-#ifndef _WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(15); /* to get file lock */
#endif
cin = icalset_new(ICAL_FILE_SET, file, &options);
-#ifndef _WIN32
+#if defined(HAVE_SIGNAL) && defined(HAVE_ALARM)
alarm(0);
#endif