Bladeren bron

add gettid syscall wrapper

Waldemar Brodkorb 2 dagen geleden
bovenliggende
commit
47c15dbb50

+ 4 - 0
include/unistd.h

@@ -1259,6 +1259,10 @@ extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
 # endif
 #endif
 
+#if (defined _GNU_SOURCE && defined __UCLIBC_HAS_THREADS_NATIVE__)
+pid_t gettid(void);
+#endif
+
 __END_DECLS
 
 

+ 1 - 1
libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch

@@ -68,7 +68,7 @@ libpthread_linux_CSRC += pthread_attr_getaffinity.c pthread_attr_setaffinity.c \
 libpthread_linux_SSRC := #ptw-close.S ptw-open.S ptw-waitid.S ptw-waidpid.S ptw-write.S
 
 libc_linux_CSRC += libc_pthread_init.c libc_multiple_threads.c		\
-	register-atfork.c unregister-atfork.c getpid.c		\
+	register-atfork.c unregister-atfork.c getpid.c gettid.c		\
 	raise.c jmp-unwind.c
 
 librt_linux_CSRC += mq_notify.c timer_create.c timer_delete.c		\

+ 13 - 0
libpthread/nptl/sysdeps/unix/sysv/linux/gettid.c

@@ -0,0 +1,13 @@
+/* Copyright (C) 2025 Waldemar Brodkorb <wbx@uclibc-ng.org> */
+
+#include <unistd.h>
+#include <tls.h>
+#include <sysdep.h>
+
+pid_t
+gettid (void)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  pid_t result = INTERNAL_SYSCALL (gettid, err, 0);
+  return result;
+}