OSDN Git Service

6dff7e25240347b22246c5b389f3ec64eb628ab8
[trx-305dsp/dsp.git] / hirado / kernel / config / blackfin / cpu_malloc.c
1 #include <t_services.h>
2
3 static void * heapPtr = 0;
4 extern void *_heap_start, *_heap_end;
5
6 /*
7  * 要求があればヒープ上にメモリ領域を割り当てる。freeは使わないことを仮定している。
8  */
9
10 void * malloc(size_t size)
11 {
12     void * retPtr;
13     SIL_PRE_LOC;
14
15     SIL_LOC_INT();
16     // 最初の呼び出しでヒープを初期化する
17     if (! heapPtr)
18         heapPtr = _heap_start;
19
20     retPtr = heapPtr;
21
22     if ((heapPtr+size) >= _heap_end)
23         retPtr =  NULL;
24     else
25     {
26         heapPtr += size;
27             // ポインタを32bit境界に揃える
28         while ((unsigned int)heapPtr % 4)
29             heapPtr++;
30     }
31     SIL_UNL_INT();
32     return retPtr;
33 }
34
35 /*
36  * なにもせずに戻る
37  */
38 void free( void * ptr )
39 {
40 }