about summary refs log tree commit diff
path: root/library/std/src/sys/pal/unix/thread.rs
diff options
context:
space:
mode:
authorMads Marquart <mads@marquart.dk>2025-03-26 15:23:47 +0100
committerMads Marquart <mads@marquart.dk>2025-03-26 16:25:05 +0100
commita7bafc0afc3dba988a7bf85198c493b20523eaa0 (patch)
tree2a9a10286c82bd6a31ef625602c960e2b6f5f42e /library/std/src/sys/pal/unix/thread.rs
parent65899c06f117ddac9c8399479ddcdc122c92fddf (diff)
downloadrust-a7bafc0afc3dba988a7bf85198c493b20523eaa0.tar.gz
rust-a7bafc0afc3dba988a7bf85198c493b20523eaa0.zip
Change the syntax of the internal `weak!` macro
Change the syntax to include parameter names and a trailing semicolon.

Motivation:
- Mirror the `syscall!` macro.
- Allow rustfmt to format it (when wrapped in parentheses).
- For better documentation (having the parameter names available in
  the source code is a bit nicer).
- Allow future improvements to this macro where we can sometimes use the
  symbol directly when it's statically known to be available.
Diffstat (limited to 'library/std/src/sys/pal/unix/thread.rs')
-rw-r--r--library/std/src/sys/pal/unix/thread.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index bb34c2fabe5..9078dd1c231 100644
--- a/library/std/src/sys/pal/unix/thread.rs
+++ b/library/std/src/sys/pal/unix/thread.rs
@@ -193,11 +193,12 @@ impl Thread {
     // and its metadata from LLVM IR.
     #[no_sanitize(cfi)]
     pub fn set_name(name: &CStr) {
-        weak! {
+        weak!(
             fn pthread_setname_np(
-                libc::pthread_t, *const libc::c_char
-            ) -> libc::c_int
-        }
+                thread: libc::pthread_t,
+                name: *const libc::c_char,
+            ) -> libc::c_int;
+        );
 
         if let Some(f) = pthread_setname_np.get() {
             #[cfg(target_os = "nto")]
@@ -762,7 +763,9 @@ unsafe fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
     // We use dlsym to avoid an ELF version dependency on GLIBC_PRIVATE. (#23628)
     // We shouldn't really be using such an internal symbol, but there's currently
     // no other way to account for the TLS size.
-    dlsym!(fn __pthread_get_minstack(*const libc::pthread_attr_t) -> libc::size_t);
+    dlsym!(
+        fn __pthread_get_minstack(attr: *const libc::pthread_attr_t) -> libc::size_t;
+    );
 
     match __pthread_get_minstack.get() {
         None => libc::PTHREAD_STACK_MIN,