Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h

From: Tony Ambardar
Date: Sat Sep 19 2020 - 00:16:21 EST

On Thu, 17 Sep 2020 at 07:34, Andreas Schwab <schwab@xxxxxxxxxxxxxx> wrote:
> On Sep 17 2020, Arnd Bergmann wrote:
> > The errno man page says they are supposed to be synonyms,
> > and glibc defines it that way, while musl uses the numbers
> > from the kernel.
> glibc also uses whatever the kernel defines.
That's right, and from my investigation this isn't a libc issue. The
various libc flavours simply try to follow POSIX and the PPC ABI and
aren't doing anything wrong.

See errno.h for example (
EDEADLK: Resource deadlock avoided (POSIX.1-2001).
EDEADLOCK: On most architectures, a synonym for EDEADLK. On some
architectures (e.g., Linux MIPS, PowerPC, SPARC), it is a separate
error code "File locking deadlock error".

The root cause is unique to the Linux PPC code in
>/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>#include <asm-generic/errno.h>
>#define EDEADLOCK 58 /* File locking deadlock error */
>#endif /* _ASM_POWERPC_ERRNO_H */

It includes "<asm-generic/errno.h>" to pull in various definitions but
has the side-effect of redefining EDEADLOCK to a non-ABI value which
conflicts with the libc errno.h, as I outline in the patch
description. Other arches which also use different EDEADLOCK and
EDEADLK values (mips,sparc) do not do this. They define EDEADLOCK
*once*, with an ABI-consistent value, and don't have the same issue.

The problem goes back a ways (as Arnd points out), affecting current
stable and all LTS branches, so would be nice to get this sorted out.
I'm certainly interested if there's a better way than proposed in this

> Andreas.
> --
> Andreas Schwab, schwab@xxxxxxxxxxxxxx
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
> "And now for something completely different."