Add stack checking functions

This commit is contained in:
2020-02-21 23:01:04 +01:00
parent b5d4bf5528
commit 68fc473372
3 changed files with 71 additions and 2 deletions

View File

@@ -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__ */