From 756a0d2edc01ab0ec369757f35ef2a1891ea3ef9 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Sun, 9 Dec 2018 19:59:33 -0700 Subject: [PATCH] Initialize pthreads if it is linked --- src/start.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/start.rs b/src/start.rs index 5c5115e6..5489bfad 100644 --- a/src/start.rs +++ b/src/start.rs @@ -44,6 +44,13 @@ unsafe fn copy_string_array(array: *const *const c_char, len: usize) -> Vec<*mut vec } +// In the case that pthread is not linked, pthread_init can be replaced +#[linkage = "weak"] +#[no_mangle] +extern "C" fn pthread_init() -> c_int { + 0 +} + #[inline(never)] #[no_mangle] pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! { @@ -53,6 +60,7 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! { static __init_array_start: extern "C" fn(); static __init_array_end: extern "C" fn(); + fn pthread_init() -> c_int; fn _init(); fn main(argc: isize, argv: *mut *mut c_char, envp: *mut *mut c_char) -> c_int; } @@ -77,6 +85,9 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! { stdio::stdout = stdio::default_stdout.get(); stdio::stderr = stdio::default_stderr.get(); + // Initialize pthreads + pthread_init(); + // Call init section _init(); -- GitLab