git: e75c8faf277d - main - virtual_oss: Use virtual_oss_timestamp() to avoid duplication
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 07 Mar 2026 23:46:37 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=e75c8faf277dded0a80d469cb8182583716a2211
commit e75c8faf277dded0a80d469cb8182583716a2211
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-03-07 23:46:28 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-03-07 23:46:28 +0000
virtual_oss: Use virtual_oss_timestamp() to avoid duplication
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
---
usr.sbin/virtual_oss/virtual_oss/virtual_oss.c | 29 ++++++++++++--------------
1 file 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
@@ -41,6 +41,18 @@
#include "backend.h"
#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)
{
@@ -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)