aboutgitcodebugslistschat
path: root/util.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-08-06 16:18:36 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-08-07 09:15:40 +0200
commit95569e4aa4da405c0df152956a58a119e248143c (patch)
tree1f28e327723cb77d6627327c23d3d552e6863ee7 /util.h
parentfbb0c9523e416a5c1ecf42287d867fc799fbf0f9 (diff)
downloadpasst-95569e4aa4da405c0df152956a58a119e248143c.tar
passt-95569e4aa4da405c0df152956a58a119e248143c.tar.gz
passt-95569e4aa4da405c0df152956a58a119e248143c.tar.bz2
passt-95569e4aa4da405c0df152956a58a119e248143c.tar.lz
passt-95569e4aa4da405c0df152956a58a119e248143c.tar.xz
passt-95569e4aa4da405c0df152956a58a119e248143c.tar.zst
passt-95569e4aa4da405c0df152956a58a119e248143c.zip
util: Some corrections for timespec_diff_us
The comment for timespec_diff_us() claims it will wrap after 2^64µs. This is incorrect for two reasons: * It returns a long long, which is probably 64-bits, but might not be * It returns a signed value, so even if it is 64 bits it will wrap after 2^63µs Correct the comment and use an explicitly 64-bit type to avoid that imprecision. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.h')
-rw-r--r--util.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/util.h b/util.h
index e8bf957..83d2b53 100644
--- a/util.h
+++ b/util.h
@@ -168,7 +168,7 @@ int sock_l4(const struct ctx *c, sa_family_t af, enum epoll_type type,
uint32_t data);
void sock_probe_mem(struct ctx *c);
long timespec_diff_ms(const struct timespec *a, const struct timespec *b);
-long long timespec_diff_us(const struct timespec *a, const struct timespec *b);
+int64_t timespec_diff_us(const struct timespec *a, const struct timespec *b);
void bitmap_set(uint8_t *map, unsigned bit);
void bitmap_clear(uint8_t *map, unsigned bit);
bool bitmap_isset(const uint8_t *map, unsigned bit);