MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / pthread_attr_init

Function pthread_attr_init

crates/runtime/src/sim_std.rs:114–133  ·  view source on GitHub ↗
(attr: *mut libc::pthread_attr_t)

Source from the content-addressed store, hash-verified

112#[unsafe(no_mangle)]
113#[inline(never)]
114unsafe extern "C" fn pthread_attr_init(attr: *mut libc::pthread_attr_t) -> libc::c_int {
115 // std::thread enters libc through pthread_attr_init on Unix. Refusing that
116 // call while in simulation keeps hidden OS scheduling out of DST.
117 if in_simulation() {
118 eprintln!("attempt to spawn a system thread in simulation.");
119 eprintln!("note: use simulator tasks instead.");
120 return -1;
121 }
122
123 type PthreadAttrInit = unsafe extern "C" fn(*mut libc::pthread_attr_t) -> libc::c_int;
124 static PTHREAD_ATTR_INIT: OnceLock<PthreadAttrInit> = OnceLock::new();
125 let original = PTHREAD_ATTR_INIT.get_or_init(|| unsafe {
126 // `RTLD_NEXT` skips this interposed function and finds the libc
127 // implementation that would have been called without the simulator.
128 let ptr = libc::dlsym(libc::RTLD_NEXT, c"pthread_attr_init".as_ptr().cast());
129 assert!(!ptr.is_null(), "failed to resolve original pthread_attr_init");
130 std::mem::transmute(ptr)
131 });
132 unsafe { original(attr) }
133}
134
135// Randomness syscall hooks.
136

Callers

nothing calls this directly

Calls 3

in_simulationFunction · 0.85
castMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…