2019-12-18 11:02:53 +01:00
|
|
|
#include <stdint.h>
|
2015-05-21 10:26:49 +02:00
|
|
|
#include "string.h"
|
2016-09-06 15:44:17 +02:00
|
|
|
#include "bios.h"
|
2015-05-21 10:26:49 +02:00
|
|
|
|
|
|
|
|
static uint8_t *fseg_base = &edata;
|
|
|
|
|
static uint8_t *malloc_top = &stext;
|
|
|
|
|
|
2017-03-30 18:20:50 +08:00
|
|
|
void *malloc_align(int n, int align)
|
2015-05-21 10:26:49 +02:00
|
|
|
{
|
2017-03-30 18:20:50 +08:00
|
|
|
malloc_top = (uint8_t *) ((uintptr_t)(malloc_top - n) & -align);
|
2015-05-21 10:26:49 +02:00
|
|
|
return malloc_top;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-30 18:20:50 +08:00
|
|
|
void *malloc_fseg_align(int n, int align)
|
2015-05-21 10:26:49 +02:00
|
|
|
{
|
2017-03-30 18:20:50 +08:00
|
|
|
void *p;
|
|
|
|
|
fseg_base = (uint8_t *) (((uintptr_t)fseg_base + align - 1) & -align);
|
|
|
|
|
p = fseg_base;
|
|
|
|
|
fseg_base += n;
|
2015-05-21 10:26:49 +02:00
|
|
|
return p;
|
|
|
|
|
}
|