Fix flisp_alloc + misc
This commit is contained in:
parent
cbbf4b0724
commit
a4b8d3f76f
3 changed files with 13 additions and 7 deletions
|
@ -28,7 +28,7 @@
|
|||
// Debug logs
|
||||
// 0 : None
|
||||
// 1 : All misc debug logs
|
||||
#define LOG 1
|
||||
#define LOG 0
|
||||
|
||||
// TODO : Automate this
|
||||
#define INTERPR
|
||||
|
|
|
@ -104,6 +104,8 @@ int alloc_init(){
|
|||
usage = NULL;
|
||||
if(!blocks || alloc_extend(EXT_BLOCK))
|
||||
return 1;
|
||||
// First 32bytes are reserved for null + alignement
|
||||
usage[0] = 0xF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -118,8 +120,8 @@ u32 flisp_alloc(u32 size){
|
|||
u32 curr_free = 0;
|
||||
while(pos < internal_size){
|
||||
if(usage[pos/32/8]){
|
||||
for(int i = 0; i < 32; i++){
|
||||
if((usage[pos/32/8]>>i) & 1)
|
||||
for(u32 opos = pos; pos < opos+32;){
|
||||
if((usage[pos/32/8]>>((pos/8)%32)) & 1)
|
||||
curr_free = 0;
|
||||
else
|
||||
curr_free+=8;
|
||||
|
@ -140,7 +142,7 @@ u32 flisp_alloc(u32 size){
|
|||
block->pos = pos-curr_free;
|
||||
block->size = size;
|
||||
for(u32 i = block->pos; i < block->pos+size; i+=8){
|
||||
usage[i/32/8] |= 1<<(i%32);
|
||||
usage[i/32/8] |= 1<<((i/8)%32);
|
||||
}
|
||||
// Unvirtualize the memory
|
||||
memset(get_addr(block->pos),0xB00B5069,size);
|
||||
|
|
10
src/parser.y
10
src/parser.y
|
@ -57,8 +57,12 @@
|
|||
%%
|
||||
|
||||
program:
|
||||
expr_list ';' {print_ast($1);execute($1);}
|
||||
| expr_list YYEOF {print_ast($1);execute($1);}
|
||||
expr_list ';'
|
||||
{print_ast($1);execute($1);}
|
||||
| expr_list YYEOF
|
||||
{print_ast($1);execute($1);}
|
||||
| program expr_list ';'
|
||||
{print_ast($2);execute($2);}
|
||||
;
|
||||
|
||||
type:
|
||||
|
@ -161,7 +165,7 @@ int main(int argc, char *argv[]){
|
|||
}
|
||||
else {
|
||||
printf("fLisp interactive env - v0.1\nFcalva 2025\n");
|
||||
printf("Under the terms of the GPL v2.0 license\n");
|
||||
printf("Under the terms of the GPL v3.0 license\n");
|
||||
yyin = stdin;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue