GitHub PullRequestReviewCommentEvent at 2014-02-26 02:18:13
Repository: rust
Actor: bharrisau
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla/rust/pulls/comments/10066081","id":10066081,"diff_hunk":"@@ -261,51 +261,39 @@ mod imp {\n     #[cfg(not(target_os = \"macos\"), not(target_os = \"android\"))]\n     pub unsafe fn yield_now() { assert_eq!(pthread_yield(), 0); }\n \n-    #[cfg(not(target_os = \"linux\"))]\n-    unsafe fn __pthread_get_minstack(_: *libc::pthread_attr_t) -> libc::size_t {\n-        libc::PTHREAD_STACK_MIN\n-    }\n-\n     // glibc >= 2.15 has a __pthread_get_minstack() function that returns\n     // PTHREAD_STACK_MIN plus however many bytes are needed for thread-local\n     // storage.  We need that information to avoid blowing up when a small stack\n     // is created in an application with big thread-local storage requirements.\n     // See #6233 for rationale and details.\n     //\n-    // Dynamically resolve the symbol for compatibility with older versions\n-    // of glibc.  Assumes that we've been dynamically linked to libpthread\n-    // but that is currently always the case.  Note that this means we take\n-    // a dlopen/dlsym/dlclose hit for every new thread.  Mitigating that by\n-    // caching the symbol or the function's return value has its drawbacks:\n-    //\n-    //  * Caching the symbol breaks when libpthread.so is reloaded because\n-    //    its address changes.\n-    //\n-    //  * Caching the return value assumes that it's a fixed quantity.\n-    //    Not very future-proof and untrue in the presence of guard pages\n-    //    The reason __pthread_get_minstack() takes a *libc::pthread_attr_t\n-    //    as its argument is because it takes pthread_attr_setguardsize() into\n-    //    account.\n-    //\n-    // A better solution is to define __pthread_get_minstack() as a weak symbol\n-    // but there is currently no way to express that in Rust code.\n-    #[cfg(target_os = \"linux\")]\n-    unsafe fn __pthread_get_minstack(attr: *libc::pthread_attr_t) -> libc::size_t {\n-        use option::None;\n-        use result::{Err, Ok};\n-        use unstable::dynamic_lib;\n-        match dynamic_lib::DynamicLibrary::open(None) {\n-            Err(err) => fail!(\"DynamicLibrary::open(): {}\", err),\n-            Ok(handle) => {\n-                match handle.symbol::<extern \"C\" fn(*libc::pthread_attr_t) ->\n-                                     libc::size_t>(\"__pthread_get_minstack\") {\n-                    Err(_) => libc::PTHREAD_STACK_MIN,\n-                    Ok(__pthread_get_minstack) => __pthread_get_minstack(attr),\n-                }\n-            }\n+    // Link weakly to the symbol for compatibility with older versions of glibc.\n+    // Assumes that we've been dynamically linked to libpthread but that is\n+    // currently always the case.  Note that you need to check that the symbol\n+    // is non-null before calling it!\n+    #[cfg(target_os = \"linux\", not(stage0))]\n+    fn min_stack_size(attr: *libc::pthread_attr_t) -> libc::size_t {\n+        use ptr::RawPtr;\n+        type F = extern \"C\" unsafe fn(*libc::pthread_attr_t) -> libc::size_t;\n+        extern {\n+            #[linkage = \"extern_weak\"]\n+            static __pthread_get_minstack: *u8;","path":"src/libstd/rt/thread.rs","position":65,"original_position":65,"commit_id":"8e2d77b95c14a1511f8e53e80a18afc24102f719","original_commit_id":"bc5fc0fb7b4944d69083866ea8056e67fdf21f55","user":{"login":"bharrisau","id":119958,"avatar_url":"https://gravatar.com/avatar/a00c8cd6b428692024076657e5be4635?d=https%3A%2F%2Fidenticons.github.com%2F801d6582c19a6114024c8b114a2c1db0.png&r=x","gravatar_id":"a00c8cd6b428692024076657e5be4635","url":"https://api.github.com/users/bharrisau","html_url":"https://github.com/bharrisau","followers_url":"https://api.github.com/users/bharrisau/followers","following_url":"https://api.github.com/users/bharrisau/following{/other_user}","gists_url":"https://api.github.com/users/bharrisau/gists{/gist_id}","starred_url":"https://api.github.com/users/bharrisau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bharrisau/subscriptions","organizations_url":"https://api.github.com/users/bharrisau/orgs","repos_url":"https://api.github.com/users/bharrisau/repos","events_url":"https://api.github.com/users/bharrisau/events{/privacy}","received_events_url":"https://api.github.com/users/bharrisau/received_events","type":"User","site_admin":false},"body":"*() feels more special than rand(*u8, *i8, *u16, *i16, etc). ;)","created_at":"2014-02-26T02:18:13Z","updated_at":"2014-02-26T02:18:13Z","html_url":"https://github.com/mozilla/rust/pull/12556#discussion_r10066081","pull_request_url":"https://api.github.com/repos/mozilla/rust/pulls/12556","_links":{"self":{"href":"https://api.github.com/repos/mozilla/rust/pulls/comments/10066081"},"html":{"href":"https://github.com/mozilla/rust/pull/12556#discussion_r10066081"},"pull_request":{"href":"https://api.github.com/repos/mozilla/rust/pulls/12556"}}}}