mirror of
https://github.com/fluencelabs/redis
synced 2025-04-25 10:32:14 +00:00
update to the sdk 0.6.0 version
This commit is contained in:
parent
0f66c1dd62
commit
2c2f486044
2
Makefile
2
Makefile
@ -7,7 +7,7 @@ default: all
|
||||
|
||||
wasm:
|
||||
cd src && $(MAKE) -f Makefile_wasm && mv redis.wasm ../
|
||||
~/.cargo/bin/fce embed -i redis.wasm -o redis.wasm -w redis.wit
|
||||
#~/.cargo/bin/fce embed -i redis.wasm -o redis.wasm -w redis.wit
|
||||
|
||||
install:
|
||||
cd src && $(MAKE) $@
|
||||
|
@ -1,4 +1,5 @@
|
||||
;; Fluence Redis fork Wasm Interface Types
|
||||
(@interface it_version "0.19.0")
|
||||
|
||||
;; allocate
|
||||
(@interface type (func (param $size: i32) (result i32))) ;; 0
|
||||
@ -16,7 +17,7 @@
|
||||
(@interface type (func (param $result: i32))) ;; 4
|
||||
|
||||
(@interface export "allocate" (func 0)) ;; 0
|
||||
(@interface export "deallocate" (func 1)) ;; 1
|
||||
(@interface export "release_objects" (func 1)) ;; 1
|
||||
(@interface export "invoke" (func 2)) ;; 2
|
||||
(@interface export "get_result_size" (func 3)) ;; 3
|
||||
(@interface export "get_result_ptr" (func 3)) ;; 4
|
||||
@ -34,9 +35,7 @@
|
||||
call-core 4 ;; call get_result_size
|
||||
call-core 3 ;; call get_result_ptr
|
||||
string.lift_memory
|
||||
call-core 4 ;; call get_result_size
|
||||
call-core 3 ;; call get_result_ptr
|
||||
call-core 1 ;; call deallocate
|
||||
call-core 1 ;; call release_objects
|
||||
)
|
||||
|
||||
;; Implementations
|
||||
|
@ -10,7 +10,7 @@ SDK = sdk/syscalls_stubs.c
|
||||
|
||||
EXPORT_FUNCS = \
|
||||
--export=allocate,$\
|
||||
--export=deallocate,$\
|
||||
--export=release_objects,$\
|
||||
--export=set_result_size,$\
|
||||
--export=set_result_ptr,$\
|
||||
--export=get_result_size,$\
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
client *g_client;
|
||||
char *RESULT_PTR;
|
||||
void *RESULT_PTR;
|
||||
int RESULT_SIZE;
|
||||
|
||||
// TODO: add handling of the initialization process errors
|
||||
@ -27,8 +27,14 @@ void deallocate(void *ptr, int size) {
|
||||
zfree(ptr);
|
||||
}
|
||||
|
||||
void set_result_ptr(char *ptr) {
|
||||
*RESULT_PTR = ptr;
|
||||
void release_objects() {
|
||||
deallocate(RESULT_PTR, RESULT_SIZE);
|
||||
RESULT_PTR = 0;
|
||||
RESULT_SIZE = 0;
|
||||
}
|
||||
|
||||
void set_result_ptr(void *ptr) {
|
||||
RESULT_PTR = ptr;
|
||||
}
|
||||
|
||||
void set_result_size(int size) {
|
||||
@ -39,14 +45,10 @@ int get_result_size(void) {
|
||||
return RESULT_SIZE;
|
||||
}
|
||||
|
||||
char *get_result_ptr() {
|
||||
void *get_result_ptr() {
|
||||
return RESULT_PTR;
|
||||
}
|
||||
|
||||
unsigned char load(const unsigned char *ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
// Cleans client output buffers to - client is blocked and
|
||||
// doesn't receive requests until output buffer isn't empty.
|
||||
void clean_client_buffer(client *c) {
|
||||
@ -117,7 +119,7 @@ void invoke(char *request, int request_size) {
|
||||
} else {
|
||||
readQueryFromClient(g_client, 0, request, request_size);
|
||||
}
|
||||
deallocate(request, 0);
|
||||
deallocate(request, request_size);
|
||||
serverLog(LL_DEBUG, "readQueryFromClient\n");
|
||||
|
||||
const size_t reply_bytes_before = g_client->reply_bytes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user