diff --git a/mx_util.c b/mx_util.c index ebb76007..b7ea0c24 100644 --- a/mx_util.c +++ b/mx_util.c @@ -10,7 +10,7 @@ #include #include - +#include #include #include #include @@ -1305,3 +1305,12 @@ unsigned long mx_df(const char *path) { } return s.f_bavail*s.f_frsize; } + +time_t mx_clock_boottime() { + struct timespec ts; + int res = clock_gettime(CLOCK_BOOTTIME, &ts); + if (res != 0) { + perror("clock_gettime"); + } + return (ts.tv_sec); +} diff --git a/mx_util.h b/mx_util.h index 409c31a1..c8c900cf 100644 --- a/mx_util.h +++ b/mx_util.h @@ -179,5 +179,5 @@ void _mx_sort_linked_list(void **list, int (*cmp)(void *o1,void *o2), void ** (* #define mx_sort_linked_list(list,cmp,getnextptr) _mx_sort_linked_list((void **)(list),(int (*)(void *,void *))(cmp),(void ** (*)(void *))(getnextptr)) unsigned long mx_df(const char *path); - +time_t mx_clock_boottime(); #endif