From: Juergen Lock <n...@jelal.kn-bremen.de> Helper functions for sysctl implementations. sysctl_name2oid and sysctl_oidfmt convert oids between host and targets
Signed-off-by: Juergen Lock <n...@jelal.kn-bremen.de> Signed-off-by: Warner Losh <i...@bsdimp.com> --- bsd-user/freebsd/os-sys.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c index e3b9f168a2b..ac5ab9b17bc 100644 --- a/bsd-user/freebsd/os-sys.c +++ b/bsd-user/freebsd/os-sys.c @@ -115,6 +115,24 @@ static int sysctl_oldcvt(void *holdp, size_t *holdlen, uint32_t kind) return 0; } +/* + * Convert the undocmented name2oid sysctl data for the target. + */ +static inline void 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 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) { -- 2.39.1