#include <pwd.h>
#include <signal.h>
#include <pthread.h>
+#include <sys/time.h>
#include "util.h"
#include "xmalloc.h"
struct sigaction sa;
sigset_t set;
+#ifdef HAVE_PTHREAD
if (pthread_sigmask(SIG_SETMASK, NULL, &set) < 0) {
+#endif
if (sigprocmask(SIG_SETMASK, NULL, &set) < 0) {
fprintf(stderr, __FILE__": sigprocmask() failed: %s\n", strerror(errno));
return;
}
+#ifdef HAVE_PTHREAD
}
+#endif
if (sigismember(&set, SIGPIPE))
return;
s[l-1] = 0;
return s;
}
+
+uint32_t pa_age(struct timeval *tv) {
+ struct timeval now;
+ uint32_t r;
+ assert(tv);
+
+ if (tv->tv_sec == 0)
+ return 0;
+
+ gettimeofday(&now, NULL);
+
+ r = (now.tv_sec-tv->tv_sec) * 1000000;
+
+ if (now.tv_usec >= tv->tv_usec)
+ r += now.tv_usec - tv->tv_usec;
+ else
+ r -= tv->tv_usec - now.tv_usec;
+
+ return r;
+}