From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28673 invoked from network); 30 Sep 2020 23:42:30 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 30 Sep 2020 23:42:30 -0000 Received: (qmail 26045 invoked by uid 550); 30 Sep 2020 23:42:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26027 invoked from network); 30 Sep 2020 23:42:24 -0000 Date: Wed, 30 Sep 2020 19:42:12 -0400 From: Rich Felker To: Petr Vorel Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Michal Kubecek , musl@lists.openwall.com Message-ID: <20200930234212.GK17637@brightrain.aerifal.cx> References: <20200930214636.186132-1-petr.vorel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200930214636.186132-1-petr.vorel@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH 1/1] linux/sysinfo.h: Add guarder for struct sysinfo On Wed, Sep 30, 2020 at 11:46:36PM +0200, Petr Vorel wrote: > for all but glibc libc. > > This fixes redefinition on MUSL which also defines struct sysinfo when > including (which includes via > ) and . > > glibc loads in . > > Signed-off-by: Petr Vorel > --- > include/uapi/linux/sysinfo.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/uapi/linux/sysinfo.h b/include/uapi/linux/sysinfo.h > index 435d5c23f0c0..c8ab18cd36b2 100644 > --- a/include/uapi/linux/sysinfo.h > +++ b/include/uapi/linux/sysinfo.h > @@ -5,6 +5,8 @@ > #include > > #define SI_LOAD_SHIFT 16 > + > +#if defined(__KERNEL__) || defined(__GLIBC__) > struct sysinfo { > __kernel_long_t uptime; /* Seconds since boot */ > __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */ > @@ -21,5 +23,6 @@ struct sysinfo { > __u32 mem_unit; /* Memory unit size in bytes */ > char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */ > }; > +#endif > > #endif /* _LINUX_SYSINFO_H */ > -- > 2.27.0.rc0 I don't think this is the right way to do it. It prevents getting access to the kernel uapi structure (which may be wanted) if you're not using glibc or if you include kernel headers before any libc headers. Rather, , whose only real purpose is providing this structure to legacy applications that don't know the renamed name for it, should not be implicitly included by other headers. There's an existing thread on the topic but I don't have the link handy. IIRC I proposed moving the alignment macros or whatever other useful stuff is in to a separate header and getting rid of all the indirect inclusions of . Rich