watt 0.4.2

Runtime for executing Rust procedural macros compiled as WebAssembly.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
#![allow(bad_style)]
#![deny(dead_code)]

use std::ffi::c_void;
use std::mem;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};

pub type wasm_name_t = wasm_byte_vec_t;
pub type wasm_valkind_t = u8;
pub type wasm_externkind_t = u8;
pub type wasm_message_t = wasm_name_t;
//pub type wasm_func_callback_t = Option<
//    unsafe extern "C" fn(args: *const wasm_val_t, results: *mut wasm_val_t) -> *mut wasm_trap_t,
//>;
pub type wasm_func_callback_with_env_t = Option<
    unsafe extern "C" fn(
        env: *mut c_void,
        args: *const wasm_val_vec_t,
        results: *mut wasm_val_vec_t,
    ) -> *mut wasm_trap_t,
>;
//pub type wasm_table_size_t = u32;
//pub type wasm_memory_pages_t = u32;
//pub type wasm_mutability_t = u8;
pub const WASM_I32: wasm_valkind_t = 0;
//pub const WASM_I64: wasm_valkind_t = 1;
//pub const WASM_F32: wasm_valkind_t = 2;
//pub const WASM_F64: wasm_valkind_t = 3;

pub const WASM_EXTERN_FUNC: wasm_externkind_t = 0;
//pub const WASM_EXTERN_GLOBAL: wasm_externkind_t = 1;
//pub const WASM_EXTERN_TABLE: wasm_externkind_t = 2;
pub const WASM_EXTERN_MEMORY: wasm_externkind_t = 3;

#[repr(C)]
pub struct wasm_byte_vec_t {
    pub size: usize,
    pub data: *mut u8,
}
#[repr(C)]
pub struct wasm_extern_vec_t {
    pub size: usize,
    pub data: *mut *mut wasm_extern_t,
}
#[repr(C)]
pub struct wasm_extern_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_memory_t {
    _unused: [u8; 0],
}
//#[repr(C)]
//pub struct wasm_table_t {
//    _unused: [u8; 0],
//}
//#[repr(C)]
//pub struct wasm_global_t {
//    _unused: [u8; 0],
//}
#[repr(C)]
pub struct wasm_func_t {
    _unused: [u8; 0],
}
//#[repr(C)]
//pub struct wasm_shared_module_t {
//    _unused: [u8; 0],
//}
#[repr(C)]
pub struct wasm_module_t {
    _unused: [u8; 0],
}
//#[repr(C)]
//pub struct wasm_foreign_t {
//    _unused: [u8; 0],
//}
#[repr(C)]
pub struct wasm_trap_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_instance_t {
    _unused: [u8; 0],
}
//#[repr(C)]
//pub struct wasm_frame_vec_t {
//    pub size: usize,
//    pub data: *mut *mut wasm_frame_t,
//}
//#[repr(C)]
//pub struct wasm_frame_t {
//    _unused: [u8; 0],
//}
#[repr(C)]
pub struct wasm_val_vec_t {
    pub size: usize,
    pub data: *mut wasm_val_t,
}
#[repr(C)]
pub struct wasm_val_t {
    pub kind: wasm_valkind_t,
    pub of: wasm_val_t_union,
}
#[repr(C)]
pub union wasm_val_t_union {
    pub i32: i32,
    pub i64: i64,
    pub f32: f32,
    pub f64: f64,
    pub ref_: *mut wasm_ref_t,
}
#[repr(C)]
pub struct wasm_ref_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_exporttype_vec_t {
    pub size: usize,
    pub data: *mut *mut wasm_exporttype_t,
}
#[repr(C)]
pub struct wasm_exporttype_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_importtype_vec_t {
    pub size: usize,
    pub data: *mut *mut wasm_importtype_t,
}
#[repr(C)]
pub struct wasm_importtype_t {
    _unused: [u8; 0],
}
//#[repr(C)]
//pub struct wasm_externtype_vec_t {
//    pub size: usize,
//    pub data: *mut *mut wasm_externtype_t,
//}
//#[repr(C)]
//pub struct wasm_externtype_t {
//    _unused: [u8; 0],
//}
//#[repr(C)]
//pub struct wasm_memorytype_vec_t {
//    pub size: usize,
//    pub data: *mut *mut wasm_memorytype_t,
//}
//#[repr(C)]
//pub struct wasm_memorytype_t {
//    _unused: [u8; 0],
//}
//#[repr(C)]
//pub struct wasm_tabletype_vec_t {
//    pub size: usize,
//    pub data: *mut *mut wasm_tabletype_t,
//}
//#[repr(C)]
//pub struct wasm_tabletype_t {
//    _unused: [u8; 0],
//}
//#[repr(C)]
//pub struct wasm_globaltype_vec_t {
//    pub size: usize,
//    pub data: *mut *mut wasm_globaltype_t,
//}
//#[repr(C)]
//pub struct wasm_globaltype_t {
//    _unused: [u8; 0],
//}
//#[repr(C)]
//pub struct wasm_functype_vec_t {
//    pub size: usize,
//    pub data: *mut *mut wasm_functype_t,
//}
#[repr(C)]
pub struct wasm_functype_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_valtype_vec_t {
    pub size: usize,
    pub data: *mut *mut wasm_valtype_t,
}
//#[repr(C)]
//pub struct wasm_limits_t {
//    pub min: u32,
//    pub max: u32,
//}

