Guest User

Untitled

a guest
May 5th, 2023
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <wasm.h>
  4. #include <wasmtime.h>
  5.  
  6. #if INF_DEBUG_PROBE_STANDALONE
  7. void Logf(const char *format, ...);
  8. #else
  9. #define Logf printf
  10. #endif
  11.  
  12.  
  13. int main()
  14. {
  15.   wasm_config_t* wasm_config = wasm_config_new();
  16.   wasmtime_config_debug_info_set(wasm_config, true);
  17.   wasm_engine_t *engine = wasm_engine_new_with_config(wasm_config);
  18.  
  19.   Logf("wasm_functype_new_1_1[before].\n");
  20.   wasm_valtype_t* val_i32 =  wasm_valtype_new(WASM_I32);
  21.   wasm_functype_t *__ft_i32_out_i32  = wasm_functype_new_1_1(val_i32, val_i32);
  22.   Logf("wasm_functype_new_1_1[after].\n");
  23.  
  24.   return 0;
  25. }
  26.  
  27.  
  28. #if INF_DEBUG_PROBE_STANDALONE
  29. #ifdef INF_DEBUG
  30. #pragma comment(lib, "..\\..\\..\\..\\target\\debug\\wasmtime.dll.lib")
  31. #else
  32. #pragma comment(lib, "..\\..\\..\\..\\target\\release\\wasmtime.dll.lib")
  33. #endif
  34. #include <windows.h>
  35. int  WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
  36. {
  37.    main();
  38.    return 0;
  39. }
  40. #endif
  41.  
  42.  
  43. #if INF_DEBUG_PROBE_STANDALONE
  44. #include <windows.h>
  45. #include <stdio.h>
  46.  
  47. void Logf(const char *format, ...)
  48. {
  49.    va_list arg_list;
  50.    va_start(arg_list, format);
  51.  
  52.    // Do the format once to get the length.
  53. #if defined _WIN32 || defined _WIN64 /// COMPILER(MSVC)
  54.     int len = _vscprintf(format, arg_list);
  55. #else
  56.     char ch;
  57.     int len = vsnprintf(&ch, 1, format, arg_list);
  58.  
  59.     // We need to call va_end() and then va_start() again here, as the
  60.     // contents of args is undefined after the call to vsnprintf
  61.     // according to http://man.cx/snprintf(3)
  62.  
  63.     // Not calling va_end/va_start here happens to work on lots of systems, but fails on some systems e.g. 64 bit Linux.
  64.     va_end(arg_list);
  65.     va_start(arg_list, format);
  66. #endif
  67.  
  68.    // Ensure we have enough room.
  69.    char *tmp = malloc(len+1);
  70.  
  71.     vsprintf(tmp, format, arg_list);
  72.  
  73.     va_end(arg_list);
  74.  
  75.    MessageBoxA(NULL, tmp, "repro", MB_OK);
  76.    free(tmp);
  77. }
  78. #endif
Advertisement
Add Comment
Please, Sign In to add comment