Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932270AbcDYMNu (ORCPT ); Mon, 25 Apr 2016 08:13:50 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:58514 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754372AbcDYMNt (ORCPT ); Mon, 25 Apr 2016 08:13:49 -0400 Date: Mon, 25 Apr 2016 15:13:35 +0300 From: Mikko Rapeli To: Szabolcs Nagy Cc: "David S. Miller" , Zhang Shengju , Stephen Hemminger , linux-kernel@vger.kernel.org, Jan Engelhardt , Josh Boyer , Waldemar Brodkorb , Gabriel Laskar , netfilter-devel@vger.kernel.org, libc-alpha@sourceware.org, Rich Felker , nd Subject: Re: [PATCH v2] uapi glibc compat: fix compile errors when glibc net/if.h included before linux/if.h Message-ID: <20160425121335.GL5160@lakka.kapsi.fi> References: <1461512707-23058-1-git-send-email-mikko.rapeli@iki.fi> <571DFED1.1090601@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <571DFED1.1090601@arm.com> X-SA-Exim-Connect-IP: 2001:1bc8:1004::1 X-SA-Exim-Mail-From: mikko.rapeli@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1800 Lines: 40 On Mon, Apr 25, 2016 at 12:26:09PM +0100, Szabolcs Nagy wrote: > On 24/04/16 16:45, Mikko Rapeli wrote: > > glibc's net/if.h contains copies of definitions from linux/if.h and these > > conflict and cause build failures if both files are included by application > > source code. Changes in uapi headers, which fixed header file dependencies to > > include linux/if.h when it was needed, e.g. commit 1ffad83d, made the > > net/if.h and linux/if.h incompatibilities visible as build failures for > > userspace applications like iproute2 and xtables-addons. > > > > This patch fixes compile errors when glibc net/if.h is included before > > linux/if.h: > > > > there should be a way to turn the conflicting definitions > off if a libc header is included first. (the other direction > won't work in general because linux definitions can be wrong > for user space.) > > currently the only way to avoid the conflict is to define > __GLIBC__ and a handful of glibc include guard macros that > are not part of any public api, so a libc implementation > might not want to do this. > > e.g. the kernel could turn off the potentially conflicting > definitions if the libc defines __LIBC_WANTS_NO_UAPI_DEFS > (it can use finer grain control, but there should be a > non-glibc specific way to do this). True. Maybe Linux kernel could allow non-glibc userspace headers to define __UAPI_DEF's as they wish but fall back to a default 1 as in lines after: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/libc-compat.h#n118 But sometimes users run old libc's and want to use shiny features from newer kernel and thus use kernel headers for some extra definitions to existing libc headers and use them in system calls. Driver specific ioctl's are a good example. -Mikko