mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-05 03:01:05 +00:00
f5c77f78ec
This patch removes __ASSUME_FUTEX_LOCK_PI usage and assumes that kernel will correctly return if it supports or not futex_atomic_cmpxchg_inatomic. Current PI mutex code already has runtime support by calling prio_inherit_missing and returns ENOTSUP if the futex operation fails at initialization (it issues a FUTEX_UNLOCK_PI futex operation). Also, current minimum supported kernel (v3.2) will return ENOSYS if futex_atomic_cmpxchg_inatomic is not supported in the system: kernel/futex.c: 2628 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 2629 u32 __user *uaddr2, u32 val2, u32 val3) 2630 { 2631 int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK; [...] 2667 case FUTEX_UNLOCK_PI: 2668 if (futex_cmpxchg_enabled) 2669 ret = futex_unlock_pi(uaddr, flags); [...] 2686 return ret; 2687 } The futex_cmpxchg_enabled is initialized by calling cmpxchg_futex_value_locked, which calls futex_atomic_cmpxchg_inatomic. For ARM futex_atomic_cmpxchg_inatomic will be either defined (if both CONFIG_CPU_USE_DOMAINS and CONFIG_SMP are not defined) or use the default generic implementation that returns ENOSYS. For m68k is uses the default generic implementation. For mips futex_atomic_cmpxchg_inatomic will return ENOSYS if cpu has no 'cpu_has_llsc' support (defined by each chip supporte inside kernel). For sparc, 32-bit kernel will just use default generic implementation, while 64-bit kernel has support. Tested on ARM (v3.8 kernel) and x86_64. * nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI] (prio_inherit_missing): Remove define. * sysdeps/unix/sysv/linux/arm/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/m68k/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/mips/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise. * sysdeps/unix/sysv/linux/sparc/kernel-features.h (__ASSUME_FUTEX_LOCK_PI): Likewise.
57 lines
2.1 KiB
C
57 lines
2.1 KiB
C
/* Set flags signalling availability of kernel features based on given
|
|
kernel version number.
|
|
Copyright (C) 2008-2016 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library. If not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* m68k uses socketcall. */
|
|
#define __ASSUME_SOCKETCALL 1
|
|
|
|
/* Direct socketcalls available with kernel 4.3. */
|
|
#if __LINUX_KERNEL_VERSION >= 0x040300
|
|
# define __ASSUME_SOCKET_SYSCALL 1
|
|
# define __ASSUME_SOCKETPAIR_SYSCALL 1
|
|
# define __ASSUME_BIND_SYSCALL 1
|
|
# define __ASSUME_CONNECT_SYSCALL 1
|
|
# define __ASSUME_LISTEN_SYSCALL 1
|
|
# define __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL 1
|
|
# define __ASSUME_GETSOCKOPT_SYSCALL 1
|
|
# define __ASSUME_SETSOCKOPT_SYSCALL 1
|
|
# define __ASSUME_GETSOCKNAME_SYSCALL 1
|
|
# define __ASSUME_GETPEERNAME_SYSCALL 1
|
|
# define __ASSUME_SENDTO_SYSCALL 1
|
|
# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1
|
|
# define __ASSUME_RECVFROM_SYSCALL 1
|
|
# define __ASSUME_RECVFROM_FOR_RECV_SYSCALL 1
|
|
# define __ASSUME_SHUTDOWN_SYSCALL 1
|
|
#endif
|
|
|
|
#include_next <kernel-features.h>
|
|
|
|
#if __LINUX_KERNEL_VERSION < 0x040300
|
|
# undef __ASSUME_ACCEPT4_SYSCALL
|
|
# undef __ASSUME_RECVMMSG_SYSCALL
|
|
# undef __ASSUME_SENDMMSG_SYSCALL
|
|
# undef __ASSUME_SENDMSG_SYSCALL
|
|
# undef __ASSUME_RECVMSG_SYSCALL
|
|
#endif
|
|
|
|
/* No support for PI futexes or robust mutexes before 3.10 for m68k. */
|
|
#if __LINUX_KERNEL_VERSION < 0x030a00
|
|
# undef __ASSUME_REQUEUE_PI
|
|
# undef __ASSUME_SET_ROBUST_LIST
|
|
#endif
|