test_add.c 731 B

1234567891011121314151617181920212223242526272829303132
  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_add_wrapper(wasm_exec_env_t exec_env, int x, int y)
  10. {
  11. return x + y;
  12. }
  13. /* clang-format off */
  14. #define REG_NATIVE_FUNC(func_name, signature) \
  15. { #func_name, func_name##_wrapper, signature, NULL }
  16. static NativeSymbol native_symbols[] = {
  17. REG_NATIVE_FUNC(test_add, "(ii)i")
  18. };
  19. /* clang-format on */
  20. uint32_t
  21. get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols)
  22. {
  23. *p_module_name = "env";
  24. *p_native_symbols = native_symbols;
  25. return sizeof(native_symbols) / sizeof(NativeSymbol);
  26. }