alpha
Login
or
Join now
tombl.dev
/
distro
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
add basic-init test package
author
Thomas Stokes
date
1 year ago
(Jan 15, 2025, 11:29 PM +0800)
commit
d12a5b49
d12a5b494fd4c90874af628cfb7bee2d36758f99
parent
4cf31410
4cf31410453c20f1f04539b744a17eb5b8d962e4
+55
2 changed files
Expand all
Collapse all
Unified
Split
packages
basic-init
init.c
package.nix
+30
packages/basic-init/init.c
Reviewed
···
1
1
+
#include <sched.h>
2
2
+
#include <stdio.h>
3
3
+
#include <sys/utsname.h>
4
4
+
#include <unistd.h>
5
5
+
6
6
+
int main(int argc, char *argv[], char *envp[]) {
7
7
+
printf("Hello, world!\n");
8
8
+
9
9
+
printf("pid = %d\n", getpid());
10
10
+
11
11
+
struct utsname sysinfo;
12
12
+
if (uname(&sysinfo) == -1) {
13
13
+
perror("uname");
14
14
+
return 1;
15
15
+
}
16
16
+
17
17
+
printf("%s %s %s\n", sysinfo.sysname, sysinfo.release, sysinfo.version);
18
18
+
19
19
+
printf("argc = %d\n", argc);
20
20
+
for (int i = 0; i < argc; i++)
21
21
+
printf("argv[%d] = %s\n", i, argv[i]);
22
22
+
for (int i = 0; envp[i]; i++)
23
23
+
printf("envp[%d] = %s\n", i, envp[i]);
24
24
+
25
25
+
printf("idling forever\n");
26
26
+
for (;;)
27
27
+
sched_yield();
28
28
+
29
29
+
return 0;
30
30
+
}
+25
packages/basic-init/package.nix
Reviewed
···
1
1
+
{
2
2
+
run,
3
3
+
4
4
+
clang,
5
5
+
lld,
6
6
+
musl,
7
7
+
compiler-rt,
8
8
+
}:
9
9
+
10
10
+
run
11
11
+
{
12
12
+
name = "basic-init";
13
13
+
src = ./.;
14
14
+
path = [
15
15
+
clang
16
16
+
lld
17
17
+
];
18
18
+
}
19
19
+
''
20
20
+
clang -c -o init.o init.c --target=wasm32 -nostdinc -isystem ${musl}/include
21
21
+
wasm-ld -o init init.o ${compiler-rt}/libclang_rt.builtins-wasm32.a ${musl}/lib/crt1.o -L${musl}/lib -lc --fatal-warnings --initial-memory=655360
22
22
+
23
23
+
mkdir -p $out/bin
24
24
+
cp init $out/bin
25
25
+
''