mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-03 15:38:36 +00:00
added monotonic clock plugin
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
NAME='clock_monotonic'
|
||||
|
||||
CFLAGS = []
|
||||
LDFLAGS = []
|
||||
LIBS = []
|
||||
GCC_LIST = ['clock_monotonic']
|
||||
Reference in New Issue
Block a user