#522773 linux-libc-dev: uses "__unused" as identifier, which is traditionally used by BSD as macro #522773
- Package:
- linux-libc-dev
- Source:
- linux
- Description:
- Linux support headers for userspace development
- Submitter:
- Thorsten Glaser
- Date:
- 2022-06-10 00:39:05 UTC
- Severity:
- wishlist
- Tags:
(mass filing with linux-libc-dev and libc6-dev) /usr/include/asm/stat.h: long __unused[3]; /usr/include/linux/icmp.h: __be16 __unused; /usr/include/linux/sysctl.h: unsigned long __unused[4]; These conflict with the traditional use of __unused by the BSDs, which predates use of __unused as identifier by Linux and glibc headers. For example, the Debian package libbsd-dev includes the following code: #ifndef __unused # ifdef __GNUC__ # define __unused __attribute__((unused)) # else # define __unused # endif #endif It however was ifdef’d out due to this problem. A personal package of mine, mirmake, fails to build on more recent Debian systems because it does _not_ ifdef it out, since otherwise, some BSD software cannot be compiled (without extra patches). Please file this bug with your respective upstreams *and* patch the header files in question yourselves, to bridge over the response time waiting for upstream to fix it. Thanks!
Hi package maintainers, maybe you can do such a thing during package installation? This would tremendously help porting software (liberal in what one accepts), such as NetBSD® makefs (ITP: #538171 – for now I worked around the issue in it). Joseph S. Myers dixit: I do have a suggestion. Maybe we can get into an agreement still… How about you use the following sed expression on installation? This way you’d only have to change the Makefile.in in question. s/[[:<:]]__unused[[:>:]]/&_/g I do not know if your sed(1) does [[:<:]] and [[:>:]], ours does, see http://www.mirbsd.org/man7/re_format – if not, something si- milar would probably be possible. As __unused* should never be used from userland, this would work I think. Comments? //mirabilos No, the only way I've seen them sold is for $40 with a free OpenBSD CD. -- Haroon Khalid and Steve Shockley in gmane.os.openbsd.misc
tags 522773 wontfix
severity 522773 wishlist
thanks
You need to get this changed upstream, we won't deviate from
upstream for this.
Cheers,
Moritz
Moritz Muehlenhoff dixit: You probably have better contact to upstream, would you be so kind as to bring this forward with them? Thanks in advance. Sincerely, //mirabilos
We don't have time for this. You should contact linux-kernel or
file a bug at http://bugzilla.kernel.org
Cheers,
Moritz
It seems there are two traditions for attribute macros. The GNU one produced things like: #define __attribute_malloc__ __attribute__ ((__malloc__)) #define __attribute_pure__ __attribute__ ((__pure__)) #define __attribute_used__ __attribute__ ((__used__)) #define __attribute_noinline__ __attribute__ ((__noinline__)) #define __always_inline __inline __attribute__ ((__always_inline__)) The BSD one produced things like: #define __malloc_like __attribute__((__malloc__)) #define __pure __attribute__((__pure__)) #define __used __attribute__((__used__)) #define __noinline __attribute__ ((__noinline__)) #define __always_inline __attribute__((__always_inline__)) When it comes to __attibute__((__unused__)), it's just a matter of agreeing on whether to call it __attribute_unused__ or __unused. The problem is that there's severe NIH to overcome. As you can see with the bug you submitted to Linux developers, they're generally very hostile to portability. The same applies to Glibc (aka Drepper). Here are some possible ways out of this I can think of: - Propose to BSD folks that they accept __attribute_* prefix and define those macros (in addition to __unused etc), then begin accepting patches that replace __unused with __attribute_unused. - Propose to GCC folks that they define __attribute_* macros in <stddef.h> (they won't define __unused since this would break Linux and Glibc), then bring the same proposal to Clang folks. If both accept, FreeBSD is much more likely to backport it to GCC 4.2. - Work with standards bodies (POSIX?) so that they specify either definition (it doesn't matter to us which one, the offending definition will have to adapt). What I would definitely NOT do is waste any time trying to persuade Drepper to remove __unused from Glibc or Linux developers to remove __unused from Linux.
Hi Robert, Robert Millan wrote: I don't agree. It's perfectly fine for there to be multiple names for the thing --- the task at hand is dividing up the __* namespace between libbsd and libc. Would it be possible to collect a near-exhaustive list of identifiers like this (i.e., used in BSD application code and starting with __) that could cause trouble? Then we can propose sed-ing them away at header installation time to the libc-ports maintainers (as Thorsten suggested), and I wouldn't be surprised if such a patch is accepted. Thanks for moving this forward. Thoughts below about the alternatives you mentioned. Regards, Jonathan If I were in their shoes, I wouldn't be happy about such patches. It sounds like heavy patching without much immediate benefit, with no end in sight (since glibc could start using another keyword the next day). Likewise, in their shoes I wouldn't accept such patches. The macros are not in the C or POSIX standard and are easy to define in terms of the __attribute__() feature, so they're not part of what a C compiler is supposed to do. Making each implementation of the standard headers add these macros would hinder portability between implementations (yes, there are more than two :)). That sounds like an excellent idea! Presumably the C working group would be likely to consider standardizing __attribute__((__unused__)) if it is proposed, since that syntax is already widely implemented. C++0x has its own attribute syntax which could make something like [[unused]] possible.
2011/6/18 Jonathan Nieder <jrnieder@gmail.com>: Providing multiple names is fine, the problem is which ones to use. If BSD developers agree to provide both __attribute_unused and __unused, and switch their users to __attribute_unused, problem is solved. If Drepper agrees to provide __unused, problem would be solved but this won't happen. Yes, just read the GNU and BSD versions of <sys/cdefs.h>... ... but I don't think this will fly. I can see they wouldn't be excited about it, but they might also accept them. This is not a recurrent problem: it's irrelevant if glibc changes it to another keyword (heck, there isn't even any equivalent to __unused RIGHT NOW), what matters is that we'd have found a way out the name collision. Actually, I realized afer writing this that the point of these macros is precisely portability among different compilers. Moving them to a GCC header is out of the question (we might as well just use __attribute__((__unused__)) then). Well I have no experience working with standards bodies (and no spare time), but if someone wants to take it, I'm almost certain this would resolve our problem.
Robert Millan dixit: You know that there are more than one BSD, but only one glibc, IIRC Drepper isn’t even its maintainer any more. Try persuading for example Theo de Raadt of anything which doesn’t have any immediate technical merit… have fun ;-) Honestly, when resolving this I’d go for “who has the older rights”. Maybe look at how CSUR resolves different claims to the same part of the Unicode PUA, or something like that. Nevertheless, thanks on picking this up. bye, //mirabilos
According to <http://www.gnu.org/software/libc/> "Ulrich Drepper is currently the foremost contributor and has overall responsibility for maintenance and development." Debian GNU/Linux is the older system; the Debian GNU/kFreeBSD maintainers have to deal with compatibility issues. Ben.
Ben Hutchings dixit: The use of __undefined in the BSDs predates use of it by both Linux and GNU. (But when using this argumentation style, we’d probably better take this upstream… except that upstream may not be helping…) bye, //mirabilos
We already asked you back in September 2009 to report this upstream.
If you don't think that will help, we can just close the bug, then.
Cheers,
Moritz
2011/7/29 Moritz Mühlenhoff <jmm@inutil.org>: He did, precisely in September 2009: https://bugzilla.kernel.org/show_bug.cgi?id=14186 He still got no response though.
'__unused' is defined as a macro by some BSD-derived userland software.
We should avoid using it in the UAPI.
References: https://bugs.debian.org/522773
Reported-by: Thorsten Glaser <tg@mirbsd.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
Build-tested on x86 only. I also grepped for uses of the supposedly
__unused fields on other architectures and found nothing.
Ben.
arch/alpha/include/uapi/asm/stat.h | 2 +-
arch/arm64/include/uapi/asm/ucontext.h | 2 +-
arch/ia64/include/uapi/asm/stat.h | 2 +-
arch/powerpc/include/uapi/asm/ucontext.h | 2 +-
arch/s390/include/uapi/asm/stat.h | 2 +-
arch/s390/include/uapi/asm/ucontext.h | 4 ++--
arch/sparc/include/uapi/asm/fcntl.h | 4 ++--
arch/sparc/include/uapi/asm/stat.h | 2 +-
arch/x86/include/uapi/asm/stat.h | 8 ++++----
include/uapi/linux/icmp.h | 2 +-
include/uapi/linux/sysctl.h | 2 +-
11 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/arch/alpha/include/uapi/asm/stat.h b/arch/alpha/include/uapi/asm/stat.h
index 07ad3e6b3f3e..f13899ad8d85 100644
--- a/arch/alpha/include/uapi/asm/stat.h
+++ b/arch/alpha/include/uapi/asm/stat.h
@@ -42,7 +42,7 @@ struct stat64 {
unsigned long st_mtime_nsec;
unsigned long st_ctime;
unsigned long st_ctime_nsec;
- long __unused[3];
+ long __unused1[3];
};
#endif
diff --git a/arch/arm64/include/uapi/asm/ucontext.h b/arch/arm64/include/uapi/asm/ucontext.h
index 791de8e89e35..37b343d2492e 100644
--- a/arch/arm64/include/uapi/asm/ucontext.h
+++ b/arch/arm64/include/uapi/asm/ucontext.h
@@ -24,7 +24,7 @@ struct ucontext {
stack_t uc_stack;
sigset_t uc_sigmask;
/* glibc uses a 1024-bit sigset_t */
- __u8 __unused[1024 / 8 - sizeof(sigset_t)];
+ __u8 __unused1[1024 / 8 - sizeof(sigset_t)];
/* last for future expansion */
struct sigcontext uc_mcontext;
};
diff --git a/arch/ia64/include/uapi/asm/stat.h b/arch/ia64/include/uapi/asm/stat.h
index 367bb90cdffa..aa1e4f942942 100644
--- a/arch/ia64/include/uapi/asm/stat.h
+++ b/arch/ia64/include/uapi/asm/stat.h
@@ -24,7 +24,7 @@ struct stat {
unsigned long st_ctime_nsec;
unsigned long st_blksize;
long st_blocks;
- unsigned long __unused[3];
+ unsigned long __unused1[3];
};
#define STAT_HAVE_NSEC 1
diff --git a/arch/powerpc/include/uapi/asm/ucontext.h b/arch/powerpc/include/uapi/asm/ucontext.h
index d9a4ddf0cc86..cb08c035e427 100644
--- a/arch/powerpc/include/uapi/asm/ucontext.h
+++ b/arch/powerpc/include/uapi/asm/ucontext.h
@@ -28,7 +28,7 @@ struct ucontext {
sigset_t uc_sigmask;
/* glibc has 1024-bit signal masks, ours are 64-bit */
#ifdef __powerpc64__
- sigset_t __unused[15]; /* Allow for uc_sigmask growth */
+ sigset_t __unused1[15]; /* Allow for uc_sigmask growth */
struct sigcontext uc_mcontext; /* last for extensibility */
#else
int uc_maskext[30];
diff --git a/arch/s390/include/uapi/asm/stat.h b/arch/s390/include/uapi/asm/stat.h
index b4ca97d91466..5e493c1aa1f6 100644
--- a/arch/s390/include/uapi/asm/stat.h
+++ b/arch/s390/include/uapi/asm/stat.h
@@ -93,7 +93,7 @@ struct stat {
unsigned long st_ctime_nsec;
unsigned long st_blksize;
long st_blocks;
- unsigned long __unused[3];
+ unsigned long __unused1[3];
};
#endif /* __s390x__ */
diff --git a/arch/s390/include/uapi/asm/ucontext.h b/arch/s390/include/uapi/asm/ucontext.h
index 64a69aa5dde0..59d915f9ac27 100644
--- a/arch/s390/include/uapi/asm/ucontext.h
+++ b/arch/s390/include/uapi/asm/ucontext.h
@@ -23,7 +23,7 @@ struct ucontext_extended {
_sigregs uc_mcontext;
sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
- unsigned char __unused[128 - sizeof(sigset_t)];
+ unsigned char __unused1[128 - sizeof(sigset_t)];
_sigregs_ext uc_mcontext_ext;
};
@@ -34,7 +34,7 @@ struct ucontext {
_sigregs uc_mcontext;
sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
- unsigned char __unused[128 - sizeof(sigset_t)];
+ unsigned char __unused1[128 - sizeof(sigset_t)];
};
#endif /* !_ASM_S390_UCONTEXT_H */
diff --git a/arch/sparc/include/uapi/asm/fcntl.h b/arch/sparc/include/uapi/asm/fcntl.h
index 7e8ace5bf760..9f5d4383170a 100644
--- a/arch/sparc/include/uapi/asm/fcntl.h
+++ b/arch/sparc/include/uapi/asm/fcntl.h
@@ -48,8 +48,8 @@
#define F_WRLCK 2
#define F_UNLCK 3
-#define __ARCH_FLOCK_PAD short __unused;
-#define __ARCH_FLOCK64_PAD short __unused;
+#define __ARCH_FLOCK_PAD short __unused1;
+#define __ARCH_FLOCK64_PAD short __unused1;
#include <asm-generic/fcntl.h>
diff --git a/arch/sparc/include/uapi/asm/stat.h b/arch/sparc/include/uapi/asm/stat.h
index a232e9e1f4e5..0b4b4ae9a05d 100644
--- a/arch/sparc/include/uapi/asm/stat.h
+++ b/arch/sparc/include/uapi/asm/stat.h
@@ -43,7 +43,7 @@ struct stat64 {
unsigned long st_mtime_nsec;
unsigned long st_ctime;
unsigned long st_ctime_nsec;
- long __unused[3];
+ long __unused1[3];
};
#else
diff --git a/arch/x86/include/uapi/asm/stat.h b/arch/x86/include/uapi/asm/stat.h
index bc03eb5d6360..64ba4e324f57 100644
--- a/arch/x86/include/uapi/asm/stat.h
+++ b/arch/x86/include/uapi/asm/stat.h
@@ -99,15 +99,15 @@ struct stat {
__kernel_ulong_t st_mtime_nsec;
__kernel_ulong_t st_ctime;
__kernel_ulong_t st_ctime_nsec;
- __kernel_long_t __unused[3];
+ __kernel_long_t __unused1[3];
};
/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT_PADDING(st) do { \
st.__pad0 = 0; \
- st.__unused[0] = 0; \
- st.__unused[1] = 0; \
- st.__unused[2] = 0; \
+ st.__unused1[0] = 0; \
+ st.__unused1[1] = 0; \
+ st.__unused1[2] = 0; \
} while (0)
#endif
diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h
index 16fff055f734..78d71b13f9e5 100644
--- a/include/uapi/linux/icmp.h
+++ b/include/uapi/linux/icmp.h
@@ -76,7 +76,7 @@ struct icmphdr {
} echo;
__be32 gateway;
struct {
- __be16 __unused;
+ __be16 __unused1;
__be16 mtu;
} frag;
} un;
diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
index 0956373b56db..177aa35a8ce8 100644
--- a/include/uapi/linux/sysctl.h
+++ b/include/uapi/linux/sysctl.h
@@ -40,7 +40,7 @@ struct __sysctl_args {
size_t __user *oldlenp;
void __user *newval;
size_t newlen;
- unsigned long __unused[4];
+ unsigned long __unused1[4];
};
/* Define sysctl names first */
hi, Given there was as well not reaction upstream AFAICS, as well to Ben's posted patch I guess we can close this bug. Not doing so yet though. Regards, Salvatore
Another year has passed and it's now almost 10 years ago that the upstream bug was closed (in a less then courteous way). I just checked 'arch/alpha/include/uapi/asm/stat.h' in Linus' master branch and the patch proposed by Ben, more then 6 years ago, hasn't been merged. As I don't know the reason it wasn't closed last year, I won't do it, but maybe it's time to finally close it?
Diederik de Haas dixit: If the bug persists, it’s still a bug, so don’t close it. Prod them occasionally. I know that *some* __unused have been fixed; maybe the remaining ones were an oversight? bye, //mirabilos