diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2016-03-02 22:42:40 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-03-04 15:12:19 +1100 |
commit | b8d4eafe29684fe4f5bb587f7eab948e6ed62723 (patch) | |
tree | 3bdc08a366a144ea37ee94907d62f21fa52d2f53 /misc.c | |
parent | 18f64b969c70ed00e74b9d8e50359dbe698ce4c0 (diff) |
upstream commit
Improve precision of progressmeter for sftp and scp by
storing sub-second timestamps. Pointed out by mmcc@, ok deraadt@ markus@
Upstream-ID: 38fd83a3d83dbf81c8ff7b5d1302382fe54970ab
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.101 2016/01/20 09:22:39 dtucker Exp $ */ +/* $OpenBSD: misc.c,v 1.102 2016/03/02 22:42:40 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -909,6 +909,17 @@ monotime(void) return time(NULL); } +double +monotime_double(void) +{ + struct timespec ts; + + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) + fatal("clock_gettime: %s", strerror(errno)); + + return (ts.tv_sec + (double)ts.tv_nsec / 1000000000); +} + void bandwidth_limit_init(struct bwlimit *bw, u_int64_t kbps, size_t buflen) { |