Skip to content

Commit

Permalink
add kernel boot time in nanoseconds support
Browse files Browse the repository at this point in the history
  • Loading branch information
pouriyajamshidi committed Jul 29, 2023
1 parent b92bbf3 commit fa6e9d9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/nixtime/nixtime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nixtime

// #cgo CFLAGS: -g -Wall
/*
#include <time.h>
static unsigned long long get_nsecs(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (unsigned long long)ts.tv_sec * 1000000000UL + ts.tv_nsec;
}
*/
import "C"

func GetNanosecSinceBoot() uint64 {
return uint64(C.get_nsecs())
}

0 comments on commit fa6e9d9

Please sign in to comment.