aboutsummaryrefslogtreecommitdiff
path: root/util.c
blob: cc7ccc011fc817a2ee5e046442d4a9fa98958a2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <sys/time.h>
#include "util.h"


i64 make_timestamp(void){
	struct timeval tv;
	gettimeofday(&tv,NULL);
	return (i64)tv.tv_sec*1000000+tv.tv_usec;
}

bool parse_i64(const char *str, i64 *out) {
	if (str[0] == '\0') return false;
	char *endp;
	i64 result = strtoll(str, &endp, 10);
	if (*endp != '\0') return false;
	*out = result;
	return true;
}