From master, will be in 0.3.33 diff --git a/meson.build b/meson.build index 838fb66be8ca0e2d66009696f6c00c2ff7580b6e..977ce9ba1f22a2785efcb1b5a5bee08cf2e4bec3 100644 --- a/meson.build +++ b/meson.build @@ -254,6 +254,9 @@ endif if cc.has_function('getpagesize', prefix : '#include') cdata.set('HAVE_GETPAGESIZE', 1) endif +if cc.has_function('gettid', prefix : '#include', args: [ '-D_GNU_SOURCE' ]) + cdata.set('HAVE_GETTID', 1) +endif if cc.has_function('clock_gettime', prefix : '#include ') cdata.set('HAVE_CLOCK_GETTIME', 1) endif diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index 1f13aa371192bee738c4e10b45917473d2f9856d..7d55fb758cdc0a3073e3e3f2536949e824ffa223 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -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 } diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index de30f4123cf017f8be2eb7d4cd3bababb51da6fc..419e4be815a46d0f466969a02813f481d48ee5a1 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -518,7 +518,7 @@ static void *custom_start(void *data) struct impl *impl = this->impl; pthread_mutex_lock(&impl->lock); - this->pid = gettid(); + this->pid = _gettid(); pthread_cond_broadcast(&impl->cond); pthread_mutex_unlock(&impl->lock); diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index 419e4be815a46d0f466969a02813f481d48ee5a1..1f13aa371192bee738c4e10b45917473d2f9856d 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -592,7 +592,7 @@ static pid_t impl_gettid(struct impl *impl, pthread_t pt) if ((thr = find_thread_by_pt(impl, pt)) != NULL) pid = thr->pid; else - pid = getpid(); + pid = _gettid(); pthread_mutex_unlock(&impl->lock); return pid;