freebsd-dev/sys/amd64/include/stack.h
Konstantin Belousov 2555f175b3 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
2023-02-02 00:59:26 +02:00

31 lines
701 B
C

/*
* This file is in the public domain.
*/
/* $FreeBSD$ */
#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