#[repr(C)]
pub struct wasm_valtype_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_store_t {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct wasm_engine_t {
    _unused: [u8; 0],
}
//#[repr(C)]
//pub struct wasm_config_t {
//    _unused: [u8; 0],
//}

fn resolve(ptr: &AtomicUsize, name: &str) -> usize {
    match ptr.load(SeqCst) {
        0 => {}
        n => return n,
    }
    let fnptr = dynamically_resolve(name);
    ptr.store(fnptr, SeqCst);
    fnptr
}

#[cfg(unix)]
fn dynamically_resolve(name: &str) -> usize {
    extern "C" {
        fn dlopen(filename: *const u8, flags: i32) -> *mut u8;
        fn dlsym(handle: *mut u8, sym: *const u8) -> *mut u8;
    }
    static HANDLE: AtomicUsize = AtomicUsize::new(0);
    unsafe {
        let handle = match HANDLE.load(SeqCst) {
            0 => {
                let path = concat!(env!("WATT_JIT"), "\0");
                let handle = dlopen(path.as_ptr(), 1);
                assert!(
                    !handle.is_null(),
                    "failed to dynamically open: {}",
                    env!("WATT_JIT")
                );
                HANDLE.store(handle as usize, SeqCst);
                handle
            }
            n => n as *mut u8,
        };
        let ret = dlsym(handle, name.as_ptr());
        assert!(!ret.is_null());
        ret as usize
    }
}

#[cfg(windows)]
fn dynamically_resolve(name: &str) -> usize {
    extern "system" {
        fn LoadLibraryA(name: *const u8) -> *mut u8;
        fn GetProcAddress(handle: *mut u8, sym: *const u8) -> *mut u8;
    }
    static HANDLE: AtomicUsize = AtomicUsize::new(0);
    unsafe {
        let handle = match HANDLE.load(SeqCst) {
            0 => {
                let path = concat!(env!("WATT_JIT"), "\0");
                let handle = LoadLibraryA(path.as_ptr());
                assert!(
                    !handle.is_null(),
                    "failed to dynamically open: {}",
                    env!("WATT_JIT")
                );
                HANDLE.store(handle as usize, SeqCst);
                handle
            }
            n => n as *mut u8,
        };
        let ret = GetProcAddress(handle, name.as_ptr());
        assert!(!ret.is_null());
        ret as usize
    }
}

macro_rules! extern_apis {
    ($(
        pub fn $name:ident($($arg:ident: $ty:ty),* $(,)?) $(-> $ret:ty)?;
    )*) => ($(
        pub unsafe extern "C" fn $name($($arg: $ty),*) $(-> $ret)? {
            static PTR: AtomicUsize = AtomicUsize::new(0);
            let _fnptr = resolve(&PTR, concat!(stringify!($name), "\0"));
            mem::transmute::<
                usize,
                unsafe extern "C" fn($($ty),*) $( -> $ret)?
            >(_fnptr)($($arg),*)
        }
    )*);
}

extern_apis! {
    //pub fn wasm_byte_vec_new_empty(out: *mut wasm_byte_vec_t);
    //pub fn wasm_byte_vec_new_uninitialized(out: *mut wasm_byte_vec_t, arg1: usize);
    //pub fn wasm_byte_vec_new(out: *mut wasm_byte_vec_t, arg1: usize, arg2: *const u8);
    //pub fn wasm_byte_vec_copy(out: *mut wasm_byte_vec_t, arg1: *mut wasm_byte_vec_t);
    pub fn wasm_byte_vec_delete(arg1: *mut wasm_byte_vec_t);
    //pub fn wasm_config_delete(arg1: *mut wasm_config_t);
    //pub fn wasm_config_new() -> *mut wasm_config_t;
    pub fn wasm_engine_delete(arg1: *mut wasm_engine_t);
    pub fn wasm_engine_new() -> *mut wasm_engine_t;
    //pub fn wasm_engine_new_with_config(arg1: *mut wasm_config_t) -> *mut wasm_engine_t;
    pub fn wasm_store_delete(arg1: *mut wasm_store_t);
    pub fn wasm_store_new(arg1: *mut wasm_engine_t) -> *mut wasm_store_t;
    pub fn wasm_valtype_delete(arg1: *mut wasm_valtype_t);
    //pub fn wasm_valtype_vec_new_empty(out: *mut wasm_valtype_vec_t);
    //pub fn wasm_valtype_vec_new_uninitialized(out: *mut wasm_valtype_vec_t, arg1: usize);
    pub fn wasm_valtype_vec_new(
        out: *mut wasm_valtype_vec_t,
        arg1: usize,
        arg2: *const *mut wasm_valtype_t,
    );
    //pub fn wasm_valtype_vec_copy(out: *mut wasm_valtype_vec_t, arg1: *mut wasm_valtype_vec_t);
    //pub fn wasm_valtype_vec_delete(arg1: *mut wasm_valtype_vec_t);
    //pub fn wasm_valtype_copy(arg1: *mut wasm_valtype_t) -> *mut wasm_valtype_t;
    pub fn wasm_valtype_new(arg1: wasm_valkind_t) -> *mut wasm_valtype_t;
    //pub fn wasm_valtype_kind(arg1: *const wasm_valtype_t) -> wasm_valkind_t;
    pub fn wasm_functype_delete(arg1: *mut wasm_functype_t);
    //pub fn wasm_functype_vec_new_empty(out: *mut wasm_functype_vec_t);
    //pub fn wasm_functype_vec_new_uninitialized(out: *mut wasm_functype_vec_t, arg1: usize);
    //pub fn wasm_functype_vec_new(
    //    out: *mut wasm_functype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_functype_t,
    //);
    //pub fn wasm_functype_vec_copy(out: *mut wasm_functype_vec_t, arg1: *mut wasm_functype_vec_t);
    //pub fn wasm_functype_vec_delete(arg1: *mut wasm_functype_vec_t);
    //pub fn wasm_functype_copy(arg1: *mut wasm_functype_t) -> *mut wasm_functype_t;
    pub fn wasm_functype_new(
        params: *mut wasm_valtype_vec_t,
        results: *mut wasm_valtype_vec_t,
    ) -> *mut wasm_functype_t;
    //pub fn wasm_functype_params(arg1: *const wasm_functype_t) -> *const wasm_valtype_vec_t;
    //pub fn wasm_functype_results(arg1: *const wasm_functype_t) -> *const wasm_valtype_vec_t;
    //pub fn wasm_globaltype_delete(arg1: *mut wasm_globaltype_t);
    //pub fn wasm_globaltype_vec_new_empty(out: *mut wasm_globaltype_vec_t);
    //pub fn wasm_globaltype_vec_new_uninitialized(out: *mut wasm_globaltype_vec_t, arg1: usize);
    //pub fn wasm_globaltype_vec_new(
    //    out: *mut wasm_globaltype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_globaltype_t,
    //);
    //pub fn wasm_globaltype_vec_copy(
    //    out: *mut wasm_globaltype_vec_t,
    //    arg1: *mut wasm_globaltype_vec_t,
    //);
    //pub fn wasm_globaltype_vec_delete(arg1: *mut wasm_globaltype_vec_t);
    //pub fn wasm_globaltype_copy(arg1: *mut wasm_globaltype_t) -> *mut wasm_globaltype_t;
    //pub fn wasm_globaltype_new(
    //    arg1: *mut wasm_valtype_t,
    //    arg2: wasm_mutability_t,
    //) -> *mut wasm_globaltype_t;
    //pub fn wasm_globaltype_content(arg1: *const wasm_globaltype_t) -> *const wasm_valtype_t;
    //pub fn wasm_globaltype_mutability(arg1: *const wasm_globaltype_t) -> wasm_mutability_t;
    //pub fn wasm_tabletype_delete(arg1: *mut wasm_tabletype_t);
    //pub fn wasm_tabletype_vec_new_empty(out: *mut wasm_tabletype_vec_t);
    //pub fn wasm_tabletype_vec_new_uninitialized(out: *mut wasm_tabletype_vec_t, arg1: usize);
    //pub fn wasm_tabletype_vec_new(
    //    out: *mut wasm_tabletype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_tabletype_t,
    //);
    //pub fn wasm_tabletype_vec_copy(out: *mut wasm_tabletype_vec_t, arg1: *mut wasm_tabletype_vec_t);
    //pub fn wasm_tabletype_vec_delete(arg1: *mut wasm_tabletype_vec_t);
    //pub fn wasm_tabletype_copy(arg1: *mut wasm_tabletype_t) -> *mut wasm_tabletype_t;
    //pub fn wasm_tabletype_new(
    //    arg1: *mut wasm_valtype_t,
    //    arg2: *const wasm_limits_t,
    //) -> *mut wasm_tabletype_t;
    //pub fn wasm_tabletype_element(arg1: *const wasm_tabletype_t) -> *const wasm_valtype_t;
    //pub fn wasm_tabletype_limits(arg1: *const wasm_tabletype_t) -> *const wasm_limits_t;
    //pub fn wasm_memorytype_delete(arg1: *mut wasm_memorytype_t);
    //pub fn wasm_memorytype_vec_new_empty(out: *mut wasm_memorytype_vec_t);
    //pub fn wasm_memorytype_vec_new_uninitialized(out: *mut wasm_memorytype_vec_t, arg1: usize);
    //pub fn wasm_memorytype_vec_new(
    //    out: *mut wasm_memorytype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_memorytype_t,
    //);
    //pub fn wasm_memorytype_vec_copy(
    //    out: *mut wasm_memorytype_vec_t,
    //    arg1: *mut wasm_memorytype_vec_t,
    //);
    //pub fn wasm_memorytype_vec_delete(arg1: *mut wasm_memorytype_vec_t);
    //pub fn wasm_memorytype_copy(arg1: *mut wasm_memorytype_t) -> *mut wasm_memorytype_t;
    //pub fn wasm_memorytype_new(arg1: *const wasm_limits_t) -> *mut wasm_memorytype_t;
    //pub fn wasm_memorytype_limits(arg1: *const wasm_memorytype_t) -> *const wasm_limits_t;
    //pub fn wasm_externtype_delete(arg1: *mut wasm_externtype_t);
    //pub fn wasm_externtype_vec_new_empty(out: *mut wasm_externtype_vec_t);
    //pub fn wasm_externtype_vec_new_uninitialized(out: *mut wasm_externtype_vec_t, arg1: usize);
    //pub fn wasm_externtype_vec_new(
    //    out: *mut wasm_externtype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_externtype_t,
    //);
    //pub fn wasm_externtype_vec_copy(
    //    out: *mut wasm_externtype_vec_t,
    //    arg1: *mut wasm_externtype_vec_t,
    //);
    //pub fn wasm_externtype_vec_delete(arg1: *mut wasm_externtype_vec_t);
    //pub fn wasm_externtype_copy(arg1: *mut wasm_externtype_t) -> *mut wasm_externtype_t;
    //pub fn wasm_externtype_kind(arg1: *const wasm_externtype_t) -> wasm_externkind_t;
    //pub fn wasm_functype_as_externtype(arg1: *mut wasm_functype_t) -> *mut wasm_externtype_t;
    //pub fn wasm_globaltype_as_externtype(arg1: *mut wasm_globaltype_t) -> *mut wasm_externtype_t;
    //pub fn wasm_tabletype_as_externtype(arg1: *mut wasm_tabletype_t) -> *mut wasm_externtype_t;
    //pub fn wasm_memorytype_as_externtype(arg1: *mut wasm_memorytype_t) -> *mut wasm_externtype_t;
    //pub fn wasm_externtype_as_functype(arg1: *mut wasm_externtype_t) -> *mut wasm_functype_t;
    //pub fn wasm_externtype_as_globaltype(arg1: *mut wasm_externtype_t) -> *mut wasm_globaltype_t;
    //pub fn wasm_externtype_as_tabletype(arg1: *mut wasm_externtype_t) -> *mut wasm_tabletype_t;
    //pub fn wasm_externtype_as_memorytype(arg1: *mut wasm_externtype_t) -> *mut wasm_memorytype_t;
    //pub fn wasm_functype_as_externtype_const(
    //    arg1: *const wasm_functype_t,
    //) -> *const wasm_externtype_t;
    //pub fn wasm_globaltype_as_externtype_const(
    //    arg1: *const wasm_globaltype_t,
    //) -> *const wasm_externtype_t;
    //pub fn wasm_tabletype_as_externtype_const(
    //    arg1: *const wasm_tabletype_t,
    //) -> *const wasm_externtype_t;
    //pub fn wasm_memorytype_as_externtype_const(
    //    arg1: *const wasm_memorytype_t,
    //) -> *const wasm_externtype_t;
    //pub fn wasm_externtype_as_functype_const(
    //    arg1: *const wasm_externtype_t,
    //) -> *const wasm_functype_t;
    //pub fn wasm_externtype_as_globaltype_const(
    //    arg1: *const wasm_externtype_t,
    //) -> *const wasm_globaltype_t;
    //pub fn wasm_externtype_as_tabletype_const(
    //    arg1: *const wasm_externtype_t,
    //) -> *const wasm_tabletype_t;
    //pub fn wasm_externtype_as_memorytype_const(
    //    arg1: *const wasm_externtype_t,
    //) -> *const wasm_memorytype_t;
    //pub fn wasm_importtype_delete(arg1: *mut wasm_importtype_t);
    //pub fn wasm_importtype_vec_new_empty(out: *mut wasm_importtype_vec_t);
    //pub fn wasm_importtype_vec_new_uninitialized(out: *mut wasm_importtype_vec_t, arg1: usize);
    //pub fn wasm_importtype_vec_new(
    //    out: *mut wasm_importtype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_importtype_t,
    //);
    //pub fn wasm_importtype_vec_copy(
    //    out: *mut wasm_importtype_vec_t,
    //    arg1: *mut wasm_importtype_vec_t,
    //);
    pub fn wasm_importtype_vec_delete(arg1: *mut wasm_importtype_vec_t);
    //pub fn wasm_importtype_copy(arg1: *mut wasm_importtype_t) -> *mut wasm_importtype_t;
    //pub fn wasm_importtype_new(
    //    module: *mut wasm_name_t,
    //    name: *mut wasm_name_t,
    //    arg1: *mut wasm_externtype_t,
    //) -> *mut wasm_importtype_t;
    pub fn wasm_importtype_module(arg1: *const wasm_importtype_t) -> *const wasm_name_t;
    pub fn wasm_importtype_name(arg1: *const wasm_importtype_t) -> *const wasm_name_t;
    //pub fn wasm_importtype_type(arg1: *const wasm_importtype_t) -> *const wasm_externtype_t;
    //pub fn wasm_exporttype_delete(arg1: *mut wasm_exporttype_t);
    //pub fn wasm_exporttype_vec_new_empty(out: *mut wasm_exporttype_vec_t);
    //pub fn wasm_exporttype_vec_new_uninitialized(out: *mut wasm_exporttype_vec_t, arg1: usize);
    //pub fn wasm_exporttype_vec_new(
    //    out: *mut wasm_exporttype_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_exporttype_t,
    //);
    //pub fn wasm_exporttype_vec_copy(
    //    out: *mut wasm_exporttype_vec_t,
    //    arg1: *mut wasm_exporttype_vec_t,
    //);
    pub fn wasm_exporttype_vec_delete(arg1: *mut wasm_exporttype_vec_t);
    //pub fn wasm_exporttype_copy(arg1: *mut wasm_exporttype_t) -> *mut wasm_exporttype_t;
    //pub fn wasm_exporttype_new(
    //    arg1: *mut wasm_name_t,
    //    arg2: *mut wasm_externtype_t,
    //) -> *mut wasm_exporttype_t;
    pub fn wasm_exporttype_name(arg1: *const wasm_exporttype_t) -> *const wasm_name_t;
    //pub fn wasm_exporttype_type(arg1: *const wasm_exporttype_t) -> *const wasm_externtype_t;
    //pub fn wasm_val_delete(v: *mut wasm_val_t);
    //pub fn wasm_val_copy(out: *mut wasm_val_t, arg1: *const wasm_val_t);
    //pub fn wasm_val_vec_new_empty(out: *mut wasm_val_vec_t);
    //pub fn wasm_val_vec_new_uninitialized(out: *mut wasm_val_vec_t, arg1: usize);
    //pub fn wasm_val_vec_new(out: *mut wasm_val_vec_t, arg1: usize, arg2: *const wasm_val_t);
    //pub fn wasm_val_vec_copy(out: *mut wasm_val_vec_t, arg1: *mut wasm_val_vec_t);
    //pub fn wasm_val_vec_delete(arg1: *mut wasm_val_vec_t);
    //pub fn wasm_ref_delete(arg1: *mut wasm_ref_t);
    //pub fn wasm_ref_copy(arg1: *const wasm_ref_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_same(arg1: *const wasm_ref_t, arg2: *const wasm_ref_t) -> bool;
    //pub fn wasm_ref_get_host_info(arg1: *const wasm_ref_t) -> *mut c_void;
    //pub fn wasm_ref_set_host_info(arg1: *mut wasm_ref_t, arg2: *mut c_void);
    //pub fn wasm_ref_set_host_info_with_finalizer(
    //    arg1: *mut wasm_ref_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_frame_delete(arg1: *mut wasm_frame_t);
    //pub fn wasm_frame_vec_new_empty(out: *mut wasm_frame_vec_t);
    //pub fn wasm_frame_vec_new_uninitialized(out: *mut wasm_frame_vec_t, arg1: usize);
    //pub fn wasm_frame_vec_new(
    //    out: *mut wasm_frame_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_frame_t,
    //);
    //pub fn wasm_frame_vec_copy(out: *mut wasm_frame_vec_t, arg1: *mut wasm_frame_vec_t);
    //pub fn wasm_frame_vec_delete(arg1: *mut wasm_frame_vec_t);
    //pub fn wasm_frame_copy(arg1: *const wasm_frame_t) -> *mut wasm_frame_t;
    //pub fn wasm_frame_instance(arg1: *const wasm_frame_t) -> *mut wasm_instance_t;
    //pub fn wasm_frame_func_index(arg1: *const wasm_frame_t) -> u32;
    //pub fn wasm_frame_func_offset(arg1: *const wasm_frame_t) -> usize;
    //pub fn wasm_frame_module_offset(arg1: *const wasm_frame_t) -> usize;
    pub fn wasm_trap_delete(arg1: *mut wasm_trap_t);
    //pub fn wasm_trap_copy(arg1: *const wasm_trap_t) -> *mut wasm_trap_t;
    //pub fn wasm_trap_same(arg1: *const wasm_trap_t, arg2: *const wasm_trap_t) -> bool;
    //pub fn wasm_trap_get_host_info(arg1: *const wasm_trap_t) -> *mut c_void;
    //pub fn wasm_trap_set_host_info(arg1: *mut wasm_trap_t, arg2: *mut c_void);
    //pub fn wasm_trap_set_host_info_with_finalizer(
    //    arg1: *mut wasm_trap_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_trap_as_ref(arg1: *mut wasm_trap_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_trap(arg1: *mut wasm_ref_t) -> *mut wasm_trap_t;
    //pub fn wasm_trap_as_ref_const(arg1: *const wasm_trap_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_trap_const(arg1: *const wasm_ref_t) -> *const wasm_trap_t;
    //pub fn wasm_trap_new(store: *mut wasm_store_t, arg1: *const wasm_message_t)
    //    -> *mut wasm_trap_t;
    pub fn wasm_trap_message(arg1: *const wasm_trap_t, out: *mut wasm_message_t);
    //pub fn wasm_trap_origin(arg1: *const wasm_trap_t) -> *mut wasm_frame_t;
    //pub fn wasm_trap_trace(arg1: *const wasm_trap_t, out: *mut wasm_frame_vec_t);
    //pub fn wasm_foreign_delete(arg1: *mut wasm_foreign_t);
    //pub fn wasm_foreign_copy(arg1: *const wasm_foreign_t) -> *mut wasm_foreign_t;
    //pub fn wasm_foreign_same(arg1: *const wasm_foreign_t, arg2: *const wasm_foreign_t) -> bool;
    //pub fn wasm_foreign_get_host_info(arg1: *const wasm_foreign_t) -> *mut c_void;
    //pub fn wasm_foreign_set_host_info(arg1: *mut wasm_foreign_t, arg2: *mut c_void);
    //pub fn wasm_foreign_set_host_info_with_finalizer(
    //    arg1: *mut wasm_foreign_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_foreign_as_ref(arg1: *mut wasm_foreign_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_foreign(arg1: *mut wasm_ref_t) -> *mut wasm_foreign_t;
    //pub fn wasm_foreign_as_ref_const(arg1: *const wasm_foreign_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_foreign_const(arg1: *const wasm_ref_t) -> *const wasm_foreign_t;
    //pub fn wasm_foreign_new(arg1: *mut wasm_store_t) -> *mut wasm_foreign_t;
    pub fn wasm_module_delete(arg1: *mut wasm_module_t);
    //pub fn wasm_module_copy(arg1: *const wasm_module_t) -> *mut wasm_module_t;
    //pub fn wasm_module_same(arg1: *const wasm_module_t, arg2: *const wasm_module_t) -> bool;
    //pub fn wasm_module_get_host_info(arg1: *const wasm_module_t) -> *mut c_void;
    //pub fn wasm_module_set_host_info(arg1: *mut wasm_module_t, arg2: *mut c_void);
    //pub fn wasm_module_set_host_info_with_finalizer(
    //    arg1: *mut wasm_module_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_module_as_ref(arg1: *mut wasm_module_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_module(arg1: *mut wasm_ref_t) -> *mut wasm_module_t;
    //pub fn wasm_module_as_ref_const(arg1: *const wasm_module_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_module_const(arg1: *const wasm_ref_t) -> *const wasm_module_t;
    //pub fn wasm_shared_module_delete(arg1: *mut wasm_shared_module_t);
    //pub fn wasm_module_share(arg1: *const wasm_module_t) -> *mut wasm_shared_module_t;
    //pub fn wasm_module_obtain(
    //    arg1: *mut wasm_store_t,
    //    arg2: *const wasm_shared_module_t,
    //) -> *mut wasm_module_t;
    pub fn wasm_module_new(
        arg1: *mut wasm_store_t,
        binary: *const wasm_byte_vec_t,
    ) -> *mut wasm_module_t;
    //pub fn wasm_module_validate(arg1: *mut wasm_store_t, binary: *const wasm_byte_vec_t) -> bool;
    pub fn wasm_module_imports(arg1: *const wasm_module_t, out: *mut wasm_importtype_vec_t);
    pub fn wasm_module_exports(arg1: *const wasm_module_t, out: *mut wasm_exporttype_vec_t);
    //pub fn wasm_module_serialize(arg1: *const wasm_module_t, out: *mut wasm_byte_vec_t);
    //pub fn wasm_module_deserialize(
    //    arg1: *mut wasm_store_t,
    //    arg2: *const wasm_byte_vec_t,
    //) -> *mut wasm_module_t;
    pub fn wasm_func_delete(arg1: *mut wasm_func_t);
    //pub fn wasm_func_copy(arg1: *const wasm_func_t) -> *mut wasm_func_t;
    //pub fn wasm_func_same(arg1: *const wasm_func_t, arg2: *const wasm_func_t) -> bool;
    //pub fn wasm_func_get_host_info(arg1: *const wasm_func_t) -> *mut c_void;
    //pub fn wasm_func_set_host_info(arg1: *mut wasm_func_t, arg2: *mut c_void);
    //pub fn wasm_func_set_host_info_with_finalizer(
    //    arg1: *mut wasm_func_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_func_as_ref(arg1: *mut wasm_func_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_func(arg1: *mut wasm_ref_t) -> *mut wasm_func_t;
    //pub fn wasm_func_as_ref_const(arg1: *const wasm_func_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_func_const(arg1: *const wasm_ref_t) -> *const wasm_func_t;
    //pub fn wasm_func_new(
    //    arg1: *mut wasm_store_t,
    //    arg2: *const wasm_functype_t,
    //    arg3: wasm_func_callback_t,
    //) -> *mut wasm_func_t;
    pub fn wasm_func_new_with_env(
        arg1: *mut wasm_store_t,
        type_: *const wasm_functype_t,
        arg2: wasm_func_callback_with_env_t,
        env: *mut c_void,
        finalizer: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    ) -> *mut wasm_func_t;
    //pub fn wasm_func_type(arg1: *const wasm_func_t) -> *mut wasm_functype_t;
    pub fn wasm_func_param_arity(arg1: *const wasm_func_t) -> usize;
    pub fn wasm_func_result_arity(arg1: *const wasm_func_t) -> usize;
    pub fn wasm_func_call(
        arg1: *const wasm_func_t,
        args: *const wasm_val_vec_t,
        results: *mut wasm_val_vec_t,
    ) -> *mut wasm_trap_t;
    //pub fn wasm_global_delete(arg1: *mut wasm_global_t);
    //pub fn wasm_global_copy(arg1: *const wasm_global_t) -> *mut wasm_global_t;
    //pub fn wasm_global_same(arg1: *const wasm_global_t, arg2: *const wasm_global_t) -> bool;
    //pub fn wasm_global_get_host_info(arg1: *const wasm_global_t) -> *mut c_void;
    //pub fn wasm_global_set_host_info(arg1: *mut wasm_global_t, arg2: *mut c_void);
    //pub fn wasm_global_set_host_info_with_finalizer(
    //    arg1: *mut wasm_global_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_global_as_ref(arg1: *mut wasm_global_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_global(arg1: *mut wasm_ref_t) -> *mut wasm_global_t;
    //pub fn wasm_global_as_ref_const(arg1: *const wasm_global_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_global_const(arg1: *const wasm_ref_t) -> *const wasm_global_t;
    //pub fn wasm_global_new(
    //    arg1: *mut wasm_store_t,
    //    arg2: *const wasm_globaltype_t,
    //    arg3: *const wasm_val_t,
    //) -> *mut wasm_global_t;
    //pub fn wasm_global_type(arg1: *const wasm_global_t) -> *mut wasm_globaltype_t;
    //pub fn wasm_global_get(arg1: *const wasm_global_t, out: *mut wasm_val_t);
    //pub fn wasm_global_set(arg1: *mut wasm_global_t, arg2: *const wasm_val_t);
    //pub fn wasm_table_delete(arg1: *mut wasm_table_t);
    //pub fn wasm_table_copy(arg1: *const wasm_table_t) -> *mut wasm_table_t;
    //pub fn wasm_table_same(arg1: *const wasm_table_t, arg2: *const wasm_table_t) -> bool;
    //pub fn wasm_table_get_host_info(arg1: *const wasm_table_t) -> *mut c_void;
    //pub fn wasm_table_set_host_info(arg1: *mut wasm_table_t, arg2: *mut c_void);
    //pub fn wasm_table_set_host_info_with_finalizer(
    //    arg1: *mut wasm_table_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_table_as_ref(arg1: *mut wasm_table_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_table(arg1: *mut wasm_ref_t) -> *mut wasm_table_t;
    //pub fn wasm_table_as_ref_const(arg1: *const wasm_table_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_table_const(arg1: *const wasm_ref_t) -> *const wasm_table_t;
    //pub fn wasm_table_new(
    //    arg1: *mut wasm_store_t,
    //    arg2: *const wasm_tabletype_t,
    //    init: *mut wasm_ref_t,
    //) -> *mut wasm_table_t;
    //pub fn wasm_table_type(arg1: *const wasm_table_t) -> *mut wasm_tabletype_t;
    //pub fn wasm_table_get(arg1: *const wasm_table_t, index: wasm_table_size_t) -> *mut wasm_ref_t;
    //pub fn wasm_table_set(
    //    arg1: *mut wasm_table_t,
    //    index: wasm_table_size_t,
    //    arg2: *mut wasm_ref_t,
    //) -> bool;
    //pub fn wasm_table_size(arg1: *const wasm_table_t) -> wasm_table_size_t;
    //pub fn wasm_table_grow(
    //    arg1: *mut wasm_table_t,
    //    delta: wasm_table_size_t,
    //    init: *mut wasm_ref_t,
    //) -> bool;
    //pub fn wasm_memory_delete(arg1: *mut wasm_memory_t);
    //pub fn wasm_memory_copy(arg1: *const wasm_memory_t) -> *mut wasm_memory_t;
    //pub fn wasm_memory_same(arg1: *const wasm_memory_t, arg2: *const wasm_memory_t) -> bool;
    //pub fn wasm_memory_get_host_info(arg1: *const wasm_memory_t) -> *mut c_void;
    //pub fn wasm_memory_set_host_info(arg1: *mut wasm_memory_t, arg2: *mut c_void);
    //pub fn wasm_memory_set_host_info_with_finalizer(
    //    arg1: *mut wasm_memory_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_memory_as_ref(arg1: *mut wasm_memory_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_memory(arg1: *mut wasm_ref_t) -> *mut wasm_memory_t;
    //pub fn wasm_memory_as_ref_const(arg1: *const wasm_memory_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_memory_const(arg1: *const wasm_ref_t) -> *const wasm_memory_t;
    //pub fn wasm_memory_new(
    //    arg1: *mut wasm_store_t,
    //    arg2: *const wasm_memorytype_t,
    //) -> *mut wasm_memory_t;
    //pub fn wasm_memory_type(arg1: *const wasm_memory_t) -> *mut wasm_memorytype_t;
    pub fn wasm_memory_data(arg1: *mut wasm_memory_t) -> *mut u8;
    pub fn wasm_memory_data_size(arg1: *const wasm_memory_t) -> usize;
    //pub fn wasm_memory_size(arg1: *const wasm_memory_t) -> wasm_memory_pages_t;
    //pub fn wasm_memory_grow(arg1: *mut wasm_memory_t, delta: wasm_memory_pages_t) -> bool;
    //pub fn wasm_extern_delete(arg1: *mut wasm_extern_t);
    //pub fn wasm_extern_copy(arg1: *const wasm_extern_t) -> *mut wasm_extern_t;
    //pub fn wasm_extern_same(arg1: *const wasm_extern_t, arg2: *const wasm_extern_t) -> bool;
    //pub fn wasm_extern_get_host_info(arg1: *const wasm_extern_t) -> *mut c_void;
    //pub fn wasm_extern_set_host_info(arg1: *mut wasm_extern_t, arg2: *mut c_void);
    //pub fn wasm_extern_set_host_info_with_finalizer(
    //    arg1: *mut wasm_extern_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_extern_as_ref(arg1: *mut wasm_extern_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_extern(arg1: *mut wasm_ref_t) -> *mut wasm_extern_t;
    //pub fn wasm_extern_as_ref_const(arg1: *const wasm_extern_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_extern_const(arg1: *const wasm_ref_t) -> *const wasm_extern_t;
    //pub fn wasm_extern_vec_new_empty(out: *mut wasm_extern_vec_t);
    //pub fn wasm_extern_vec_new_uninitialized(out: *mut wasm_extern_vec_t, arg1: usize);
    //pub fn wasm_extern_vec_new(
    //    out: *mut wasm_extern_vec_t,
    //    arg1: usize,
    //    arg2: *const *mut wasm_extern_t,
    //);
    //pub fn wasm_extern_vec_copy(out: *mut wasm_extern_vec_t, arg1: *mut wasm_extern_vec_t);
    pub fn wasm_extern_vec_delete(arg1: *mut wasm_extern_vec_t);
    pub fn wasm_extern_kind(arg1: *const wasm_extern_t) -> wasm_externkind_t;
    //pub fn wasm_extern_type(arg1: *const wasm_extern_t) -> *mut wasm_externtype_t;
    pub fn wasm_func_as_extern(arg1: *mut wasm_func_t) -> *mut wasm_extern_t;
    //pub fn wasm_global_as_extern(arg1: *mut wasm_global_t) -> *mut wasm_extern_t;
    //pub fn wasm_table_as_extern(arg1: *mut wasm_table_t) -> *mut wasm_extern_t;
    //pub fn wasm_memory_as_extern(arg1: *mut wasm_memory_t) -> *mut wasm_extern_t;
    pub fn wasm_extern_as_func(arg1: *mut wasm_extern_t) -> *mut wasm_func_t;
    //pub fn wasm_extern_as_global(arg1: *mut wasm_extern_t) -> *mut wasm_global_t;
    //pub fn wasm_extern_as_table(arg1: *mut wasm_extern_t) -> *mut wasm_table_t;
    pub fn wasm_extern_as_memory(arg1: *mut wasm_extern_t) -> *mut wasm_memory_t;
    //pub fn wasm_func_as_extern_const(arg1: *const wasm_func_t) -> *const wasm_extern_t;
    //pub fn wasm_global_as_extern_const(arg1: *const wasm_global_t) -> *const wasm_extern_t;
    //pub fn wasm_table_as_extern_const(arg1: *const wasm_table_t) -> *const wasm_extern_t;
    //pub fn wasm_memory_as_extern_const(arg1: *const wasm_memory_t) -> *const wasm_extern_t;
    //pub fn wasm_extern_as_func_const(arg1: *const wasm_extern_t) -> *const wasm_func_t;
    //pub fn wasm_extern_as_global_const(arg1: *const wasm_extern_t) -> *const wasm_global_t;
    //pub fn wasm_extern_as_table_const(arg1: *const wasm_extern_t) -> *const wasm_table_t;
    //pub fn wasm_extern_as_memory_const(arg1: *const wasm_extern_t) -> *const wasm_memory_t;
    pub fn wasm_instance_delete(arg1: *mut wasm_instance_t);
    //pub fn wasm_instance_copy(arg1: *const wasm_instance_t) -> *mut wasm_instance_t;
    //pub fn wasm_instance_same(arg1: *const wasm_instance_t, arg2: *const wasm_instance_t) -> bool;
    //pub fn wasm_instance_get_host_info(arg1: *const wasm_instance_t) -> *mut c_void;
    //pub fn wasm_instance_set_host_info(arg1: *mut wasm_instance_t, arg2: *mut c_void);
    //pub fn wasm_instance_set_host_info_with_finalizer(
    //    arg1: *mut wasm_instance_t,
    //    arg2: *mut c_void,
    //    arg3: Option<unsafe extern "C" fn(arg1: *mut c_void)>,
    //);
    //pub fn wasm_instance_as_ref(arg1: *mut wasm_instance_t) -> *mut wasm_ref_t;
    //pub fn wasm_ref_as_instance(arg1: *mut wasm_ref_t) -> *mut wasm_instance_t;
    //pub fn wasm_instance_as_ref_const(arg1: *const wasm_instance_t) -> *const wasm_ref_t;
    //pub fn wasm_ref_as_instance_const(arg1: *const wasm_ref_t) -> *const wasm_instance_t;
    pub fn wasm_instance_new(
        arg1: *mut wasm_store_t,
        arg2: *const wasm_module_t,
        imports: *const wasm_extern_vec_t,
        arg3: *mut *mut wasm_trap_t,
    ) -> *mut wasm_instance_t;
    pub fn wasm_instance_exports(arg1: *const wasm_instance_t, out: *mut wasm_extern_vec_t);
}