about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-09 15:56:10 +0000
committerbors <bors@rust-lang.org>2024-10-09 15:56:10 +0000
commit8e8dd57ac26ce4af9172e19e4059f8b67aece7fa (patch)
treec44b919d14a7900eebbfe87a7c50c241c3a5c933 /compiler/rustc_codegen_llvm/src
parent87058a499093b2d919849c6edeb643c5ba03a438 (diff)
parentf64c9c64164664bcd7ccad4a68ccd97f11684a22 (diff)
downloadrust-8e8dd57ac26ce4af9172e19e4059f8b67aece7fa.tar.gz
rust-8e8dd57ac26ce4af9172e19e4059f8b67aece7fa.zip
Auto merge of #3953 - YohDeadfall:glibc-thread-name, r=RalfJung
Fixed pthread_getname_np impl for glibc

The behavior of `glibc` differs a bit different for `pthread_getname_np` from other implementations. It requires the buffer to be at least 16 bytes wide without exception.

[Docs](https://www.man7.org/linux/man-pages/man3/pthread_setname_np.3.html):

```
The pthread_getname_np() function can be used to retrieve the
name of the thread.  The thread argument specifies the thread
whose name is to be retrieved.  The buffer name is used to return
the thread name; size specifies the number of bytes available in
name.  The buffer specified by name should be at least 16
characters in length.  The returned thread name in the output
buffer will be null terminated.
```

[Source](https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getname.c;hb=dff8da6b3e89b986bb7f6b1ec18cf65d5972e307#l37):

```c
int
__pthread_getname_np (pthread_t th, char *buf, size_t len)
{
  const struct pthread *pd = (const struct pthread *) th;

  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
     macro.  So we have to define it here.  */
#define TASK_COMM_LEN 16
  if (len < TASK_COMM_LEN)
    return ERANGE;
```
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions