Add stack checking functions
This commit is contained in:
@@ -18,8 +18,24 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __STACK_CHECK_H__
|
||||
#define __STACK_CHECK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define STACK_CHECK_MIN_HEAP_GAP 16UL
|
||||
|
||||
int32_t stack_check_get_usage();
|
||||
|
||||
int32_t stack_check_get_free();
|
||||
|
||||
static inline uint32_t read_stack_pointer()
|
||||
{
|
||||
uint32_t stack_pointer;
|
||||
|
||||
__asm__ __volatile__ ("mov %0, sp\n\t" : "=r"(stack_pointer) : : );
|
||||
|
||||
return stack_pointer;
|
||||
}
|
||||
|
||||
#endif /* __STACK_CHECK_H__ */
|
||||
|
Reference in New Issue
Block a user