]> git.proxmox.com Git - mirror_qemu.git/commitdiff
bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl_oidfmt
authorJuergen Lock <nox@jelal.kn-bremen.de>
Fri, 10 Feb 2023 22:13:30 +0000 (15:13 -0700)
committerWarner Losh <imp@bsdimp.com>
Wed, 1 Mar 2023 18:09:18 +0000 (11:09 -0700)
Helper functions for sysctl implementations. sysctl_name2oid and
sysctl_oidfmt convert oids between host and targets

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
bsd-user/freebsd/os-sys.c

index 2e0a6c058d65ae4aa21908497d4b16950dddfbb3..8bd1db694105481f8029034da82bd2be45d3bc47 100644 (file)
@@ -230,6 +230,24 @@ static void G_GNUC_UNUSED h2g_old_sysctl(void *holdp, size_t *holdlen, uint32_t
 #endif
 }
 
+/*
+ * Convert the undocmented name2oid sysctl data for the target.
+ */
+static inline void G_GNUC_UNUSED sysctl_name2oid(uint32_t *holdp, size_t holdlen)
+{
+    size_t i, num = holdlen / sizeof(uint32_t);
+
+    for (i = 0; i < num; i++) {
+        holdp[i] = tswap32(holdp[i]);
+    }
+}
+
+static inline void G_GNUC_UNUSED sysctl_oidfmt(uint32_t *holdp)
+{
+    /* byte swap the kind */
+    holdp[0] = tswap32(holdp[0]);
+}
+
 /* sysarch() is architecture dependent. */
 abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
 {