msSince() function added to utils

This commit is contained in:
Hayley 2019-06-19 15:54:47 -05:00
parent a3c4fedced
commit f64b60a1c6
2 changed files with 10 additions and 0 deletions

View file

@ -86,6 +86,7 @@ float tsfSubtract(struct timespec time1, struct timespec time2)
return result;
}
//! get time since a certain time in microseconds
uint32 usSince(struct timespec time)
{
@ -95,6 +96,14 @@ uint32 usSince(struct timespec time)
return diff_us;
}
uint32 msSince(struct timespec time)
{
struct timespec delay;
clock_gettime(CLOCK_MONOTONIC, &delay);
uint32 diff_ms = (uint32)(tsSubtract(delay, time));
return diff_ms;
}
uint32 getIP(char* text)
{
uint32 ip;

View file

@ -40,6 +40,7 @@ void output(const char *fmt,...);
void tsAdd(struct timespec* time1, struct timespec time2);
float tsfSubtract(struct timespec time1, struct timespec time2);
uint32 usSince(struct timespec time);
uint32 msSince(struct timespec time);
uint32 getIP(char* text);
void lock_malloc_init(void);
void* safe_malloc(size_t size);