This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

musl and basic-init: support threads (#25)

+29 -6
+23
packages/basic-init/init.c
··· 1 + #define _GNU_SOURCE 2 + #include <stdlib.h> 1 3 #include <sched.h> 2 4 #include <stdio.h> 3 5 #include <sys/utsname.h> 4 6 #include <unistd.h> 7 + 8 + static int foo = 0; 9 + 10 + int other(void *arg) { 11 + printf("hello from other thread: %d\n", foo); 12 + return 0; 13 + } 5 14 6 15 int main(int argc, char *argv[], char *envp[]) { 7 16 printf("Hello, world!\n"); ··· 21 30 printf("argv[%d] = %s\n", i, argv[i]); 22 31 for (int i = 0; envp[i]; i++) 23 32 printf("envp[%d] = %s\n", i, envp[i]); 33 + 34 + foo = 1; 35 + void* stack = malloc(4096); 36 + if (!stack) { 37 + perror("malloc"); 38 + return 1; 39 + } 40 + 41 + if (clone(other, stack + 4096, CLONE_VM | CLONE_VFORK, NULL) == -1) { 42 + perror("clone"); 43 + return 1; 44 + } 45 + 46 + free(stack); 24 47 25 48 printf("idling forever\n"); 26 49 for (;;)
+2 -2
packages/basic-init/package.nix
··· 19 19 ]; 20 20 } 21 21 '' 22 - clang -c -o init.o init.c --target=wasm32 -nostdinc -isystem ${musl}/include ${lib.optionalString config.debug "-g"} 23 - 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 + clang -c -o init.o init.c --target=wasm32 -nostdinc -isystem ${musl}/include ${lib.optionalString config.debug "-g"} -matomics -mbulk-memory 23 + wasm-ld -o init init.o ${compiler-rt}/libclang_rt.builtins-wasm32.a ${musl}/lib/crt1.o -L${musl}/lib -lc --fatal-warnings --import-memory --max-memory=4294967296 --shared-memory --export-table 24 24 25 25 mkdir -p $out/bin 26 26 cp init $out/bin
+1 -1
packages/busybox/package.nix
··· 21 21 owner = "tombl"; 22 22 repo = "busybox"; 23 23 rev = "refs/heads/master"; 24 - hash = "sha256-Rlgj229jP+I/x3mdgilY6FHu1IDyAwpQc/pqBzQIasU="; 24 + hash = "sha256-cL/QLG0etQ1TxTBRMrKR5VESGPC73CDcoVomInmL8yE="; 25 25 }; 26 26 path = [ 27 27 clang
+1 -1
packages/linux/package.nix
··· 26 26 owner = "tombl"; 27 27 repo = "linux"; 28 28 rev = "refs/heads/wasm"; 29 - hash = "sha256-rK+2aXZ4K/9ObHI0oKTysVt54U/vXf5JslikUB8Iv7M="; 29 + hash = "sha256-foKmTG3DpKTXBmD4NI4nYJanaWwx0qSxEvHzEN0nnbM="; 30 30 }; 31 31 path = [ 32 32 bc
+2 -2
packages/musl/package.nix
··· 17 17 owner = "tombl"; 18 18 repo = "musl"; 19 19 rev = "refs/heads/master"; 20 - hash = "sha256-6v4HfJpWdHUA4hlauMRNFex03SkdfXUt7SkfGuQfMgE="; 20 + hash = "sha256-HPEneCJPOb5zSiVzV11g82lWEWKBZxTxIlO0gomNyvk="; 21 21 }; 22 22 path = [ 23 23 clang ··· 33 33 ARCH=wasm32 34 34 prefix=$out 35 35 syslibdir=$out 36 - CFLAGS=--target=wasm32 ${lib.optionalString config.debug "-g"} 36 + CFLAGS=--target=wasm32 ${lib.optionalString config.debug "-g"} -matomics -mbulk-memory 37 37 EOF 38 38 39 39 mkdir $out