glcc: minilisp - w-i-p

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
petersieg
Posts: 110
Joined: 28 Jun 2023, 09:06

Re: glcc: minilisp - w-i-p

Post by petersieg »

Hi.

Great! But there is more to make minilisp.c compile:

Code: Select all

ich@iMac-von-ich minilisp % make
../../build/glcc -o minilisp.gt1 minilisp.c -map=64k -rom=v5a
minilisp.c:190: syntax error; found `size_t' expecting `;'
minilisp.c:226: unknown size for type `void'
minilisp.c:247: syntax error; found `Obj' expecting `;'
minilisp.c:250: undeclared identifier `uint8_t'
minilisp.c:250: illegal expression
minilisp.c:250: syntax error; found `obj' expecting `)'
minilisp.c:250: syntax error; found `obj' expecting `;'
minilisp.c:250: illegal expression
minilisp.c:250: syntax error; found `from_space' expecting `)'
minilisp.c:250: warning: expression with no effect elided
minilisp.c:250: syntax error; found `from_space' expecting `;'
minilisp.c:250: warning: expression with no effect elided
minilisp.c:262: illegal expression
minilisp.c:262: syntax error; found `scan2' expecting `)'
minilisp.c:262: syntax error; found `scan2' expecting `)'
minilisp.c:262: syntax error; found `scan2' expecting `;'
minilisp.c:262: warning: expression with no effect elided
minilisp.c:262: syntax error; found `)' expecting `;'
minilisp.c:262: illegal statement termination
minilisp.c:262: skipping `)'
minilisp.c:272: warning: implicit declaration of function `mmap'
minilisp.c:272: undeclared identifier `PROT_READ'
minilisp.c:272: undeclared identifier `PROT_WRITE'
minilisp.c:272: undeclared identifier `MAP_PRIVATE'
minilisp.c:272: too many errors
make: *** [minilisp.gt1] Error 1
The C99 headers: stdbool.h and stdint.h are missing and probably more stuff.

best, Peter
Attachments
minilisp.zip
(12.76 KiB) Downloaded 113 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: glcc: minilisp - w-i-p

Post by lb3361 »

Not sure.
  • The problem on line 190 is the keyword "inline" which is not supported and not functionally important. #define inline /**/
  • Line 226 is because memory is declared as void* which has no size and therefore does not support addition. It seems that more recent C treat them like char* for arithmetic. One would have to write Obj *obj = (Obj*)((char*)memory + mem_nused); Or maybe declare variable memory as char* and use casts in all places where a cast is needed.
  • line 247 like line 190
  • line 250 is the lack of stdint.h. One just has to use typedef unsigned char uint8_t;
Etc.
petersieg
Posts: 110
Joined: 28 Jun 2023, 09:06

Re: glcc: minilisp - w-i-p

Post by petersieg »

Hi.

ok. But than mman.h / mmap() causes trouble:

Code: Select all

../../build/glcc -o minilisp.gt1 minilisp.c -map=64k -rom=v5a
minilisp.c:273: warning: implicit declaration of function `mmap'
minilisp.c:273: undeclared identifier `PROT_READ'
minilisp.c:273: undeclared identifier `PROT_WRITE'
minilisp.c:273: undeclared identifier `MAP_PRIVATE'
minilisp.c:273: undeclared identifier `MAP_ANON'
minilisp.c:273: illegal return type; found `int' expected `pointer to void'
minilisp.c:279: syntax error; found `void' expecting `;'
minilisp.c:279: syntax error; found `void' expecting `;'
minilisp.c:279: syntax error; found `void' expecting `)'
minilisp.c:279: skipping `void'
minilisp.c:279: undeclared identifier `frame'
minilisp.c:279: type error: pointer expected
minilisp.c:279: type error: pointer expected
minilisp.c:279: operands of = have illegal types `int' and `pointer to void'
minilisp.c:279: warning: expression with no effect elided
minilisp.c:279: operands of = have illegal types `int' and `pointer to pointer to void'
minilisp.c:279: syntax error; found `)' expecting `;'
minilisp.c:279: illegal statement termination
minilisp.c:279: skipping `)'
minilisp.c:280: syntax error; found `int' expecting `;'
minilisp.c:280: warning: unreachable code
minilisp.c:280: syntax error; found `int' expecting `;'
minilisp.c:280: syntax error; found `int' expecting `)'
minilisp.c:280: too many errors
Looks like minilisp.c is a real trouble maker ;-)

best, Peter
Attachments
minilisp.zip
(12.79 KiB) Downloaded 117 times
lb3361
Posts: 367
Joined: 17 Feb 2021, 23:07

Re: glcc: minilisp - w-i-p

Post by lb3361 »

Function mmap does not exist at all because there is no virtual memory on the Gigatron. One could use malloc/free.
Or one could remember that there are only two semi spaces, alloc them as large global arrays, and swap them as needed.

Note that the copy garbage collector is not a great fit for the Gigatron because you can only use half the available memory (you need two copies). So on a 64k Gigatron, you can use two semi semi-spaces of 16KB, both located in the high memory because they have to be contiguous. And you need to think where to put the stack...
Post Reply