summaryrefslogtreecommitdiff
path: root/src/cmd/netstack/util.h
diff options
context:
space:
mode:
authordzwdz2024-05-04 18:22:23 +0200
committerdzwdz2024-05-04 18:22:23 +0200
commit8c7b8d9e4ec40c38c657851354fc74428f0df1ac (patch)
tree29588306bd4453de86fc5a4ba230537f8f47bea5 /src/cmd/netstack/util.h
parent32d7e504169351ce6a5542b4f559c7e4d3834b45 (diff)
user/ntpfs: implement a basic ntp client
time() will probably end up doing io. That sounded bad at first, but Plan 9 does that too (see /sys/src/libc/9sys/nsec.c), so it's probably fine. I might need better service management soon. Also, dunno what it should return before it makes contact with NTP. I could implement RTC support, but eh. Doesn't feel that necessary. I'll also need to remember how the hell threading works, so it can talk with the ntp daemon on another thread.
Diffstat (limited to 'src/cmd/netstack/util.h')
-rw-r--r--src/cmd/netstack/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/netstack/util.h b/src/cmd/netstack/util.h
index c1032a2..1cd22fb 100644
--- a/src/cmd/netstack/util.h
+++ b/src/cmd/netstack/util.h
@@ -40,3 +40,15 @@ static inline uint32_t nget32(const void *vbuf) {
| (b[2] << 8)
| (b[3] << 0);
}
+
+static inline uint64_t nget64(const void *vbuf) {
+ const uint8_t *b = vbuf;
+ return ((uint64_t)b[0] << 56)
+ | ((uint64_t)b[1] << 48)
+ | ((uint64_t)b[2] << 40)
+ | ((uint64_t)b[3] << 32)
+ | ((uint64_t)b[4] << 24)
+ | ((uint64_t)b[5] << 16)
+ | ((uint64_t)b[6] << 8)
+ | ((uint64_t)b[7] << 0);
+}