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