Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755004AbbGOJdl (ORCPT ); Wed, 15 Jul 2015 05:33:41 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:54065 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754985AbbGOJdj (ORCPT ); Wed, 15 Jul 2015 05:33:39 -0400 From: Arnd Bergmann To: Bamvor Zhang Jian Cc: John Stultz , Thomas Gleixner , y2038@lists.linaro.org, lkml , Baolin Wang Subject: Re: [RFC PATCH v2 1/4] y2038: add 64bit time_t support in timeval for 32bit architecture Date: Wed, 15 Jul 2015 11:33:33 +0200 Message-ID: <1584628.QfGpsYboN5@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <55A5D107.5080604@linaro.org> References: <1435587807-10008-1-git-send-email-bamvor.zhangjian@linaro.org> <1819798.ecaiCVEJzg@wuerfel> <55A5D107.5080604@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:bnNsVuHxv/pbk0umtR+eoKOvxqO1xcikUYJcouSPGKCUAp7unEf Ix0kGWqxsalOfp0AXfQcwu0izjGmBfKZMEzVtSpm0EIDIoMU829iSiFs9pLveOY0UgviX+G HsbPBGatRkAz8ddPKrbUi9f3vM0B+Wl+sAb8LuonFZ6fqNV1AU5YLRhnXo/dEOeFEww1GZm 1xbub1nwgV6UggwJCR+Gw== X-UI-Out-Filterresults: notjunk:1;V01:K0:YoD8YmUYwOA=:ZnxmkeLUwr8BgbTL/nTGiE UJmtVXkDSQeLZYPJpwjaRA98lxrolclMZzfBOfiHvZuZqWlG5PYqC6oedD9eFwQ2OSZzyJdQE eblA8iPkfMKquFKtHBOtVh2ztjllDsWxlP4TR2KN5fx8Ab/AuX5gKoWT2NNoL1FF31WciM7u7 07Y6oWxhO/EUmU3vOFZmD62v8J7du9A/ohouMjsEjO+/ebGrqpEIkd8EtmF4cSwpjJVHfp+jL KfXYyt3Vycmzmowhj3ZIbXPYQVd17ax1TWItmlwXtjvVSjtEdK/UPgUysv0UioGO4pn7Y6c5n vFAwVJEh4YNghCVZjZze5GlkE++LRth9YIiVPzbAI+rapuu4blIa7LFbGBrbkPP6BCjfLLwXl 6V7yz8GNCOU+QzxpxDXp0B8uoG42Pn9eHHtsUpGyTt0BaZesIG1censXwnGKzQagiAttCluCI Ko5++cUJnzgs+TQf20DV9GP1KbLZN8aTB+RoFZ8QcOBW7K50J7W3eh4bqpJU8WPv6kGYnQAup Okmq4Uuu6gmQNbzby3JbyyHS5etY4Sw1DSXzV1E8KtIX3KwT83eke0GizkulgtwznLipCOQqR iDGjWd4Y4EAxOMy9sbuD0lXKZ1SfAbV0L1svta2atII5KgcI1YblKChg/uERDyTnAHUWjOjZU rym2ekShp2ZPS53uPq+Jqn2P/dfYKgbAPrzdvYnaXxCSITA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2467 Lines: 61 On Wednesday 15 July 2015 11:18:31 Bamvor Zhang Jian wrote: > Hi, Arnd > > On 07/09/2015 06:26 PM, Arnd Bergmann wrote: > > On Thursday 09 July 2015 17:02:47 Bamvor Zhang Jian wrote: > >> On 07/09/2015 04:09 AM, John Stultz wrote: > >>> On Mon, Jun 29, 2015 at 7:23 AM, Bamvor Zhang Jian > >>> wrote: > >>>> +int get_timeval64(struct timeval64 *tv, > >>>> + const struct __kernel_timeval __user *utv) > >>>> +{ > >>>> + struct __kernel_timeval ktv; > >>>> + int ret; > >>>> + > >>>> + ret = copy_from_user(&ktv, utv, sizeof(ktv)); > >>>> + if (ret) > >>>> + return -EFAULT; > >>>> + > >>>> + tv->tv_sec = ktv.tv_sec; > >>>> + if (!IS_ENABLED(CONFIG_64BIT) > >>>> +#ifdef CONFIG_COMPAT > >>>> + || is_compat_task() > >>>> +#endif > >>> > >>> These sorts of ifdefs are to be avoided inside of functions. > >> > >>> Instead, it seems is_compat_task() should be defined to 0 in the > >>> !CONFIG_COMPAT case, so you can avoid the ifdefs and the compiler can > >>> still optimize it out. > >> I add this ifdef because I got compile failure on arm platform. This > >> file do not include the directly. And in arm64, > >> compat.h is included implicitily. > >> So, I am not sure what I should do here. Include in > >> this file directly or add a this check at the beginning of this file? > >> > >> #ifndef is_compat_task > >> #define is_compat_task() (0) > >> #endif > >> > > > > Actually I think we can completely skip this test here: Unlike > > timespec, timeval is defined in a way that always lets user space > > use a 64-bit type for the microsecond portion (suseconds_t tv_usec). > > I do not familar with this type. I grep the suseconds_t in glibc, it > seems that suseconds_t(__SUSECONDS_T_TYPE) is defined as > __SYSCALL_SLONG_TYPE which is __SLONGWORD_TYPE(32bit on 32bit > architecture). Correct, but POSIX allows it to be redefined along with time_t, so timeval can be a pair of 64-bit values. In contrast, timespec is required by POSIX (and C11) to be a time_t and a 'long', which is why we need a hack to check the size of the second word of the timespec structure. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/