mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
modules: improve _gettid wrapper
- use meson to check for gettid() function, always use if available - use syscall fallback on linux, if not - restrict thr_self() fallback to *only* FreeBSD - error out if there isn't any gettid impl
This commit is contained in:
parent
a4b8bd6d52
commit
4c166709d0
2 changed files with 9 additions and 2 deletions
|
|
@ -254,6 +254,9 @@ endif
|
|||
if cc.has_function('getpagesize', prefix : '#include<unistd.h>')
|
||||
cdata.set('HAVE_GETPAGESIZE', 1)
|
||||
endif
|
||||
if cc.has_function('gettid', prefix : '#include<unistd.h>', args: [ '-D_GNU_SOURCE' ])
|
||||
cdata.set('HAVE_GETTID', 1)
|
||||
endif
|
||||
if cc.has_function('clock_gettime', prefix : '#include <time.h>')
|
||||
cdata.set('HAVE_CLOCK_GETTIME', 1)
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -182,12 +182,16 @@ void pw_rtkit_bus_free(struct pw_rtkit_bus *system_bus)
|
|||
|
||||
static pid_t _gettid(void)
|
||||
{
|
||||
#ifndef __FreeBSD__
|
||||
#if defined(HAVE_GETTID)
|
||||
return (pid_t) gettid();
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
return syscall(SYS_gettid);
|
||||
#elif defined(__FreeBSD__)
|
||||
long pid;
|
||||
thr_self(&pid);
|
||||
return (pid_t)pid;
|
||||
#else
|
||||
#error "No gettid impl"
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue