X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fcommon.h;h=5eee7ccd0688f8ac089c5376a6896be26ec19141;hb=a671f27ecb900f91bf32b8b13edb678009e319c1;hp=d4defd95c949046007bfbc2820d612302739b30b;hpb=f858232d7c564f14e6d2fb9d616f8e12a1ec9171;p=matches%2FMCTX3420.git diff --git a/server/common.h b/server/common.h index d4defd9..5eee7cc 100644 --- a/server/common.h +++ b/server/common.h @@ -8,9 +8,9 @@ /** Defines required to allow various C standard functions to be used **/ #define _POSIX_C_SOURCE 200809L -#define _BSD_SOURCE +//#define _BSD_SOURCE #define _XOPEN_SOURCE 600 - +#define _GNU_SOURCE /** Determine if we're running on the BBB **/ #ifdef __arm__ #define _BBB @@ -21,6 +21,7 @@ /** The current API version **/ #define API_VERSION 0 +//#define REALTIME_VERSION @@ -34,19 +35,24 @@ #include #include #include +#include #include "log.h" #include "fastcgi.h" #include "control.h" /**Converts a timeval to a double**/ -#define TIMEVAL_TO_DOUBLE(tv) ((tv).tv_sec + 1e-6 * ((tv).tv_usec)) +#define TIMEVAL_TO_DOUBLE(tv) ((tv).tv_sec + 1e-9 * ((tv).tv_nsec)) /**Takes the tv1-tv2 between two timevals and returns the result as a double*/ -#define TIMEVAL_DIFF(tv1, tv2) ((tv1).tv_sec - (tv2).tv_sec + 1e-6 * ((tv1).tv_usec - (tv2).tv_usec)) - - -extern bool PathExists(const char * path); - +#define TIMEVAL_DIFF(tv1, tv2) ((tv1).tv_sec - (tv2).tv_sec + 1e-9 * ((tv1).tv_nsec - (tv2).tv_nsec)) +/** Converts a double time value (in seconds) to a timespec **/ +#define DOUBLE_TO_TIMEVAL(value, tv) { \ + (tv)->tv_sec = (int)(value); \ + (tv)->tv_nsec = ((value) - (int)(value))*1e9; \ + } + +//extern bool PathExists(const char * path); +extern bool DirExists(const char * path);