From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id C7FCB3858424 for ; Wed, 8 Dec 2021 15:47:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7FCB3858424 Received: by mail-wm1-x335.google.com with SMTP id j140-20020a1c2392000000b003399ae48f58so4454126wmj.5 for ; Wed, 08 Dec 2021 07:47:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=l1dCvdIhIfXopnah+yZdqwfQRuAb8/Y8egSlDGSw9AA=; b=nVxJG39Y5sT8rdqWAldr2nAlkfEp+aIhj9pqF2t534oOTkapfiOtq1sra9oLkw8Duc PbT3XRbOtyMSZ+D77qLR63p8eDc7fAkHf0QeumK4IsRekYfSJYD6GKMEZNQOYLdJ3+Ea 9xOwV+OxqTYTlmOEz1idFumZ3oC2iBgxPmGckIWsyP6oevGi2T1oH7c1jaAsCEiAs0Q1 OpimJkqJKLQdlo43BuJpIugoWAamLIrA0lg+6BPG7aHe0AIcBunMOqsOh6tMsc7SRGtN yb60Ev860x6mMSvtaKANscbl7jWS7OTcRCzqsSZ6viP0oFX4bl6a+0GkgQpDsT0gBpX7 xcQQ== X-Gm-Message-State: AOAM533MOznqFh0HSUBS06czI7yu2X2s1KMhRRXP83UZEoXii5mgqAf6 CDijb3WJccttWupSdbOtak5te2W8bfc= X-Google-Smtp-Source: ABdhPJywSwaUPML2Q7qyPLvUzWtZTeZ8iLokfp1uQH+COdvryDcQ3BlLLlBSYsxRITWJ33XFlltPSg== X-Received: by 2002:a1c:1dd6:: with SMTP id d205mr16665928wmd.77.1638978444816; Wed, 08 Dec 2021 07:47:24 -0800 (PST) Received: from [10.8.0.26] ([195.53.121.100]) by smtp.gmail.com with ESMTPSA id e7sm4137209wrg.31.2021.12.08.07.47.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Dec 2021 07:47:24 -0800 (PST) Message-ID: Date: Wed, 8 Dec 2021 16:47:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [RFC v3 2/3] sys/types.h: struct timespec: Use __snseconds_t for tv_nsec Content-Language: en-US To: Joseph Myers , Zack Weinberg Cc: libc-alpha@sourceware.org, =?UTF-8?B?0L3QsNCx?= , Jakub Wilk , Stefan Puiu , Michael Kerrisk , "H . J . Lu" , Rich Felker , Andreas Schwab , Paul Eggert References: <20211207111957.8087-1-alx.manpages@gmail.com> <20211208144757.37641-2-alx.manpages@gmail.com> From: "Alejandro Colomar (man-pages)" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Dec 2021 15:47:27 -0000 On 12/8/21 16:24, Joseph Myers wrote: > On Wed, 8 Dec 2021, Zack Weinberg wrote: > >> On Wed, Dec 8, 2021, at 9:47 AM, Alejandro Colomar wrote: >>> >>> Use __snseconds_t to simplify the definition of struct timespec. >> ... >>> #if __WORDSIZE == 64 \ >>> || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \ >>> || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64) >>> - __syscall_slong_t tv_nsec; /* Nanoseconds. */ >>> + __snseconds_t tv_nsec; /* Nanoseconds. */ >> >> All my grousing about spec bugs aside, the _point_ of having tv_nsec's >> type be a typedef is that it ought to be possible to make this >> preprocessor conditional (and the rest of the cases in the same if-else >> chain) less hairy. Can you look into that please? > > The question about whether there is padding around tv_nsec is a separate > one to what the type of tv_nsec is. I don't see how you can avoid the > conditionals related to padding, which is what these conditionals are > about. And the preprocessor doesn't readily lend itself to saying "if > tv_sec is 64-bit and tv_nsec is 32-bit" to describe when padding is > involved. > How about defining _WIDTH macros for integral types (mirroring C2X _WIDTH macros)? That way we could make use of them to make these ifdefs simpler. I guess it would be something like #if __SNSECONDS_WIDTH == 32 && __TIME_WIDTH == 64 ... Would this make sense? Thanks, Alex -- Alejandro Colomar Linux man-pages maintainer; https://www.kernel.org/doc/man-pages/