Compare commits

..

1 Commits

Author SHA1 Message Date
xenua 6e02c67a9f
fork: update refs 8 months ago
  1. 9
      Cargo.toml
  2. 4
      src/thread.rs
  3. 18
      src/thread_keys.rs

9
Cargo.toml

@ -1,12 +1,15 @@ @@ -1,12 +1,15 @@
[package]
name = "pthread-3ds"
authors = [ "Rust3DS Org", "Andrea Ciliberti <meziu210@icloud.com>" ]
authors = ["Rust3DS Org", "Andrea Ciliberti <meziu210@icloud.com>"]
version = "0.1.0"
license = "MIT OR Apache-2.0"
edition = "2021"
[dependencies]
libc = "0.2.116"
ctru-sys = { git = "https://github.com/rust3ds/ctru-rs.git" }
spin = { version = "0.9", default-features = false, features = ["rwlock", "std"] }
ctru-sys = { git = "https://git.xenua.me/rust3ds/ctru-rs.git" }
spin = { version = "0.9", default-features = false, features = [
"rwlock",
"std",
] }
static_assertions = "1.0"

4
src/thread.rs

@ -6,8 +6,6 @@ use std::collections::BTreeMap; @@ -6,8 +6,6 @@ use std::collections::BTreeMap;
use std::ptr;
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::thread_keys;
pub mod attr;
/// The main thread's pthread ID
@ -89,8 +87,6 @@ pub unsafe extern "C" fn pthread_create( @@ -89,8 +87,6 @@ pub unsafe extern "C" fn pthread_create(
pthread.is_finished = true;
pthread.result.0 = result;
thread_keys::run_local_destructors();
if pthread.is_detached {
// libctru will call threadFree once this thread dies
thread_map.remove(&thread_id);

18
src/thread_keys.rs

@ -19,24 +19,6 @@ fn is_valid_key(key: Key) -> bool { @@ -19,24 +19,6 @@ fn is_valid_key(key: Key) -> bool {
KEYS.read().contains_key(&(key as Key))
}
pub(crate) fn run_local_destructors() {
unsafe {
// We iterate all the thread-local keys set.
//
// When using `std` and the `thread_local!` macro there should be only one key registered here,
// which is the list of keys to destroy.
for (key, value) in LOCALS.iter() {
// We retrieve the destructor for a key from the static list.
if let Some(destructor) = KEYS.read().get(&key) {
// If the destructor is registered for a key, run it.
if let Some(d) = destructor {
d(*value);
}
}
}
};
}
#[no_mangle]
pub unsafe extern "C" fn pthread_key_create(
key: *mut libc::pthread_key_t,

Loading…
Cancel
Save