mirror of
https://github.com/fluencelabs/c-template
synced 2025-04-24 14:22:12 +00:00
add syscall_stubs file
This commit is contained in:
parent
2edc942401
commit
460d09a911
5
Makefile
5
Makefile
@ -5,14 +5,15 @@ TARGET_TRIPLE = wasm32-unknown-wasi
|
||||
CFLAGS = -nostartfiles -fvisibility=hidden
|
||||
LDFLAGS = -Wl,--no-entry,--demangle,--allow-undefined
|
||||
EXPORT_FUNCS = --export=allocate,--export=deallocate,--export=invoke
|
||||
SDK = sdk/allocator.c sdk/logger.c
|
||||
SDK = sdk/allocator.c sdk/logger.c sdk/syscalls_stubs.c
|
||||
SRC = src/main.c
|
||||
|
||||
.PHONY: default all clean
|
||||
|
||||
default: $(TARGET)
|
||||
all: default
|
||||
|
||||
$(TARGET): main.c $(SDK)
|
||||
$(TARGET): $(SRC) $(SDK)
|
||||
$(CC) --sysroot=$(SYSROOT) --target=$(TARGET_TRIPLE) $(CFLAGS) $(LDFLAGS) -Wl,$(EXPORT_FUNCS) $^ -o $@.wasm
|
||||
|
||||
.PRECIOUS: $(TARGET)
|
||||
|
7
main.c
7
main.c
@ -1,7 +0,0 @@
|
||||
#include "sdk/allocator.h"
|
||||
#include "sdk/logger.h"
|
||||
#include "sdk/side_module_api.h"
|
||||
|
||||
char *invoke(const char *str, int length) {
|
||||
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
#define C_TEMPLATE_SIDE_MODULE_API_H
|
||||
|
||||
#include <string.h>
|
||||
#include <sttlib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Concatenate preprocessor tokens A and B without expanding macro definitions
|
||||
|
14
sdk/syscalls_stubs.c
Normal file
14
sdk/syscalls_stubs.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __stdio_close(FILE *f) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
off_t __stdio_seek(FILE *_f, off_t _offset, int _value) {
|
||||
return 1;
|
||||
}
|
||||
|
7
src/main.c
Normal file
7
src/main.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include "../sdk/allocator.h"
|
||||
#include "../sdk/logger.h"
|
||||
#include "../sdk/side_module_api.h"
|
||||
|
||||
char *invoke(const char *str, int length) {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user