diff options
| author | Christos Margiolis <christos@FreeBSD.org> | 2026-03-07 23:46:28 +0000 |
|---|---|---|
| committer | Christos Margiolis <christos@FreeBSD.org> | 2026-03-07 23:46:28 +0000 |
| commit | e75c8faf277dded0a80d469cb8182583716a2211 (patch) | |
| tree | 38cafb5da5067bdf7bd3cfef1ac2eaa348ff478e | |
| parent | 3a410851bf02c247e71bcd06fdeec2706c6b6070 (diff) | |
virtual_oss: Use virtual_oss_timestamp() to avoid duplication
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
| -rw-r--r-- | usr.sbin/virtual_oss/virtual_oss/virtual_oss.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/usr.sbin/virtual_oss/virtual_oss/virtual_oss.c b/usr.sbin/virtual_oss/virtual_oss/virtual_oss.c index 5554ddb9a592..1d95c87d57b1 100644 --- a/usr.sbin/virtual_oss/virtual_oss/virtual_oss.c +++ b/usr.sbin/virtual_oss/virtual_oss/virtual_oss.c @@ -42,6 +42,18 @@ #include "int.h" uint64_t +virtual_oss_timestamp(void) +{ + struct timespec ts; + uint64_t nsec; + + clock_gettime(CLOCK_MONOTONIC, &ts); + + nsec = ts.tv_sec * 1000000000ULL + ts.tv_nsec; + return (nsec); +} + +uint64_t virtual_oss_delay_ns(void) { uint64_t delay; @@ -56,31 +68,16 @@ virtual_oss_delay_ns(void) void virtual_oss_wait(void) { - struct timespec ts; uint64_t delay; uint64_t nsec; - clock_gettime(CLOCK_MONOTONIC, &ts); - - nsec = ts.tv_sec * 1000000000ULL + ts.tv_nsec; + nsec = virtual_oss_timestamp(); delay = virtual_oss_delay_ns(); usleep((delay - (nsec % delay)) / 1000); } -uint64_t -virtual_oss_timestamp(void) -{ - struct timespec ts; - uint64_t nsec; - - clock_gettime(CLOCK_MONOTONIC, &ts); - - nsec = ts.tv_sec * 1000000000ULL + ts.tv_nsec; - return (nsec); -} - static size_t vclient_read_linear(struct virtual_client *pvc, struct virtual_ring *pvr, int64_t *dst, size_t total) __requires_exclusive(atomic_mtx) |
