glib/gthread-posix: Use the config.h macros to detect futex support

This commit is contained in:
L. E. Segovia 2024-04-01 23:57:46 -03:00
parent ffa639f0b7
commit 049c8e70c8
2 changed files with 10 additions and 10 deletions

View File

@ -1624,7 +1624,7 @@ g_cond_wait_until (GCond *cond,
sampled = cond->i[0];
g_mutex_unlock (mutex);
#ifdef __NR_futex_time64
#if defined(HAVE_FUTEX_TIME64)
#if defined(__BIONIC__)
if (__builtin_available (android 30, *)) {
#else
@ -1645,9 +1645,9 @@ g_cond_wait_until (GCond *cond,
* normal `futex` syscall. This can happen if newer kernel headers are
* used than the kernel that is actually running.
*/
# ifdef __NR_futex
# if defined(HAVE_FUTEX)
if (res >= 0 || errno != ENOSYS)
# endif /* defined(__NR_futex) */
# endif /* defined(HAVE_FUTEX) */
{
success = (res < 0 && errno == ETIMEDOUT) ? FALSE : TRUE;
g_mutex_lock (mutex);
@ -1657,7 +1657,7 @@ g_cond_wait_until (GCond *cond,
}
#endif
#ifdef __NR_futex
#if defined(HAVE_FUTEX)
{
# ifdef __kernel_long_t
# define KERNEL_SPAN_SEC_TYPE __kernel_long_t
@ -1689,7 +1689,7 @@ g_cond_wait_until (GCond *cond,
return success;
}
# undef KERNEL_SPAN_SEC_TYPE
#endif /* defined(__NR_futex) */
#endif /* defined(HAVE_FUTEX) */
/* We can't end up here because of the checks above */
g_assert_not_reached ();

View File

@ -73,7 +73,7 @@ struct _GRealThread
* This must not be called with a timeout parameter as that differs
* in size between the two syscall variants!
*/
#if defined(__NR_futex) && defined(__NR_futex_time64)
#if defined(HAVE_FUTEX) && defined(HAVE_FUTEX_TIME64)
#if defined(__BIONIC__)
#define g_futex_simple(uaddr, futex_op, ...) \
G_STMT_START \
@ -116,7 +116,7 @@ struct _GRealThread
} \
G_STMT_END
#endif /* defined(__BIONIC__) */
#elif defined(__NR_futex_time64)
#elif defined(HAVE_FUTEX_TIME64)
#define g_futex_simple(uaddr, futex_op, ...) \
G_STMT_START \
{ \
@ -128,7 +128,7 @@ struct _GRealThread
} \
} \
G_STMT_END
#elif defined(__NR_futex)
#elif defined(HAVE_FUTEX)
#define g_futex_simple(uaddr, futex_op, ...) \
G_STMT_START \
{ \
@ -140,9 +140,9 @@ struct _GRealThread
} \
} \
G_STMT_END
#else /* !defined(__NR_futex) && !defined(__NR_futex_time64) */
#else /* !defined(HAVE_FUTEX) && !defined(HAVE_FUTEX_TIME64) */
#error "Neither __NR_futex nor __NR_futex_time64 are available"
#endif /* defined(__NR_futex) && defined(__NR_futex_time64) */
#endif /* defined(HAVE_FUTEX) && defined(HAVE_FUTEX_TIME64) */
#endif