diff options
author | Rob Landley <rob@landley.net> | 2018-01-06 15:43:17 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-01-06 15:43:17 -0600 |
commit | b432aee484bfca4d53cdce13343e6ee5c850d0f3 (patch) | |
tree | 0edd004bb051adf96aee91893e44324a784871ce | |
parent | 73690e9ebb24868a996567fdbe523ddc0a3c1415 (diff) | |
download | toybox-b432aee484bfca4d53cdce13343e6ee5c850d0f3.tar.gz |
Move millitime() into lib.c.
-rw-r--r-- | lib/lib.c | 13 | ||||
-rw-r--r-- | lib/lib.h | 1 | ||||
-rw-r--r-- | toys/posix/ps.c | 8 |
3 files changed, 12 insertions, 10 deletions
@@ -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; +} @@ -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 diff --git a/toys/posix/ps.c b/toys/posix/ps.c index 8d643576..76884c55 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1341,14 +1341,6 @@ static int header_line(int line, int rev) return line-1; } -static long long millitime(void) -{ - struct timespec ts; - - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec*1000+ts.tv_nsec/1000000; -} - static void top_common( int (*filter)(long long *oslot, long long *nslot, int milis)) { |