hare

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

start+test.ha (834B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 // The real main function.
      5 @symbol(".main") fn main() void;
      6 
      7 @symbol("__test_main") fn test_main() size;
      8 
      9 // The setup of envp and args is done here. This is called by crt0 before
     10 // normal init functions are called.
     11 export @symbol("preinit_hare") fn preinit_hare(
     12 	c_argc: int,
     13 	c_argv: *[*]*u8,
     14 	c_envp: *[*]nullable *u8
     15 ) void = {
     16 	argc = c_argc: size;
     17 	argv = c_argv;
     18 	envp = c_envp;
     19 };
     20 
     21 // The purpose of this "fake" main function is to make sure we exit with the
     22 // correct exit code in the case that rt::exit() is not called from within the
     23 // program. The intilization and finilization functions are not run from here,
     24 // they are ran by crt0.
     25 export @symbol("main") fn _main() void = {
     26 	const ret = if (test_main() > 0) 1 else 0;
     27 	exit(ret);
     28 };