FreeBSD: improve internal syscallbyname

Post FreeBSD 12.2 this is a syscall that does everything
(rather than needing an undocumented syscall).
This commit is contained in:
Paul Floyd 2023-02-02 22:06:38 +01:00
parent a8e350c6d1
commit 7003f40be9
2 changed files with 7 additions and 2 deletions

View File

@ -1194,12 +1194,16 @@ void VG_(do_atfork_child)(ThreadId tid)
}
/* ---------------------------------------------------------------------
FreeBSD sysctlbyname(), modfind(), etc
FreeBSD sysctlbyname, getosreldate, is32on64
------------------------------------------------------------------ */
#if defined(VGO_freebsd)
Int VG_(sysctlbyname)(const HChar *name, void *oldp, SizeT *oldlenp, const void *newp, SizeT newlen)
{
#if (FREEBSD_VERS >= FREEBSD_12_2)
SysRes res = VG_(do_syscall5)(__NR___sysctlbyname, (UWord)name, (UWord)oldp, (UWord)oldlenp, (UWord)newp, (UWord)newlen);
return sr_isError(res) ? -1 : sr_Res(res);
#else
Int oid[2];
Int real_oid[10];
SizeT oidlen;
@ -1214,6 +1218,7 @@ Int VG_(sysctlbyname)(const HChar *name, void *oldp, SizeT *oldlenp, const void
oidlen /= sizeof(int);
error = VG_(sysctl)(real_oid, oidlen, oldp, oldlenp, newp, newlen);
return error;
#endif
}
Int VG_(getosreldate)(void)

View File

@ -86,7 +86,7 @@ extern void VG_(do_atfork_parent) ( ThreadId tid );
extern void VG_(do_atfork_child) ( ThreadId tid );
#if defined(VGO_freebsd)
// sysctl, modfind
// sysctlbyname, getosreldate, is32on64
extern Int VG_(sysctlbyname)(const HChar *name, void *oldp, SizeT *oldlenp, const void *newp, SizeT newlen);
extern Int VG_(getosreldate)(void);
extern Bool VG_(is32on64)(void);