added monotonic clock plugin

This commit is contained in:
roberto@quantal64
2012-08-25 17:15:58 +02:00
parent a491be3975
commit 7033a0b5d2
3 changed files with 40 additions and 0 deletions
+2
View File
@@ -2041,6 +2041,8 @@ int main(int argc, char *argv[], char *envp[]) {
uwsgi_log_initial("machine: %s\n", uuts.machine);
}
uwsgi_log_initial("clock source: %s\n", uwsgi.clock->name);
#ifdef __BIG_ENDIAN__
uwsgi_log_initial("*** big endian arch detected ***\n");
+32
View File
@@ -0,0 +1,32 @@
#include "../../uwsgi.h"
// timespecs have nanoseconds resolution
time_t uwsgi_monotonic_seconds() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec;
}
uint64_t uwsgi_monotonic_microseconds() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000000) + (ts.tv_nsec*1000);
}
static struct uwsgi_clock uwsgi_monotonic_clock = {
.name = "monotonic",
.seconds = uwsgi_monotonic_seconds,
.microseconds = uwsgi_monotonic_microseconds,
};
void uwsgi_monotonic_clock_load() {
uwsgi_register_clock(&uwsgi_monotonic_clock);
}
struct uwsgi_plugin clock_monotonic_plugin = {
.name = "clock_monotonic",
.on_load = uwsgi_monotonic_clock_load
};
+6
View File
@@ -0,0 +1,6 @@
NAME='clock_monotonic'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['clock_monotonic']