-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add kernel boot time in nanoseconds support
- Loading branch information
1 parent
b92bbf3
commit fa6e9d9
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} |