Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752913AbdCBP3t (ORCPT ); Thu, 2 Mar 2017 10:29:49 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:35175 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbdCBP3n (ORCPT ); Thu, 2 Mar 2017 10:29:43 -0500 MIME-Version: 1.0 X-Originating-IP: [65.93.71.239] In-Reply-To: References: <20170226010156.GA28831@altlinux.org> From: "Carlos O'Donell" Date: Thu, 2 Mar 2017 10:22:18 -0500 Message-ID: Subject: Re: [PATCH] uapi: fix asm/signal.h userspace compilation errors To: Arnd Bergmann Cc: "Dmitry V. Levin" , 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 Content-Length: 2016 Lines: 53 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. >> >> On the kernel side size_t is typedef'ed to __kernel_size_t, so >> an alternative fix would be to change the type of sigaltstack.ss_size >> from size_t to __kernel_size_t for all architectures except those where >> sizeof(size_t) < sizeof(__kernel_size_t), namely, x32 and mips n32. >> >> On x32 and mips n32, however, #include seems to be the most >> straightforward way to obtain the definition for sigaltstack.ss_size's >> type. >> >> Signed-off-by: Dmitry V. Levin > > 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 And... /* Any one of these symbols __need_* means that GNU libc wants us just to define one data type. So don't define the symbols that indicate this file's entire job has been done. */ #if (!defined(__need_wchar_t) && !defined(__need_size_t) \ && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \ && !defined(__need_wint_t)) The idea being that the type you want is really defined by stddef.h, but you just one the one type. Changing the fundamental type causes the issues you see in patch v2 where sizeof(size_t) < sizeof(__kernel_size_t). It will only lead to problem substituting the wrong type. Cheers, Carlos.