From patchwork Tue Dec 7 21:48:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 48612 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1634A385803A for ; Tue, 7 Dec 2021 22:04:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1634A385803A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638914658; bh=9N+nxND4wbP8rcXxghvJkA1HBWcqxyCg+kyo22rfseY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ooELOLcOi8d74MkAwacy7uzmm/a79MFq8Tkdzaes90jl+31bxJl4eSUqJAted408H XMzm2oZP1N1QuUnqgy3cq1mphjC0LCf/tG66O+gwfFuqcgCcvc0k64y4EI2KT1mgnR Bieoyeh9LdicK1T0NYPVLDNUZT8HioRO/obLd49w= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 7D45E3858014 for ; Tue, 7 Dec 2021 22:03:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D45E3858014 Received: by mail-wr1-x435.google.com with SMTP id t9so581033wrx.7 for ; Tue, 07 Dec 2021 14:03:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9N+nxND4wbP8rcXxghvJkA1HBWcqxyCg+kyo22rfseY=; b=rrGqty1i+qjo6iWhrNLxkxg+608q8oYX65HYsaK+jWzgdsP14FEzqKrjCg3lGiJpKc jSgvJ2WivY8yMdd8LcSrWszUlt22tYvNwj0exmdhgcoJy/aY8S7owJj4VP3rD7h4sh1D O2Wxz3pGMD+FLcomv/8XVffHQ6cI63sSz1FriRdr3YhAO6aB5W8DYZjDxZyk+hBeIOH5 xegXBv6GMErGypyxfS5c62VpQQVr4LzMLe0bxXl4XHdFl5Hdb+7Y4obdzwlYAiGsqoKi XVWYPQHn5/toFkACJsM7A4ONqr97vjjPalgpZxQVx4QlEjpFq0gwlzMn76SxBavSEoCR CDBg== X-Gm-Message-State: AOAM533vFPSlZaW00YheFe5xqt0kVPbMcQIZl6Zxr+DunOl1AZKVz48X iRD+z8nZWgOB4e190K/P9ZA60eydBXo= X-Google-Smtp-Source: ABdhPJyNJdajAthi4vQ30wJBEav5aNEtFFpPt6+q6qdbkF6L4Yi4eIDTG+Xvz+GMTTyvPlTrAehLhg== X-Received: by 2002:a5d:5850:: with SMTP id i16mr55021768wrf.197.1638914633624; Tue, 07 Dec 2021 14:03:53 -0800 (PST) Received: from sqli.sqli.com ([195.53.121.100]) by smtp.googlemail.com with ESMTPSA id l2sm4276614wmq.42.2021.12.07.14.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 14:03:53 -0800 (PST) To: libc-alpha@sourceware.org Subject: [RFC v2 1/2] sys/types.h: Define new type: snseconds_t Date: Tue, 7 Dec 2021 22:48:14 +0100 Message-Id: <20211207214814.18553-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211207111957.8087-1-alx.manpages@gmail.com> References: <20211207111957.8087-1-alx.manpages@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , Rich Felker , Stefan Puiu , Michael Kerrisk , =?utf-8?b?0L3QsNCx?= , Jakub Wilk , Joseph Myers Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Based on the existing suseconds_t type. The timespec(3) structure uses long for tv_nsec, except if __x86_64__ && __ILP32__, in which case it uses long long. Let's define a stable type that can be relied upon by users, for example for creating pointers. Link: linux-man Link: glibc Cc: наб Cc: Jakub Wilk Cc: Zack Weinberg Cc: Stefan Puiu Cc: Michael Kerrisk (man-pages) Cc: H.J. Lu Cc: Joseph Myers Cc: Rich Felker Signed-off-by: Alejandro Colomar --- Hi, For this RFC I used snseconds_t for simplicity writing the patch, and it helps reviewing it too I think, but it can easily be changed later at once. I'd like some feedback on naming the type nsec_t vs snseconds_t. snseconds_t is more similar to the existing suseconds_t type. However, since there's no unsigned version, having the 's' prefix is slightly weird (not that much, but nsec_t is shorter, and still very readable, in line with C tradition). And if the prefix wasn't there, it would be even worse, since it would create confusion. nsec_t is similar to tv_nsec. bits/typesizes.h | 1 + posix/bits/types.h | 1 + posix/sys/types.h | 5 +++++ sysdeps/mach/hurd/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 1 + 9 files changed, 13 insertions(+) diff --git a/bits/typesizes.h b/bits/typesizes.h index 63564b2fa1..85c093fabb 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -51,6 +51,7 @@ #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE #define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/posix/bits/types.h b/posix/bits/types.h index 2dc63de5c2..c4107f1458 100644 --- a/posix/bits/types.h +++ b/posix/bits/types.h @@ -161,6 +161,7 @@ __STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */ __STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */ __STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */ __STD_TYPE __SUSECONDS64_T_TYPE __suseconds64_t; +__STD_TYPE __SNSECONDS_T_TYPE __snseconds_t; /* Signed count of nanoseconds. */ __STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */ __STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */ diff --git a/posix/sys/types.h b/posix/sys/types.h index 477a45f4af..e8fe2d1ba6 100644 --- a/posix/sys/types.h +++ b/posix/sys/types.h @@ -140,6 +140,11 @@ typedef __suseconds_t suseconds_t; # endif #endif +#ifndef __snseconds_t_defined +typedef __snseconds_t snseconds_t; +# define __snseconds_t_defined +#endif + #define __need_size_t #include diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h index 36adbe09c4..558f9ee597 100644 --- a/sysdeps/mach/hurd/bits/typesizes.h +++ b/sysdeps/mach/hurd/bits/typesizes.h @@ -51,6 +51,7 @@ #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE #define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h index 9bdc925168..d17131cf25 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h @@ -50,6 +50,7 @@ #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __S64_TYPE #define __SUSECONDS64_T_TYPE __S64_TYPE +#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h index c658dfdf60..bb5276b103 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h @@ -64,6 +64,7 @@ #define __CLOCK_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h index 82e77e1e03..c2ba225750 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h @@ -51,6 +51,7 @@ #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE #define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h index 7aaca9757d..cebc057109 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h @@ -51,6 +51,7 @@ #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __S32_TYPE #define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h index 060af056f8..e668755fca 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h @@ -65,6 +65,7 @@ #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SYSCALL_SLONG_TYPE #define __SUSECONDS64_T_TYPE __SQUAD_TYPE +#define __SNSECONDS_T_TYPE __SYSCALL_SLONG_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE