--- l2_ch_buffer.c 2001/10/30 18:55:27 1.29
+++ l2_ch_buffer.c 2001/10/31 16:47:05 1.30
@@ -34,7 +34,7 @@
#include <unistd.h> /* for alarm(3) */
#include <signal.h> /* for sigaction(2) and SIGALRM */
-#ifdef HAVE_SETITIMER
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> /* for setitimer(2) */
#endif
@@ -47,7 +47,7 @@
int bufsize;
long bufinterval;
struct sigaction sigalrm;
-#ifdef HAVE_SETITIMER
+#if defined HAVE_SETITIMER && defined HAVE_SYS_TIME_H
struct itimerval valprev;
#endif
int levelflush;
@@ -57,7 +57,7 @@
/* Sets the VIRTUAL timer to preconfigured value in cfg */
static int set_alarm(l2_ch_buffer_t *cfg)
{
-#ifdef HAVE_INET_SETITIMER
+#if defined HAVE_SETITIMER && defined HAVE_SYS_TIME_H
struct itimerval valtest, valnew;
/* initialize auto vars before using them */
@@ -67,22 +67,22 @@
valnew.it_interval.tv_usec = 0;
valnew.it_value.tv_sec = cfg->bufinterval;
valnew.it_value.tv_usec = 0;
- if ((getitimer(L2_BUFFER_TIMER, &testval) == 0) &&
- ((testval.it_value.tv_sec | testval.it_value.tv_usec |
- testval.it_interval.tv_sec | testval.it_interval.tv_usec) == 0))
+ if ((getitimer(L2_BUFFER_TIMER, &valtest) == 0) &&
+ ((valtest.it_value.tv_sec | valtest.it_value.tv_usec |
+ valtest.it_interval.tv_sec | valtest.it_interval.tv_usec) == 0))
return setitimer(L2_BUFFER_TIMER, &valnew, &cfg->valprev);
else {
cfg->bufinterval = -1L; /* mark this timer as broken */
assert(FALSE);
+ return 1; /* to make the compiler happy */
}
#else
unsigned int uiAlarmed = 0;
- uiAlarmed = alarm(cfg->bufinterval);
+ assert(uiAlarmed = alarm(cfg->bufinterval));
if (uiAlarmed) { /* check if SIGALRM is occupied */
alarm(uiAlarmed); /* ...if so, then hack in the old value */
cfg->bufinterval = -1L; /* ...mark this timer as broken */
- assert(FALSE); /* ...and warn the user about problems */
}
return 0;
#endif
@@ -91,7 +91,7 @@
/* Resets the VIRTUAL timer to preconfigured value in cfg */
static int reset_alarm(l2_ch_buffer_t *cfg)
{
-#ifdef HAVE_INET_SETITIMER
+#if defined HAVE_SETITIMER && defined HAVE_SYS_TIME_H
struct itimerval valnew;
/* initialize auto vars before using them */
@@ -123,9 +123,7 @@
else if (sig == SIGALRM) {
TRACE("SIGALRM caught");
l2_channel_flush(ch);
-#ifndef HAVE_SETITIMER
reset_alarm(cfg); /* alarm(3) doesn't auto-reset like setitime(2) */
-#endif
}
}
@@ -146,7 +144,7 @@
cfg->levelflush = 0;
cfg->level = L2_LEVEL_NONE;
memset(&cfg->sigalrm, 0, sizeof(cfg->sigalrm));
-#ifdef HAVE_SETITIMER
+#if defined HAVE_SETITIMER && defined HAVE_SYS_TIME_H
memset(&cfg->valprev, 0, sizeof(cfg->valprev));
#endif
@@ -293,7 +291,7 @@
l2_result_t rv;
if ((cfg->bufinterval != 0) && (cfg->bufinterval != -1L)) {
-#ifdef HAVE_INET_SETITIMER
+#if defined HAVE_SETITIMER && defined HAVE_SYS_TIME_H
if (setitimer(L2_BUFFER_TIMER, &cfg->valprev, 0)) /* restore timer */
return L2_ERR_SYS;
#else
|