diff options
Diffstat (limited to 'sys/amd64/include/stack.h')
| -rw-r--r-- | sys/amd64/include/stack.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/amd64/include/stack.h b/sys/amd64/include/stack.h new file mode 100644 index 000000000000..848f35aad1a1 --- /dev/null +++ b/sys/amd64/include/stack.h @@ -0,0 +1,29 @@ +/* + * This file is in the public domain. + */ + +#ifndef _MACHINE_STACK_H_ +#define _MACHINE_STACK_H_ + +#include <x86/stack.h> + +#ifdef _SYS_PROC_H_ + +/* Get the current kernel thread stack usage. */ +#define GET_STACK_USAGE(total, used) do { \ + struct thread *td = curthread; \ + (total) = td->td_kstack_pages * PAGE_SIZE; \ + (used) = (char *)td->td_kstack + \ + td->td_kstack_pages * PAGE_SIZE - \ + (char *)&td; \ +} while (0) + +static __inline bool +kstack_contains(struct thread *td, vm_offset_t va, size_t len) +{ + return (va >= td->td_kstack && va + len >= va && + va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE); +} +#endif /* _SYS_PROC_H_ */ + +#endif |
