hare

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

start.ha (752B)


      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 // The setup of envp and args is done here. This is called by crt0 before
      8 // normal init functions are called.
      9 export @symbol("preinit_hare") fn preinit_hare(
     10 	c_argc: int,
     11 	c_argv: *[*]*u8,
     12 	c_envp: *[*]nullable *u8
     13 ) void = {
     14 	argc = c_argc: size;
     15 	argv = c_argv;
     16 	envp = c_envp;
     17 };
     18 
     19 // The purpose of this "fake" main function is to make sure we exit with the
     20 // correct exit code in the case that rt::exit() is not called from within the
     21 // program. The intilization and finilization functions are not run from here,
     22 // they are ran by crt0.
     23 export @symbol("main") fn _main() void = {
     24 	main();
     25 	exit(0);
     26 };