From patchwork Sat Jul 20 20:40:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 33748 Received: (qmail 121950 invoked by alias); 20 Jul 2019 20:41:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 121942 invoked by uid 89); 20 Jul 2019 20:41:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:87muh8a, H*i:sk:87muh8a, 1998 X-HELO: mail-qk1-f196.google.com MIME-Version: 1.0 References: <20190720174844.4b989d34@sf> <87wogca86l.fsf@mid.deneb.enyo.de> <87muh8a4a3.fsf@mid.deneb.enyo.de> In-Reply-To: <87muh8a4a3.fsf@mid.deneb.enyo.de> From: Arnd Bergmann Date: Sat, 20 Jul 2019 22:40:49 +0200 Message-ID: Subject: Re: linux-headers-5.2 and proper use of SIOCGSTAMP To: Florian Weimer Cc: Sergei Trofimovich , Networking , Linux Kernel Mailing List , GNU C Library , "David S. Miller" , Michael Kerrisk , linux-man On Sat, Jul 20, 2019 at 9:34 PM Florian Weimer wrote: > * Arnd Bergmann: > > On Sat, Jul 20, 2019 at 8:10 PM Florian Weimer wrote: > > As far as I can tell, nobody thought it would be a problem to move it > > from asm/sockios.h to linux/sockios.h, as the general rule is that one > > should use the linux/*.h version if both exist, and that the asm/*.h > > version only contains architecture specific definitions. The new > > definition is the same across all architectures, so it made sense to > > have it in the common file. > > Most of the socket-related constants are not exposed in UAPI headers, > although userspace is expected to use them. It seems to me that due > to the lack of other options among the UAPI headers, > has been a dumping ground for various socket-related things in the > past, whether actually architecture-specific or not. > > does not include , so that's why we > usually end up with including (perhaps indirectly via > ), which used to include on most (all?) > architectures. That in turn provided some of the SIOC* constants in > the past, so people didn't investigate other options. It seems that both the missing constants and the fact that linux/socket.h doesn't include asm/socket.h and linux/sockios.h goes back to a 21 year old commit: commit 74f513101058f7585176ea8cdf6fb026faea8a7e Author: linus1 Date: Wed May 20 11:00:00 1998 -0800 [tytso] include/asm-i386/posix_types.h This quick fix eliminates a lot of warning messages when compiling e2fsprogs under glibc. This is because the glibc header files defines its own version of FD_SET, FD_ZERO, etc., and so if you need to #include the kernel include files, you get a lot of duplicate defined macro warning messages. This patch simply #ifdef's out the kernel versions of these function if the kernel is not being compiled and the glibc header files are in use. #include /* iovec support */ @@ -256,4 +258,5 @@ extern int move_addr_to_user(void *kaddr, int klen, void *uaddr, int *ulen); extern int move_addr_to_kernel(void *uaddr, int ulen, void *kaddr); extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); #endif +#endif /* not kernel and not glibc */ #endif /* _LINUX_SOCKET_H */ (the same commit did similar changes in linux/stat.h and asm/posix_types.h) Over time, the check for glibc was removed (to allow including linux/socket.h before sys/socket.h), and all the #ifdef __KERNEL__ bits were removed from the installed header as part of the uapi header split. > I think we can change glibc to include in addition > to . looks reasonably clean to me, > much better than . That seems reasonable to me, but overall my fear is that these headers are already so broken that any change will risk breaking something in more or less unexpected ways. Arnd diff --git a/include/linux/socket.h b/include/linux/socket.h index 08f0d281401c..35a7629b6b70 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -1,6 +1,8 @@ #ifndef _LINUX_SOCKET_H #define _LINUX_SOCKET_H +#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) + #include /* arch-dependent defines */ #include /* the SIOCxxx I/O controls */