From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932213AbdCFPKd (ORCPT ); Mon, 6 Mar 2017 10:10:33 -0500 Received: from mail-qk0-f175.google.com ([209.85.220.175]:35759 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932172AbdCFPKU (ORCPT ); Mon, 6 Mar 2017 10:10:20 -0500 MIME-Version: 1.0 X-Originating-IP: [184.145.137.27] In-Reply-To: References: <20170226010156.GA28831@altlinux.org> <20170302154845.GB3503@altlinux.org> From: "Carlos O'Donell" Date: Mon, 6 Mar 2017 10:10:18 -0500 Message-ID: Subject: Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors To: "Dmitry V. Levin" Cc: Arnd Bergmann , Russell King , Haavard Skinnemoen , Hans-Christian Egtvedt , Mikael Starvik , Jesper Nilsson , Yoshinori Sato , Tony Luck , Fenghua Yu , Geert Uytterhoeven , Ralf Baechle , David Howells , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , "David S. Miller" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Chris Zankel , Max Filippov , linux-arch , "linux-alpha@vger.kernel.org" , Linux ARM , linux-cris-kernel@axis.com, uclinux-h8-devel@lists.sourceforge.jp, linux-ia64@vger.kernel.org, linux-m68k@vger.kernel.org, "linux-mips@linux-mips.org" , linux-am33-list@redhat.com, linux-parisc , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, "linux-xtensa@linux-xtensa.org" , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 3, 2017 at 8:23 PM, Carlos O'Donell wrote: > On Thu, Mar 2, 2017 at 10:48 AM, Dmitry V. Levin wrote: >> On Thu, Mar 02, 2017 at 10:22:18AM -0500, Carlos O'Donell wrote: >>> On Wed, Mar 1, 2017 at 11:20 AM, Arnd Bergmann wrote: >>> > On Sun, Feb 26, 2017 at 2:01 AM, Dmitry V. Levin wrote: >>> >> Include (guarded by #ifndef __KERNEL__) to fix asm/signal.h >>> >> userspace compilation errors like this: >>> >> >>> >> /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t' >>> >> size_t ss_size; >>> >> >>> >> As no uapi header provides a definition of size_t, inclusion >>> >> of seems to be the most conservative fix available. >> [...] >>> > I'm not sure if this is the best fix. We generally should not include one >>> > standard header from another standard header. Would it be possible >>> > to use __kernel_size_t instead of size_t? >>> >>> In glibc we handle this with special use of __need_size_t with GCC's >>> provided stddef.h. >>> >>> For example glibc's signal.h does this: >>> >>> # define __need_size_t >>> # include >> >> Just to make it clear, do you suggest this approach for asm/signal.h as well? The best practice from the glibc community looks like this: (a) Create a bits/types/*.h header for the type you need. e.g. ./time/bits/types/struct_timeval.h ./time/bits/types/struct_itimerspec.h ./time/bits/types/time_t.h ./time/bits/types/struct_timespec.h ./time/bits/types/struct_tm.h ./time/bits/types/clockid_t.h ./time/bits/types/clock_t.h ./time/bits/types/timer_t.h (b) If neccessary the bits/types/*.h header is a wrapper: ~~~ #define __need_size_t #include ~~~ to get access to the compiler provided type. This way all of the code you need simplifies to includes for the types you need. e.g. time/sys/time.h: ... #include #include #include ... This is what we've been doing in glibc starting last September as we cleaned up all the convoluted conditional logic to get the types we needed in the headers that needed them. Cheers, Carlos.