Skip to content

Commit d6dbcd2

Browse files
authored
Expose signals_based_traps config option to C API (#11879)
1 parent 6b156f2 commit d6dbcd2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

crates/c-api/include/wasmtime/config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,19 @@ WASM_API_EXTERN void wasmtime_config_cranelift_flag_set(wasm_config_t *,
451451
*/
452452
WASMTIME_CONFIG_PROP(void, macos_use_mach_ports, bool)
453453

454+
/**
455+
* \brief Configures Wasmtime to not use signals-based trap handlers, for
456+
* example disables `SIGILL` and `SIGSEGV` handler registration on Unix
457+
* platforms.
458+
*
459+
* This option defaults to `true`: signals-based trap handlers are enabled
460+
* by default.
461+
*
462+
* For more information see the Rust documentation at
463+
* https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.signals_based_traps
464+
*/
465+
WASMTIME_CONFIG_PROP(void, signals_based_traps, bool)
466+
454467
/**
455468
* Return the data from a LinearMemory instance.
456469
*

crates/c-api/include/wasmtime/config.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,12 @@ public:
523523
wasmtime_config_macos_use_mach_ports_set(ptr.get(), enable);
524524
}
525525

526+
/// \brief Configures Wasmtime to not use signals-based trap handlers
527+
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.signals_based_traps
528+
void signals_based_traps(bool enable) {
529+
wasmtime_config_signals_based_traps_set(ptr.get(), enable);
530+
}
531+
526532
#ifdef WASMTIME_FEATURE_CACHE
527533
/// \brief Loads the default cache configuration present on the system.
528534
///

crates/c-api/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ pub extern "C" fn wasmtime_config_macos_use_mach_ports_set(c: &mut wasm_config_t
277277
c.config.macos_use_mach_ports(enabled);
278278
}
279279

280+
#[unsafe(no_mangle)]
281+
pub extern "C" fn wasmtime_config_signals_based_traps_set(c: &mut wasm_config_t, enable: bool) {
282+
c.config.signals_based_traps(enable);
283+
}
284+
280285
#[unsafe(no_mangle)]
281286
#[cfg(any(feature = "cranelift", feature = "winch"))]
282287
pub unsafe extern "C" fn wasmtime_config_cranelift_flag_enable(

0 commit comments

Comments
 (0)