/// A shim to wrap thread entry points in logic to set up TLS, for example
A shim to wrap thread entry points in logic to set up TLS, for example
A shim to wrap thread entry points in logic to set up TLS for example
unsafe extern "C" fn pte_osThreadShim(
    entryPoint: pte_osThreadEntryPoint,
    argv: *mut c_void,
    mutex: pte_osMutexHandle,
    tls_size: usize,
    tls_masters_ptr: *mut Master,
    tls_masters_len: usize,
    tls_linker_ptr: *const Mutex<Linker>,
    tls_mspace: usize,
) {
    // The kernel allocated TLS does not have masters set, so do not attempt to copy it.
    // It will be copied by the kernel.
    if !tls_masters_ptr.is_null() {
        let tcb = Tcb::new(tls_size).unwrap();
        tcb.masters_ptr = tls_masters_ptr;
        tcb.masters_len = tls_masters_len;
        tcb.linker_ptr = tls_linker_ptr;
        tcb.mspace = tls_mspace;
        tcb.copy_masters().unwrap();
        tcb.activate();
    }
    // Wait until pte_osThreadStart
    pte_osMutexLock(mutex);
    entryPoint(argv);
    pte_osThreadExit();
}
unsafe extern " " fn pte_osThreadShim ( entryPoint : pte_osThreadEntryPoint , argv : * mut c_void , mutex : pte_osMutexHandle , tls_size : usize , tls_masters_ptr : * mut Master , tls_masters_len : usize , tls_linker_ptr : * const Mutex < Linker > , tls_mspace : usize , ) { // The kernel allocated TLS does not have masters set, so do not attempt to copy it. // It will be copied by the kernel. if ! tls_masters_ptr . is_null ( ) { let tcb = Tcb :: new ( tls_size ) . unwrap ( ) ; tcb . masters_ptr = tls_masters_ptr ; tcb . masters_len = tls_masters_len ; tcb . linker_ptr = tls_linker_ptr ; tcb . mspace = tls_mspace ; tcb . copy_masters ( ) . unwrap ( ) ; tcb . activate ( ) ; } // Wait until pte_osThreadStart pte_osMutexLock ( mutex ) ; entryPoint ( argv ) ; pte_osThreadExit ( ) ; }
A shim to wrap thread entry points in logic to set up TLS, for example
A shim to wrap thread entry points in logic to set up TLS for example
entryPoint
pte_osThreadEntryPoint
argv
*mut c_void
mutex
pte_osMutexHandle
tls_size
usize
tls_masters_ptr
*mut Master
tls_masters_len
usize
tls_linker_ptr
*const Mutex<Linker>
tls_mspace
usize