hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

start+libc.ha (816B)


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