shithub: femtolisp

Download patch

ref: ccb3743d19272e051bbe4be8c080ef44376cfac5
parent: 71f61c850babd66d4f251cb68786e6bb853c89df
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Jan 17 13:29:30 EST 2025

move INITIAL_HEAP_SIZE & ALLOC_LIMIT_TRIGGER to platform.h; allow redefining during configuration

--- a/dos/platform.h
+++ b/dos/platform.h
@@ -39,6 +39,13 @@
 #define PATHLISTSEPSTRING ":"
 #define ISPATHSEP(c) ((c) == '\\')
 
+#if !defined(INITIAL_HEAP_SIZE)
+#define INITIAL_HEAP_SIZE 4*1024*1024
+#endif
+#if !defined(ALLOC_LIMIT_TRIGGER)
+#define ALLOC_LIMIT_TRIGGER INITIAL_HEAP_SIZE
+#endif
+
 #include "cc.h"
 #include "mem.h"
 #include "mp.h"
--- a/macos/platform.h
+++ b/macos/platform.h
@@ -44,6 +44,13 @@
 #error unknown byte order
 #endif
 
+#if !defined(INITIAL_HEAP_SIZE)
+#define INITIAL_HEAP_SIZE 128*1024
+#endif
+#if !defined(ALLOC_LIMIT_TRIGGER)
+#define ALLOC_LIMIT_TRIGGER INITIAL_HEAP_SIZE
+#endif
+
 #include "cc.h"
 #include "mem.h"
 #include "mp.h"
--- a/meson.build
+++ b/meson.build
@@ -79,12 +79,6 @@
 		required: true,
 	)
 	cpp = meson.get_compiler('cpp')
-	add_project_arguments(
-		'-DINITIAL_HEAP_SIZE=128*1024',
-		'-DALLOC_LIMIT_TRIGGER=64*1024',
-		'-D__thread=', # does not make sense anyway
-		language: 'c',
-	)
 	if host_machine.cpu() == 'm68k'
 		add_project_arguments(
 			# don't expect NewPtr-returned pointers to be aligned by 8 bytes
@@ -104,20 +98,10 @@
 elif host_machine.system() == 'dos'
 	flisp_exe_name = 'flisp.exe'
 	platform = 'dos'
-	add_project_arguments(
-		'-DINITIAL_HEAP_SIZE=2*1024*1024',
-		'-DALLOC_LIMIT_TRIGGER=256*1024*1024',
-		language: 'c',
-	)
 	inc += [include_directories('dos')]
 else
 	platform = 'posix'
 	flisp_exe_name = 'flisp'
-	add_project_arguments(
-		'-DINITIAL_HEAP_SIZE=8*1024*1024',
-		'-DALLOC_LIMIT_TRIGGER=1*1024*1024',
-		language: 'c',
-	)
 	inc += [include_directories('posix')]
 endif
 
--- a/mkfile
+++ b/mkfile
@@ -5,8 +5,6 @@
 CFLAGS=$CFLAGS -p -I. -I3rd -I3rd/brieflz -Iplan9 \
 	-D__plan9__ -D__${objtype}__ \
 	-DNDEBUG \
-	-DINITIAL_HEAP_SIZE=8*1024*1024 \
-	-DALLOC_LIMIT_TRIGGER=1*1024*1024 \
 
 CLEANFILES=plan9/flisp.boot.s plan9/builtin_fns.h
 
--- a/plan9/platform.h
+++ b/plan9/platform.h
@@ -129,5 +129,12 @@
 int wcwidth(Rune c);
 int ftruncate(int f, off_t sz);
 
+#if !defined(INITIAL_HEAP_SIZE)
+#define INITIAL_HEAP_SIZE 16*1024*1024
+#endif
+#if !defined(ALLOC_LIMIT_TRIGGER)
+#define ALLOC_LIMIT_TRIGGER INITIAL_HEAP_SIZE
+#endif
+
 #include "cc.h"
 #include "mem.h"
--- a/posix/platform.h
+++ b/posix/platform.h
@@ -65,6 +65,13 @@
 #define BYTE_ORDER __BYTE_ORDER
 #endif
 
+#if !defined(INITIAL_HEAP_SIZE)
+#define INITIAL_HEAP_SIZE 16*1024*1024
+#endif
+#if !defined(ALLOC_LIMIT_TRIGGER)
+#define ALLOC_LIMIT_TRIGGER INITIAL_HEAP_SIZE
+#endif
+
 #include "cc.h"
 #include "mem.h"
 #include "mp.h"