8384946: os::Bsd::gettid misses the return value

Co-authored-by: Kurt Miller <kurt@openjdk.org>
Co-authored-by: Greg Lewis <glewis@openjdk.org>
Reviewed-by: shade, phubner, jwaters
This commit is contained in:
Harald Eilertsen 2026-05-20 09:17:12 +00:00 committed by Aleksey Shipilev
parent fada70f8cc
commit 0b0829960b

View File

@ -102,6 +102,14 @@
#include <elf.h>
#endif
#ifdef __FreeBSD__
#include <pthread_np.h>
#endif
#ifdef __NetBSD__
#include <lwp.h>
#endif
#ifdef __APPLE__
#include <libproc.h>
#include <mach/task_info.h>
@ -873,23 +881,20 @@ pid_t os::Bsd::gettid() {
mach_port_deallocate(mach_task_self(), port);
return (pid_t)port;
#elif defined(__FreeBSD__)
return ::pthread_getthreadid_np();
#elif defined(__OpenBSD__)
retval = getthrid();
#elif defined(__NetBSD__)
retval = (pid_t) _lwp_self();
#else
#ifdef __FreeBSD__
retval = syscall(SYS_thr_self);
#else
#ifdef __OpenBSD__
retval = syscall(SYS_getthrid);
#else
#ifdef __NetBSD__
retval = (pid_t) syscall(SYS__lwp_self);
#endif
#endif
#endif
#error "unsupported OS"
#endif
if (retval == -1) {
return getpid();
}
return retval;
}
// Returns the uid of a process or -1 on error.