Add clock_micros()

This commit is contained in:
2022-12-31 00:53:36 +01:00
parent 9ad1ecf1da
commit 96f3225f51
7 changed files with 20 additions and 14 deletions
+7
View File
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
static const char base64_encode_table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -203,3 +204,9 @@ int base64_encode(void *data, unsigned long data_len, char *output, unsigned lon
return 0;
}
long clock_micros(void) {
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
return time.tv_sec * 10000000 + time.tv_nsec / 1000;
}