xref: /freebsd/sys/amd64/include/stack.h (revision 2a58b312b62f908ec92311d1bd8536dbaeb8e55b)
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) = td->td_kstack_pages * PAGE_SIZE;			\
17 	(used) = (char *)td->td_kstack +				\
18 	    td->td_kstack_pages * PAGE_SIZE -				\
19 	    (char *)&td;						\
20 } while (0)
21 
22 static __inline bool
23 kstack_contains(struct thread *td, vm_offset_t va, size_t len)
24 {
25 	return (va >= td->td_kstack && va + len >= va &&
26 	    va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
27 }
28 #endif	/* _SYS_PROC_H_ */
29 
30 #endif
31