Skip to content

Commit

Permalink
Add libc-free hello_world
Browse files Browse the repository at this point in the history
  • Loading branch information
data-man authored and lerno committed Sep 15, 2023
1 parent 9233305 commit d129cd4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions resources/examples/nolibc/hello_world.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fn int main()
{
String msg = "Hello, C3 World!\n";
$$syscall(1, 1, (uptr)msg.ptr, msg.len); // __NR_write, STDOUT
return 0;
}

fn void _start() @export("_start")
{
int ret = main();
$$syscall(60, ret); // __NR_exit
}

module std::core::builtin;

def PanicFn = fn void(String message, String file, String function, uint line);

PanicFn panic = &default_panic;

fn void default_panic(String message, String file, String function, uint line)
{
}
21 changes: 21 additions & 0 deletions resources/examples/nolibc/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"authors": [ "Dmitry Atamanov https://github.com/data-man" ],
"version": "0.0.1 Omega",
"sources": [ "./**" ],
"targets": {
"hello_world": {
"type": "executable",
"opt": "O3",
"nolibc": true,
"nostdlib": true
},
},
"debug-info": "none",
"target": "linux-x64",
"reloc": "none",
"trap-on-wrap": false,
"soft-float": false,
"x86vec": "sse",
"cpu": "generic",
"output": "."
}

0 comments on commit d129cd4

Please sign in to comment.