Browse Source

Fix link errors by using inlining

The release build (ex. for ctru-rs examples) was doing some extra
optimizations and throwing away the submodules of this crate after the
refactor split it into multiple files.

For some reason if the init call is behind another function call, it is
as if it doesn't exit. Luckily forcing inlining makes sure the module
doesn't get thrown away.

The `thread::attr` init call also needs to appear in the top level init,
otherwise you still get link errors.
pull/15/head
Mark Drobnak 3 years ago
parent
commit
f93ccc1a95
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 2
      src/lib.rs
  2. 6
      src/thread.rs

2
src/lib.rs

@ -15,11 +15,13 @@ mod thread_keys;
/// The call doesn't need to execute, just exist. /// The call doesn't need to execute, just exist.
/// ///
/// See https://github.com/rust-lang/rust/issues/47384 /// See https://github.com/rust-lang/rust/issues/47384
#[inline(always)]
pub fn init() { pub fn init() {
condvar::init(); condvar::init();
misc::init(); misc::init();
mutex::init(); mutex::init();
rwlock::init(); rwlock::init();
thread::init(); thread::init();
thread::attr::init();
thread_keys::init(); thread_keys::init();
} }

6
src/thread.rs

@ -6,11 +6,9 @@ use std::collections::BTreeMap;
use std::ptr; use std::ptr;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
mod attr; pub mod attr;
pub fn init() { pub fn init() {}
attr::init();
}
/// The main thread's pthread ID /// The main thread's pthread ID
const MAIN_THREAD_ID: libc::pthread_t = 0; const MAIN_THREAD_ID: libc::pthread_t = 0;

Loading…
Cancel
Save