ソースを参照

Revert "Fix malloc corrupting the stack. Added new function reserve_stack() to adjust the amount of memory reserved for the stack."

Different version applied upstream.

This reverts commit c5bdda910b.
teensy4-core
Tilo Nitzsche 7年前
コミット
91190e6cf4
2個のファイルの変更0行の追加18行の削除
  1. +0
    -5
      teensy3/kinetis.h
  2. +0
    -13
      teensy3/mk20dx128.c

+ 0
- 5
teensy3/kinetis.h ファイルの表示

extern void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void); extern void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);
extern void (* const _VectorsFlash[NVIC_NUM_INTERRUPTS+16])(void); extern void (* const _VectorsFlash[NVIC_NUM_INTERRUPTS+16])(void);


// Reserve stack memory. This is the amount of memory malloc will leave alone
// for the stack. The stack can grow larger than this limit (growing towards /
// into the heap). 512 bytes are reserved by default.
extern void reserve_stack(int size);

#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

+ 0
- 13
teensy3/mk20dx128.c ファイルの表示

#include "core_pins.h" // testing only #include "core_pins.h" // testing only
#include "ser_print.h" // testing only #include "ser_print.h" // testing only


#include <errno.h>


// Flash Security Setting. On Teensy 3.2, you can lock the MK20 chip to prevent // Flash Security Setting. On Teensy 3.2, you can lock the MK20 chip to prevent
// anyone from reading your code. You CAN still reprogram your Teensy while // anyone from reading your code. You CAN still reprogram your Teensy while


char *__brkval = (char *)&_ebss; char *__brkval = (char *)&_ebss;


int reserved_stack_size = 512;

void reserve_stack(int size)
{
reserved_stack_size = size;
}

void * _sbrk(int incr) void * _sbrk(int incr)
{ {
if(__brkval + incr >= (char*) &_estack - reserved_stack_size)
{
errno = ENOMEM;
return (void*) -1;
}
char *prev = __brkval; char *prev = __brkval;
__brkval += incr; __brkval += incr;
return prev; return prev;

読み込み中…
キャンセル
保存