Getting the current thread's stack base / size on FreeBSD

From: David Chisnall <>
Date: Fri, 25 Mar 2022 11:41:18 UTC
Hi all,

I'm trying to get the VAVM[1] WebAssembly runtime working on FreeBSD. 
In its platform-specific code, they need to find the base and size of 
the current stack.  They have code for Linux and macOS, using different 
non-standard pthread extensions, but I couldn't see a mechanism for 
doing this on FreeBSD.  Is there an API for this?

Darwin provides a pair of _np APIs for getting these values.  Glibc 
provides an API for getting the pthread attributes for the current 
thread, which is a bit more general and useful.  Adding this to libthr 
would be a fairly simple change, if it doesn't exist already.  Am I 
missing an existing mechanism?