add heap and _sbrk to mc13224v
This commit is contained in:
parent
9572baa71b
commit
f5ba70cd20
|
@ -36,6 +36,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "mc1322x.h"
|
#include "mc1322x.h"
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
int raise(void)
|
int raise(void)
|
||||||
{
|
{
|
||||||
|
@ -49,3 +50,25 @@ void srand(unsigned int seed) {
|
||||||
int rand(void) {
|
int rand(void) {
|
||||||
return (int)*MACA_RANDOM;
|
return (int)*MACA_RANDOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int __HEAP_START;
|
||||||
|
extern int __HEAP_END;
|
||||||
|
|
||||||
|
caddr_t _sbrk ( int incr )
|
||||||
|
{
|
||||||
|
static unsigned char *heap = NULL;
|
||||||
|
unsigned char *prev_heap;
|
||||||
|
|
||||||
|
if (heap == NULL) {
|
||||||
|
heap = (unsigned char *)&__HEAP_START;
|
||||||
|
}
|
||||||
|
prev_heap = heap;
|
||||||
|
/* check removed to show basic approach */
|
||||||
|
|
||||||
|
if((heap + incr) >= (unsigned char *)&__HEAP_END) return((void *)-1);
|
||||||
|
|
||||||
|
heap += incr;
|
||||||
|
|
||||||
|
return (caddr_t) prev_heap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,11 +215,11 @@ HEAP_SIZE = 1024;
|
||||||
. = ALIGN(32 / 8);
|
. = ALIGN(32 / 8);
|
||||||
|
|
||||||
.heap : {
|
.heap : {
|
||||||
__heap_start__ = . ;
|
__heap_start__ = . ; PROVIDE(__HEAP_START = .);
|
||||||
*(.heap);
|
*(.heap);
|
||||||
. += HEAP_SIZE;
|
. += HEAP_SIZE;
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
__heap_end__ = . ;
|
__heap_end__ = . ; PROVIDE(__HEAP_END = .);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue