#ifndef SOFTWAREWATCHDOG_H #define SOFTWAREWATCHDOG_H #include #include #ifdef _WIN32 #include #include #define sleep(...) (Sleep(1000.0*__VA_ARGS__)) #else #include #include #endif // Software WatchDog (swd) void printHelloWorld(); typedef void (*timeout_cb_t)(void *watchdog); typedef struct { char *name; timeout_cb_t timeout_cb; struct timespec timeout; struct timespec latestKick; void *userData; bool isEnabled; pthread_t thread_id; pthread_mutex_t mutex; } SoftwareWatchdog; // return -1 on error int swd_setup(SoftwareWatchdog *watchdog, char *name, timeout_cb_t timeout_cb, struct timespec timeout, void *userData); int swd_enable(SoftwareWatchdog *watchdog); void swd_disable(SoftwareWatchdog *watchdog); void swd_kick(SoftwareWatchdog *watchdog); #endif /* SOFTWAREWATCHDOG_H */