Move kstack_contains() and GET_STACK_USAGE() to MD machine/stack.h
Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38320
This commit is contained in:
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/proc.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/reg.h>
|
||||
#include <machine/pcb.h>
|
||||
#ifdef VFP
|
||||
#include <machine/vfp.h>
|
||||
#endif
|
||||
|
||||
@@ -56,15 +56,4 @@ struct mdproc {
|
||||
|
||||
#define KINFO_PROC_SIZE 816
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <machine/pcb.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 - sizeof(struct pcb); \
|
||||
(used) = td->td_kstack + (total) - (vm_offset_t)&td; \
|
||||
} while (0)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_MACHINE_PROC_H_ */
|
||||
|
||||
@@ -63,6 +63,25 @@ struct linker_file;
|
||||
void unwind_module_loaded(struct linker_file *);
|
||||
void unwind_module_unloaded(struct linker_file *);
|
||||
|
||||
#ifdef _SYS_PROC_H_
|
||||
|
||||
#include <machine/pcb.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 - sizeof(struct pcb); \
|
||||
(used) = td->td_kstack + (total) - (vm_offset_t)&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
|
||||
|
||||
#endif /* !_MACHINE_STACK_H_ */
|
||||
|
||||
Reference in New Issue
Block a user