Commit b34ec62a authored by Jan Kiszka's avatar Jan Kiszka
Browse files

lib: Switch to pthread_mutexattr_setrobust



With recent glibc (at least 2.34), autoconf fails to detect
pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So
switch to pthread_mutexattr_setrobust and only fall back to _np when
needed.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent ab753198
......@@ -530,6 +530,7 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \
pthread_mutexattr_getprotocol \
pthread_mutexattr_getprioceiling \
pthread_mutexattr_setprioceiling \
pthread_mutexattr_setrobust \
pthread_mutexattr_setrobust_np \
pthread_mutex_getprioceiling \
pthread_mutex_setprioceiling \
......
......@@ -243,14 +243,18 @@ __weak int shm_unlink(const char *name)
}
#endif /* !HAVE_SHM_UNLINK */
#ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
#ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST
#ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
#define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np
#else
static inline
int pthread_mutexattr_setrobust_np(const pthread_mutexattr_t *attr,
int *robustness)
int pthread_mutexattr_setrobust(const pthread_mutexattr_t *attr,
int *robustness)
{
return ENOSYS;
}
#endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP */
#endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST */
#if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY)
static inline
......
......@@ -131,8 +131,8 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);
pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
/* pthread_mutexattr_setrobust_np() might not be implemented. */
pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP);
/* pthread_mutexattr_setrobust() might not be implemented. */
pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
if (ret) {
xnfree(mcb);
......
......@@ -411,8 +411,8 @@ SEM_ID semMCreate(int options)
*/
pthread_mutexattr_init(&mattr);
pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
/* pthread_mutexattr_setrobust_np() might not be implemented. */
pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP);
/* pthread_mutexattr_setrobust() might not be implemented. */
pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
if (options & SEM_INVERSION_SAFE)
pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment