test_hello.c 877 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "wasm_export.h"
  8. static int
  9. test_hello_wrapper(wasm_exec_env_t exec_env, const char *name, char *result,
  10. size_t resultlen)
  11. {
  12. return snprintf(result, resultlen, "Hello, %s. This is %s!\n", name,
  13. __func__);
  14. }
  15. /* clang-format off */
  16. #define REG_NATIVE_FUNC(func_name, signature) \
  17. { #func_name, func_name##_wrapper, signature, NULL }
  18. static NativeSymbol native_symbols[] = {
  19. REG_NATIVE_FUNC(test_hello, "($*~)i")
  20. };
  21. /* clang-format on */
  22. uint32_t
  23. get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols)
  24. {
  25. *p_module_name = "env";
  26. *p_native_symbols = native_symbols;
  27. return sizeof(native_symbols) / sizeof(NativeSymbol);
  28. }