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

View File

@ -19,7 +19,6 @@
#include <errno.h>
#include <openssl/err.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <netdb.h>
static SSL_CTX *proxy_ctx = NULL;

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;
}

View File

@ -37,4 +37,6 @@ int str_trim_lws(char **start, char **end);
int base64_encode(void *data, unsigned long data_len, char *output, unsigned long *output_len);
long clock_micros(void);
#endif //SESIMOS_UTILS_H