Debian Codegraph @

rt/+dragonfly/start+test+libc.ha

raw
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 @symbol("__libc_init_array_start") const init_start: [*]*fn() void;
7 @symbol("__libc_init_array_end") const init_end: [*]*fn() void;
8 @symbol("__fini_array_start") const fini_start: [*]*fn() void;
9 @symbol("__fini_array_end") const 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 @symbol("environ") let c_envp: *[*]nullable *u8;