Path: blob/main/core/dylink/test/wasi/dynamic-library.c
1393 views
#include <stdio.h>1#include <stdlib.h>2#include <string.h>3//#include <assert.h>4#include "app.h"56static int x = 388;7int y = 1;89EXPORTED_SYMBOL10PyObject* pynone_b() { return PyNone; }1112EXPORTED_SYMBOL13int add10(const int a) { return a + 10; }1415EXPORTED_SYMBOL16FUN_PTR pointer_to_add10() { return &add10; }1718EXPORTED_SYMBOL19int add389(const int a) { return a + x + y; }2021// This illustrates calling a function that is22// defined in the main app.c.23extern int add5077(int a);2425EXPORTED_SYMBOL26int add5077_using_func_from_main(int a) {27// This uses WASI!28printf("Print from dynamic-library! add5077_using_func_from_main a=%d\n", a);29void* mem = malloc(32);30printf("I got some memory here: %p\n", mem);31free(mem);32int n = add5077(a - strlen("four") + 4);33// doesn't work due to issue with __assert_fail not being defined:34// assert(n == a + 5077);35return n;36}3738