this repo has no description

make CONST_HEAP work on macOS

authored by

Jacob Denbeaux and committed by
Max Bernstein
6fafd59e cd0c2af6

+15 -2
+1
compiler_tests.py
··· 24 24 with open(os.path.join(dirname, "cli.c"), "r") as f: 25 25 c_file.write(f.read()) 26 26 with tempfile.NamedTemporaryFile(mode="w", suffix=".out", delete=False) as out_file: 27 + print(" ".join([*cc, *cflags, "-o", out_file.name, c_file.name])) 27 28 subprocess.run([*cc, *cflags, "-o", out_file.name, c_file.name], check=True) 28 29 return out_file.name 29 30
+14 -2
runtime.c
··· 206 206 #undef __attribute__ 207 207 #endif 208 208 209 - extern char __start_const_heap[]; 210 - extern char __stop_const_heap[]; 209 + extern char __start_const_heap[] 210 + #ifdef __APPLE__ 211 + __asm("section$start$__DATA$const_heap") 212 + #endif 213 + ; 214 + extern char __stop_const_heap[] 215 + #ifdef __APPLE__ 216 + __asm("section$end$__DATA$const_heap") 217 + #endif 218 + ; 211 219 212 220 bool in_const_heap(struct gc_obj* obj) { 213 221 return (uword)obj >= (uword)__start_const_heap && ··· 861 869 862 870 // Put something in the const heap so that __start_const_heap and 863 871 // __stop_const_heap are defined by the linker. 872 + #ifdef __APPLE__ 873 + #define CONST_HEAP const __attribute__((section("__DATA,const_heap"))) 874 + #else 864 875 #define CONST_HEAP const __attribute__((section("const_heap"))) 876 + #endif 865 877 CONST_HEAP 866 878 __attribute__((used)) struct heap_string private_unused_const_heap = { 867 879 .HEAD.tag = TAG_STRING, .size = 11, .data = "hello world"};