wasmtime_c_api/
config.rs

1// Don't worry about unused imports if we're frobbing features, only worry about
2// them with the default set of features enabled.
3#![cfg_attr(not(feature = "cache"), allow(unused_imports))]
4
5use crate::{handle_result, wasm_memorytype_t, wasmtime_error_t};
6use std::os::raw::c_char;
7use std::ptr;
8use std::{ffi::CStr, sync::Arc};
9use wasmtime::{
10    Config, InstanceAllocationStrategy, LinearMemory, MemoryCreator, OptLevel, ProfilingStrategy,
11    Result, Strategy,
12};
13
14#[cfg(feature = "pooling-allocator")]
15use wasmtime::PoolingAllocationConfig;
16
17#[repr(C)]
18#[derive(Clone)]
19pub struct wasm_config_t {
20    pub(crate) config: Config,
21}
22
23wasmtime_c_api_macros::declare_own!(wasm_config_t);
24
25#[repr(u8)]
26#[derive(Clone)]
27pub enum wasmtime_strategy_t {
28    WASMTIME_STRATEGY_AUTO,
29    WASMTIME_STRATEGY_CRANELIFT,
30}
31
32#[repr(u8)]
33#[derive(Clone)]
34pub enum wasmtime_opt_level_t {
35    WASMTIME_OPT_LEVEL_NONE,
36    WASMTIME_OPT_LEVEL_SPEED,
37    WASMTIME_OPT_LEVEL_SPEED_AND_SIZE,
38}
39
40#[repr(u8)]
41#[derive(Clone)]
42pub enum wasmtime_profiling_strategy_t {
43    WASMTIME_PROFILING_STRATEGY_NONE,
44    WASMTIME_PROFILING_STRATEGY_JITDUMP,
45    WASMTIME_PROFILING_STRATEGY_VTUNE,
46    WASMTIME_PROFILING_STRATEGY_PERFMAP,
47}
48
49#[unsafe(no_mangle)]
50pub extern "C" fn wasm_config_new() -> Box<wasm_config_t> {
51    Box::new(wasm_config_t {
52        config: Config::default(),
53    })
54}
55
56#[unsafe(no_mangle)]
57pub extern "C" fn wasmtime_config_debug_info_set(c: &mut wasm_config_t, enable: bool) {
58    c.config.debug_info(enable);
59}
60
61#[unsafe(no_mangle)]
62pub extern "C" fn wasmtime_config_consume_fuel_set(c: &mut wasm_config_t, enable: bool) {
63    c.config.consume_fuel(enable);
64}
65
66#[unsafe(no_mangle)]
67pub extern "C" fn wasmtime_config_epoch_interruption_set(c: &mut wasm_config_t, enable: bool) {
68    c.config.epoch_interruption(enable);
69}
70
71#[unsafe(no_mangle)]
72pub extern "C" fn wasmtime_config_max_wasm_stack_set(c: &mut wasm_config_t, size: usize) {
73    c.config.max_wasm_stack(size);
74}
75
76#[unsafe(no_mangle)]
77#[cfg(feature = "threads")]
78pub extern "C" fn wasmtime_config_wasm_threads_set(c: &mut wasm_config_t, enable: bool) {
79    c.config.wasm_threads(enable);
80}
81
82#[unsafe(no_mangle)]
83pub extern "C" fn wasmtime_config_wasm_tail_call_set(c: &mut wasm_config_t, enable: bool) {
84    c.config.wasm_tail_call(enable);
85}
86
87#[unsafe(no_mangle)]
88pub extern "C" fn wasmtime_config_wasm_reference_types_set(c: &mut wasm_config_t, enable: bool) {
89    c.config.wasm_reference_types(enable);
90}
91
92#[unsafe(no_mangle)]
93pub extern "C" fn wasmtime_config_wasm_function_references_set(
94    c: &mut wasm_config_t,
95    enable: bool,
96) {
97    c.config.wasm_function_references(enable);
98}
99
100#[unsafe(no_mangle)]
101pub extern "C" fn wasmtime_config_wasm_gc_set(c: &mut wasm_config_t, enable: bool) {
102    c.config.wasm_gc(enable);
103}
104
105#[unsafe(no_mangle)]
106pub extern "C" fn wasmtime_config_wasm_simd_set(c: &mut wasm_config_t, enable: bool) {
107    c.config.wasm_simd(enable);
108}
109
110#[unsafe(no_mangle)]
111pub extern "C" fn wasmtime_config_wasm_relaxed_simd_set(c: &mut wasm_config_t, enable: bool) {
112    c.config.wasm_relaxed_simd(enable);
113}
114
115#[unsafe(no_mangle)]
116pub extern "C" fn wasmtime_config_wasm_relaxed_simd_deterministic_set(
117    c: &mut wasm_config_t,
118    enable: bool,
119) {
120    c.config.relaxed_simd_deterministic(enable);
121}
122
123#[unsafe(no_mangle)]
124pub extern "C" fn wasmtime_config_wasm_bulk_memory_set(c: &mut wasm_config_t, enable: bool) {
125    c.config.wasm_bulk_memory(enable);
126}
127
128#[unsafe(no_mangle)]
129pub extern "C" fn wasmtime_config_wasm_multi_value_set(c: &mut wasm_config_t, enable: bool) {
130    c.config.wasm_multi_value(enable);
131}
132
133#[unsafe(no_mangle)]
134pub extern "C" fn wasmtime_config_wasm_multi_memory_set(c: &mut wasm_config_t, enable: bool) {
135    c.config.wasm_multi_memory(enable);
136}
137
138#[unsafe(no_mangle)]
139pub extern "C" fn wasmtime_config_wasm_memory64_set(c: &mut wasm_config_t, enable: bool) {
140    c.config.wasm_memory64(enable);
141}
142
143#[unsafe(no_mangle)]
144#[cfg(any(feature = "cranelift", feature = "winch"))]
145pub extern "C" fn wasmtime_config_strategy_set(
146    c: &mut wasm_config_t,
147    strategy: wasmtime_strategy_t,
148) {
149    use wasmtime_strategy_t::*;
150    c.config.strategy(match strategy {
151        WASMTIME_STRATEGY_AUTO => Strategy::Auto,
152        WASMTIME_STRATEGY_CRANELIFT => Strategy::Cranelift,
153    });
154}
155
156#[unsafe(no_mangle)]
157#[cfg(feature = "parallel-compilation")]
158pub extern "C" fn wasmtime_config_parallel_compilation_set(c: &mut wasm_config_t, enable: bool) {
159    c.config.parallel_compilation(enable);
160}
161
162#[unsafe(no_mangle)]
163#[cfg(any(feature = "cranelift", feature = "winch"))]
164pub extern "C" fn wasmtime_config_cranelift_debug_verifier_set(
165    c: &mut wasm_config_t,
166    enable: bool,
167) {
168    c.config.cranelift_debug_verifier(enable);
169}
170
171#[unsafe(no_mangle)]
172#[cfg(any(feature = "cranelift", feature = "winch"))]
173pub extern "C" fn wasmtime_config_cranelift_nan_canonicalization_set(
174    c: &mut wasm_config_t,
175    enable: bool,
176) {
177    c.config.cranelift_nan_canonicalization(enable);
178}
179
180#[unsafe(no_mangle)]
181#[cfg(any(feature = "cranelift", feature = "winch"))]
182pub extern "C" fn wasmtime_config_cranelift_opt_level_set(
183    c: &mut wasm_config_t,
184    opt_level: wasmtime_opt_level_t,
185) {
186    use wasmtime_opt_level_t::*;
187    c.config.cranelift_opt_level(match opt_level {
188        WASMTIME_OPT_LEVEL_NONE => OptLevel::None,
189        WASMTIME_OPT_LEVEL_SPEED => OptLevel::Speed,
190        WASMTIME_OPT_LEVEL_SPEED_AND_SIZE => OptLevel::SpeedAndSize,
191    });
192}
193
194#[unsafe(no_mangle)]
195pub extern "C" fn wasmtime_config_profiler_set(
196    c: &mut wasm_config_t,
197    strategy: wasmtime_profiling_strategy_t,
198) {
199    use wasmtime_profiling_strategy_t::*;
200    c.config.profiler(match strategy {
201        WASMTIME_PROFILING_STRATEGY_NONE => ProfilingStrategy::None,
202        WASMTIME_PROFILING_STRATEGY_JITDUMP => ProfilingStrategy::JitDump,
203        WASMTIME_PROFILING_STRATEGY_VTUNE => ProfilingStrategy::VTune,
204        WASMTIME_PROFILING_STRATEGY_PERFMAP => ProfilingStrategy::PerfMap,
205    });
206}
207
208#[unsafe(no_mangle)]
209#[cfg(feature = "cache")]
210pub unsafe extern "C" fn wasmtime_config_cache_config_load(
211    c: &mut wasm_config_t,
212    filename: *const c_char,
213) -> Option<Box<wasmtime_error_t>> {
214    use std::path::Path;
215
216    use wasmtime::Cache;
217
218    handle_result(
219        if filename.is_null() {
220            Cache::from_file(None).map(|cache| c.config.cache(Some(cache)))
221        } else {
222            match CStr::from_ptr(filename).to_str() {
223                Ok(s) => {
224                    Cache::from_file(Some(&Path::new(s))).map(|cache| c.config.cache(Some(cache)))
225                }
226                Err(e) => Err(e.into()),
227            }
228        },
229        |_cfg| {},
230    )
231}
232
233#[unsafe(no_mangle)]
234pub extern "C" fn wasmtime_config_memory_may_move_set(c: &mut wasm_config_t, enable: bool) {
235    c.config.memory_may_move(enable);
236}
237
238#[unsafe(no_mangle)]
239pub extern "C" fn wasmtime_config_memory_reservation_set(c: &mut wasm_config_t, size: u64) {
240    c.config.memory_reservation(size);
241}
242
243#[unsafe(no_mangle)]
244pub extern "C" fn wasmtime_config_memory_guard_size_set(c: &mut wasm_config_t, size: u64) {
245    c.config.memory_guard_size(size);
246}
247
248#[unsafe(no_mangle)]
249pub extern "C" fn wasmtime_config_memory_reservation_for_growth_set(
250    c: &mut wasm_config_t,
251    size: u64,
252) {
253    c.config.memory_reservation_for_growth(size);
254}
255
256#[unsafe(no_mangle)]
257pub extern "C" fn wasmtime_config_native_unwind_info_set(c: &mut wasm_config_t, enabled: bool) {
258    c.config.native_unwind_info(enabled);
259}
260
261#[unsafe(no_mangle)]
262pub unsafe extern "C" fn wasmtime_config_target_set(
263    c: &mut wasm_config_t,
264    target: *const c_char,
265) -> Option<Box<wasmtime_error_t>> {
266    let target = CStr::from_ptr(target).to_str().expect("not valid utf-8");
267    handle_result(c.config.target(target), |_cfg| {})
268}
269
270#[unsafe(no_mangle)]
271pub extern "C" fn wasmtime_config_macos_use_mach_ports_set(c: &mut wasm_config_t, enabled: bool) {
272    c.config.macos_use_mach_ports(enabled);
273}
274
275#[unsafe(no_mangle)]
276#[cfg(any(feature = "cranelift", feature = "winch"))]
277pub unsafe extern "C" fn wasmtime_config_cranelift_flag_enable(
278    c: &mut wasm_config_t,
279    flag: *const c_char,
280) {
281    let flag = CStr::from_ptr(flag).to_str().expect("not valid utf-8");
282    c.config.cranelift_flag_enable(flag);
283}
284
285#[unsafe(no_mangle)]
286#[cfg(any(feature = "cranelift", feature = "winch"))]
287pub unsafe extern "C" fn wasmtime_config_cranelift_flag_set(
288    c: &mut wasm_config_t,
289    flag: *const c_char,
290    value: *const c_char,
291) {
292    let flag = CStr::from_ptr(flag).to_str().expect("not valid utf-8");
293    let value = CStr::from_ptr(value).to_str().expect("not valid utf-8");
294    c.config.cranelift_flag_set(flag, value);
295}
296
297pub type wasmtime_memory_get_callback_t = extern "C" fn(
298    env: *mut std::ffi::c_void,
299    byte_size: &mut usize,
300    maximum_byte_size: &mut usize,
301) -> *mut u8;
302
303pub type wasmtime_memory_grow_callback_t =
304    extern "C" fn(env: *mut std::ffi::c_void, new_size: usize) -> Option<Box<wasmtime_error_t>>;
305
306#[repr(C)]
307pub struct wasmtime_linear_memory_t {
308    env: *mut std::ffi::c_void,
309    get_memory: wasmtime_memory_get_callback_t,
310    grow_memory: wasmtime_memory_grow_callback_t,
311    finalizer: Option<extern "C" fn(arg1: *mut std::ffi::c_void)>,
312}
313
314pub type wasmtime_new_memory_callback_t = extern "C" fn(
315    env: *mut std::ffi::c_void,
316    ty: &wasm_memorytype_t,
317    minimum: usize,
318    maximum: usize,
319    reserved_size_in_bytes: usize,
320    guard_size_in_bytes: usize,
321    memory_ret: *mut wasmtime_linear_memory_t,
322) -> Option<Box<wasmtime_error_t>>;
323
324struct CHostLinearMemory {
325    foreign: crate::ForeignData,
326    get_memory: wasmtime_memory_get_callback_t,
327    grow_memory: wasmtime_memory_grow_callback_t,
328}
329
330unsafe impl LinearMemory for CHostLinearMemory {
331    fn byte_size(&self) -> usize {
332        let mut byte_size = 0;
333        let mut byte_capacity = 0;
334        let cb = self.get_memory;
335        cb(self.foreign.data, &mut byte_size, &mut byte_capacity);
336        return byte_size;
337    }
338    fn byte_capacity(&self) -> usize {
339        let mut byte_size = 0;
340        let mut byte_capacity = 0;
341        let cb = self.get_memory;
342        cb(self.foreign.data, &mut byte_size, &mut byte_capacity);
343        byte_capacity
344    }
345    fn as_ptr(&self) -> *mut u8 {
346        let mut byte_size = 0;
347        let mut byte_capacity = 0;
348        let cb = self.get_memory;
349        cb(self.foreign.data, &mut byte_size, &mut byte_capacity)
350    }
351    fn grow_to(&mut self, new_size: usize) -> Result<()> {
352        let cb = self.grow_memory;
353        let error = cb(self.foreign.data, new_size);
354        if let Some(err) = error {
355            Err((*err).into())
356        } else {
357            Ok(())
358        }
359    }
360}
361
362#[repr(C)]
363pub struct wasmtime_memory_creator_t {
364    env: *mut std::ffi::c_void,
365    new_memory: wasmtime_new_memory_callback_t,
366    finalizer: Option<extern "C" fn(arg1: *mut std::ffi::c_void)>,
367}
368
369struct CHostMemoryCreator {
370    foreign: crate::ForeignData,
371    new_memory: wasmtime_new_memory_callback_t,
372}
373unsafe impl Send for CHostMemoryCreator {}
374unsafe impl Sync for CHostMemoryCreator {}
375
376unsafe impl MemoryCreator for CHostMemoryCreator {
377    fn new_memory(
378        &self,
379        ty: wasmtime::MemoryType,
380        minimum: usize,
381        maximum: Option<usize>,
382        reserved_size_in_bytes: Option<usize>,
383        guard_size_in_bytes: usize,
384    ) -> Result<Box<dyn wasmtime::LinearMemory>, String> {
385        extern "C" fn panic_get_callback(
386            _env: *mut std::ffi::c_void,
387            _byte_size: &mut usize,
388            _maximum_byte_size: &mut usize,
389        ) -> *mut u8 {
390            panic!("a callback must be set");
391        }
392        extern "C" fn panic_grow_callback(
393            _env: *mut std::ffi::c_void,
394            _size: usize,
395        ) -> Option<Box<wasmtime_error_t>> {
396            panic!("a callback must be set");
397        }
398        let mut memory = wasmtime_linear_memory_t {
399            env: ptr::null_mut(),
400            get_memory: panic_get_callback,
401            grow_memory: panic_grow_callback,
402            finalizer: None,
403        };
404        let cb = self.new_memory;
405        let error = cb(
406            self.foreign.data,
407            &wasm_memorytype_t::new(ty),
408            minimum,
409            maximum.unwrap_or(usize::MAX),
410            reserved_size_in_bytes.unwrap_or(0),
411            guard_size_in_bytes,
412            &mut memory,
413        );
414        match error {
415            None => {
416                let foreign = crate::ForeignData {
417                    data: memory.env,
418                    finalizer: memory.finalizer,
419                };
420                Ok(Box::new(CHostLinearMemory {
421                    foreign,
422                    get_memory: memory.get_memory,
423                    grow_memory: memory.grow_memory,
424                }))
425            }
426            Some(err) => {
427                let err: anyhow::Error = (*err).into();
428                Err(format!("{err}"))
429            }
430        }
431    }
432}
433
434#[unsafe(no_mangle)]
435pub unsafe extern "C" fn wasmtime_config_host_memory_creator_set(
436    c: &mut wasm_config_t,
437    creator: &wasmtime_memory_creator_t,
438) {
439    c.config.with_host_memory(Arc::new(CHostMemoryCreator {
440        foreign: crate::ForeignData {
441            data: creator.env,
442            finalizer: creator.finalizer,
443        },
444        new_memory: creator.new_memory,
445    }));
446}
447
448#[unsafe(no_mangle)]
449pub extern "C" fn wasmtime_config_memory_init_cow_set(c: &mut wasm_config_t, enable: bool) {
450    c.config.memory_init_cow(enable);
451}
452
453#[unsafe(no_mangle)]
454pub extern "C" fn wasmtime_config_wasm_wide_arithmetic_set(c: &mut wasm_config_t, enable: bool) {
455    c.config.wasm_wide_arithmetic(enable);
456}
457
458#[repr(C)]
459#[derive(Clone)]
460#[cfg(feature = "pooling-allocator")]
461pub struct wasmtime_pooling_allocation_config_t {
462    pub(crate) config: PoolingAllocationConfig,
463}
464
465#[unsafe(no_mangle)]
466#[cfg(feature = "pooling-allocator")]
467pub extern "C" fn wasmtime_pooling_allocation_config_new()
468-> Box<wasmtime_pooling_allocation_config_t> {
469    Box::new(wasmtime_pooling_allocation_config_t {
470        config: PoolingAllocationConfig::default(),
471    })
472}
473
474#[unsafe(no_mangle)]
475#[cfg(feature = "pooling-allocator")]
476pub extern "C" fn wasmtime_pooling_allocation_config_delete(
477    _: Box<wasmtime_pooling_allocation_config_t>,
478) {
479}
480
481#[unsafe(no_mangle)]
482#[cfg(feature = "pooling-allocator")]
483pub extern "C" fn wasmtime_pooling_allocation_config_max_unused_warm_slots_set(
484    c: &mut wasmtime_pooling_allocation_config_t,
485    max: u32,
486) {
487    c.config.max_unused_warm_slots(max);
488}
489
490#[unsafe(no_mangle)]
491#[cfg(feature = "pooling-allocator")]
492pub extern "C" fn wasmtime_pooling_allocation_config_decommit_batch_size_set(
493    c: &mut wasmtime_pooling_allocation_config_t,
494    batch_size: usize,
495) {
496    c.config.decommit_batch_size(batch_size);
497}
498
499#[unsafe(no_mangle)]
500#[cfg(all(feature = "pooling-allocator", feature = "async"))]
501pub extern "C" fn wasmtime_pooling_allocation_config_async_stack_keep_resident_set(
502    c: &mut wasmtime_pooling_allocation_config_t,
503    size: usize,
504) {
505    c.config.async_stack_keep_resident(size);
506}
507
508#[unsafe(no_mangle)]
509#[cfg(feature = "pooling-allocator")]
510pub extern "C" fn wasmtime_pooling_allocation_config_linear_memory_keep_resident_set(
511    c: &mut wasmtime_pooling_allocation_config_t,
512    size: usize,
513) {
514    c.config.linear_memory_keep_resident(size);
515}
516
517#[unsafe(no_mangle)]
518#[cfg(feature = "pooling-allocator")]
519pub extern "C" fn wasmtime_pooling_allocation_config_table_keep_resident_set(
520    c: &mut wasmtime_pooling_allocation_config_t,
521    size: usize,
522) {
523    c.config.table_keep_resident(size);
524}
525
526#[unsafe(no_mangle)]
527#[cfg(feature = "pooling-allocator")]
528pub extern "C" fn wasmtime_pooling_allocation_config_total_component_instances_set(
529    c: &mut wasmtime_pooling_allocation_config_t,
530    count: u32,
531) {
532    c.config.total_component_instances(count);
533}
534
535#[unsafe(no_mangle)]
536#[cfg(feature = "pooling-allocator")]
537pub extern "C" fn wasmtime_pooling_allocation_config_max_component_instance_size_set(
538    c: &mut wasmtime_pooling_allocation_config_t,
539    size: usize,
540) {
541    c.config.max_component_instance_size(size);
542}
543
544#[unsafe(no_mangle)]
545#[cfg(feature = "pooling-allocator")]
546pub extern "C" fn wasmtime_pooling_allocation_config_max_core_instances_per_component_set(
547    c: &mut wasmtime_pooling_allocation_config_t,
548    count: u32,
549) {
550    c.config.max_core_instances_per_component(count);
551}
552
553#[unsafe(no_mangle)]
554#[cfg(feature = "pooling-allocator")]
555pub extern "C" fn wasmtime_pooling_allocation_config_max_memories_per_component_set(
556    c: &mut wasmtime_pooling_allocation_config_t,
557    count: u32,
558) {
559    c.config.max_memories_per_component(count);
560}
561
562#[unsafe(no_mangle)]
563#[cfg(feature = "pooling-allocator")]
564pub extern "C" fn wasmtime_pooling_allocation_config_max_tables_per_component_set(
565    c: &mut wasmtime_pooling_allocation_config_t,
566    count: u32,
567) {
568    c.config.max_tables_per_component(count);
569}
570
571#[unsafe(no_mangle)]
572#[cfg(feature = "pooling-allocator")]
573pub extern "C" fn wasmtime_pooling_allocation_config_total_memories_set(
574    c: &mut wasmtime_pooling_allocation_config_t,
575    count: u32,
576) {
577    c.config.total_memories(count);
578}
579
580#[unsafe(no_mangle)]
581#[cfg(feature = "pooling-allocator")]
582pub extern "C" fn wasmtime_pooling_allocation_config_total_tables_set(
583    c: &mut wasmtime_pooling_allocation_config_t,
584    count: u32,
585) {
586    c.config.total_tables(count);
587}
588
589#[unsafe(no_mangle)]
590#[cfg(all(feature = "pooling-allocator", feature = "async"))]
591pub extern "C" fn wasmtime_pooling_allocation_config_total_stacks_set(
592    c: &mut wasmtime_pooling_allocation_config_t,
593    count: u32,
594) {
595    c.config.total_stacks(count);
596}
597
598#[unsafe(no_mangle)]
599#[cfg(feature = "pooling-allocator")]
600pub extern "C" fn wasmtime_pooling_allocation_config_total_core_instances_set(
601    c: &mut wasmtime_pooling_allocation_config_t,
602    count: u32,
603) {
604    c.config.total_core_instances(count);
605}
606
607#[unsafe(no_mangle)]
608#[cfg(feature = "pooling-allocator")]
609pub extern "C" fn wasmtime_pooling_allocation_config_max_core_instance_size_set(
610    c: &mut wasmtime_pooling_allocation_config_t,
611    size: usize,
612) {
613    c.config.max_core_instance_size(size);
614}
615
616#[unsafe(no_mangle)]
617#[cfg(feature = "pooling-allocator")]
618pub extern "C" fn wasmtime_pooling_allocation_config_max_tables_per_module_set(
619    c: &mut wasmtime_pooling_allocation_config_t,
620    tables: u32,
621) {
622    c.config.max_tables_per_module(tables);
623}
624
625#[unsafe(no_mangle)]
626#[cfg(feature = "pooling-allocator")]
627pub extern "C" fn wasmtime_pooling_allocation_config_table_elements_set(
628    c: &mut wasmtime_pooling_allocation_config_t,
629    elements: usize,
630) {
631    c.config.table_elements(elements);
632}
633
634#[unsafe(no_mangle)]
635#[cfg(feature = "pooling-allocator")]
636pub extern "C" fn wasmtime_pooling_allocation_config_max_memories_per_module_set(
637    c: &mut wasmtime_pooling_allocation_config_t,
638    memories: u32,
639) {
640    c.config.max_memories_per_module(memories);
641}
642
643#[unsafe(no_mangle)]
644#[cfg(feature = "pooling-allocator")]
645pub extern "C" fn wasmtime_pooling_allocation_config_max_memory_size_set(
646    c: &mut wasmtime_pooling_allocation_config_t,
647    bytes: usize,
648) {
649    c.config.max_memory_size(bytes);
650}
651
652#[unsafe(no_mangle)]
653#[cfg(all(feature = "pooling-allocator", feature = "gc"))]
654pub extern "C" fn wasmtime_pooling_allocation_config_total_gc_heaps_set(
655    c: &mut wasmtime_pooling_allocation_config_t,
656    count: u32,
657) {
658    c.config.total_gc_heaps(count);
659}
660
661#[unsafe(no_mangle)]
662#[cfg(feature = "pooling-allocator")]
663pub extern "C" fn wasmtime_pooling_allocation_strategy_set(
664    c: &mut wasm_config_t,
665    pc: &wasmtime_pooling_allocation_config_t,
666) {
667    c.config
668        .allocation_strategy(InstanceAllocationStrategy::Pooling(pc.config.clone()));
669}