start+test+libc.ha (819B)
1 // SPDX-License-Identifier: MPL-2.0 2 // (c) Hare authors <https://harelang.org> 3 4 @symbol("__test_main") fn test_main() size; 5 6 const @symbol("__libc_init_array_start") init_start: [*]*fn() void; 7 const @symbol("__libc_init_array_end") init_end: [*]*fn() void; 8 const @symbol("__fini_array_start") fini_start: [*]*fn() void; 9 const @symbol("__fini_array_end") fini_end: [*]*fn() void; 10 11 export @symbol("main") fn start_ha(c_argc: int, c_argv: *[*]*u8) int = { 12 argc = c_argc: size; 13 argv = c_argv; 14 envp = c_envp; 15 // we deliberately prevent libc from running @init for us, in order to 16 // be able to initialize argc/argv/envp beforehand. we can still get 17 // away with just using libc for @fini though 18 init(); 19 const nfail = test_main(); 20 return if (nfail > 0) 1 else 0; 21 }; 22 23 let @symbol("environ") c_envp: *[*]nullable *u8;