xref: /freebsd/sys/i386/include/stack.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*
2  * This file is in the public domain.
3  */
4 
5 #ifndef _MACHINE_STACK_H_
6 #define	_MACHINE_STACK_H_
7 
8 #include <x86/stack.h>
9 
10 #ifdef _SYS_PROC_H_
11 
12 /* Get the current kernel thread stack usage. */
13 #define GET_STACK_USAGE(total, used) do {				\
14 	struct thread	*td = curthread;				\
15 	(total) = (vm_offset_t)get_pcb_td(td) - td->td_kstack;		\
16 	(used) = (vm_offset_t)get_pcb_td(td) - (vm_offset_t)&td;	\
17 } while (0)
18 
19 static __inline bool
20 kstack_contains(struct thread *td, vm_offset_t va, size_t len)
21 {
22 	return (va >= td->td_kstack && va + len >= va &&
23 	    va + len <= (vm_offset_t)get_pcb_td(td));
24 }
25 
26 #endif	/* _SYS_PROC_H_ */
27 
28 #endif
29