start with hello world in C
This commit is contained in:
parent
bc93aab53e
commit
2a791c418d
|
@ -1,3 +1 @@
|
|||
.gitignore
|
||||
|
||||
: foreach *.wast |> wat2wasm -o %o %f |> %B.wasm
|
||||
.gitignore
|
|
@ -1,4 +1,4 @@
|
|||
include_rules
|
||||
|
||||
: *_test.go | testdata/arbint.wasm testdata/struct.wasm |> vgo test -v -cover -race -o %o |> ../../bin/%d.test
|
||||
: *_test.go | testdata/*.wasm |> vgo test -v -cover -race -o %o |> ../../bin/%d.test
|
||||
: *.go |> vgo build -o %o |> ../../bin/land
|
||||
|
|
|
@ -4,4 +4,5 @@ CFLAGS += --target=wasm32-unknown-unknown-wasm
|
|||
CFLAGS += --sysroot=~/code/wasmception/sysroot/
|
||||
CFLAGS += -O0 -nostartfiles -Wl,--no-entry -nostdlib
|
||||
|
||||
: foreach *.wast |> wat2wasm -o %o %f |> %B.wasm
|
||||
: foreach *.c |> ~/code/wasmception/dist/bin/clang $(CFLAGS) %f -o %o |> %B.wasm
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
extern int open(const char *, int);
|
||||
extern int write(int, char *, int);
|
||||
extern int close(int);
|
||||
|
||||
__attribute__ ((visibility ("default")))
|
||||
int main() {
|
||||
const char *name = "hello";
|
||||
char *msg = "Hello, world!";
|
||||
int fd = open(name, 0x42);
|
||||
int num = write(fd, msg, 13);
|
||||
if (num == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
num = close(fd);
|
||||
if (num == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#define export __attribute__ ((visibility ("default"))
|
||||
#define import extern
|
||||
|
||||
import int close(int file);
|
||||
import int isatty(int file);
|
||||
import int open(const char *name, int flags, ...);
|
||||
import int read(int file, char *ptr, int len);
|
||||
import int write(int file, char *ptr, int len);
|
||||
import int unlink(char *name);
|
Binary file not shown.
Loading…
Reference in New Issue