From b432aee484bfca4d53cdce13343e6ee5c850d0f3 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 6 Jan 2018 15:43:17 -0600 Subject: Move millitime() into lib.c. --- lib/lib.c | 13 +++++++++++-- lib/lib.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index 8a818575..7f5fbbda 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -1353,7 +1353,16 @@ long environ_bytes() long bytes = sizeof(char *); char **ev; - for (ev = environ; *ev; ev++) - bytes += sizeof(char *) + strlen(*ev) + 1; + for (ev = environ; *ev; ev++) bytes += sizeof(char *) + strlen(*ev) + 1; + return bytes; } + +// Return unix time in milliseconds +long long millitime(void) +{ + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec*1000+ts.tv_nsec/1000000; +} diff --git a/lib/lib.h b/lib/lib.h index 021ab44a..5dd629d2 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -243,6 +243,7 @@ char *getusername(uid_t uid); char *getgroupname(gid_t gid); void do_lines(int fd, void (*call)(char **pline, long len)); long environ_bytes(); +long long millitime(void); #define HR_SPACE 1 // Space between number and units #define HR_B 2 // Use "B" for single byte units -- cgit v1.2.3