Commit 34fbbef0 authored by Joanne Hugé's avatar Joanne Hugé

Fix compilation errors

parent f0347f53
#define _GNU_SOURCE #define _GNU_SOURCE
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h>
#include <signal.h> #include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include "utilities.h" #include "utilities.h"
(void)(*previous_handlers[NSIG])(int); void (*previous_handlers[NSIG])(int);
static (void)(*sighand)(int); static void (*sighand)(int);
uint64_t ts_to_uint(struct timespec t) { uint64_t ts_to_uint(struct timespec t) {
return t.tv_sec * NSEC_PER_SEC + t.tv_nsec; return t.tv_sec * NSEC_PER_SEC + t.tv_nsec;
...@@ -36,30 +38,28 @@ uint64_t min(uint64_t a, uint64_t b) { return a < b ? a : b; } ...@@ -36,30 +38,28 @@ uint64_t min(uint64_t a, uint64_t b) { return a < b ? a : b; }
static void sighand_wrapper(int sig) { static void sighand_wrapper(int sig) {
// If we get un unexpected signal, report it, if not print the histogram // If we get un unexpected signal, report it, if not print the histogram
if(sig == SIGINT || sig == SIGTERM) if (sig == SIGINT || sig == SIGTERM)
(*sighand)(sig); // Will print the histogram (*sighand)(sig); // Will print the histogram
else else
printf("Uknown signal interrupt: %s (%d)\n", strsignal(sig), sig); printf("Uknown signal interrupt: %s (%d)\n", strsignal(sig), sig);
// Execute the default handler // Execute the default handler
if(previous_handlers[sig] == SIG_DFL) { if (previous_handlers[sig] == SIG_DFL) {
signal(sig, SIG_DFL); signal(sig, SIG_DFL);
raise(sig); raise(sig);
} } else if (previous_handlers[sig] == SIG_IGN) {
else if(previous_handlers[sig] == SIG_IGN) {
return; return;
} } else {
else {
(*previous_handlers[sig])(sig); (*previous_handlers[sig])(sig);
} }
} }
void init_signals((void)(*_sighand(int)), int enable_histograms) { void init_signals(void (*_sighand)(int), int enable_histograms) {
sighand = _sighand; sighand = _sighand;
if(enable_histograms) if (enable_histograms)
for(int i = 0; i < NSIG; i++) for (int i = 0; i < NSIG; i++)
signal(i, sighand_wrapper); signal(i, sighand_wrapper);
} }
...@@ -28,9 +28,9 @@ uint64_t calcdiff_ns(struct timespec t1, struct timespec t2); ...@@ -28,9 +28,9 @@ uint64_t calcdiff_ns(struct timespec t1, struct timespec t2);
uint64_t max(uint64_t a, uint64_t b); uint64_t max(uint64_t a, uint64_t b);
uint64_t min(uint64_t a, uint64_t b); uint64_t min(uint64_t a, uint64_t b);
void init_signals((void)(*_sighand(int)), int enable_histograms); void init_signals(void (*_sighand)(int), int enable_histograms);
extern (void)(*previous_handlers[NSIG])(int); extern void (*previous_handlers[NSIG])(int);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment