From patchwork Wed Dec 8 14:48:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1565250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=rcg/19Os; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8Kqp6qP7z9ssD for ; Thu, 9 Dec 2021 01:51:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D74503858426 for ; Wed, 8 Dec 2021 14:51:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D74503858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638975092; bh=ob/Z2x9bJNm80GLo9Z3R4OVJPw2nJ58yKvUGmgvhrbk=; 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=rcg/19OsWomvPdSR+qMKw99BG81h5FrugbEvKROgPlDchaAlM6iwhxR+T53Bn7NjM yP9awnq6D++cnt7uVIe5JxEdBAHl02Mz0PmrnDKJ2VOwB2hJ3rT2HO5B+fg6CmkvMT X+k4/3TpJcHZ/G0s1U+rnDq7BxeJd84FyRKSKtvQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 15F6A3858D3C for ; Wed, 8 Dec 2021 14:51:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 15F6A3858D3C Received: by mail-wm1-x330.google.com with SMTP id p18so1944369wmq.5 for ; Wed, 08 Dec 2021 06:51:18 -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=ob/Z2x9bJNm80GLo9Z3R4OVJPw2nJ58yKvUGmgvhrbk=; b=H+FQS5FB678Uq41UT5fIzL+HOqsl6KhyA3yfIJjG+mu/tw2bqLLcNb1e6vyOtpTocp 0KJyRiQjSE+zUeeUw4pJBNQO6TLrZt+DyqYGzXICbmtwo3OzU6e3PzVivjd3987FP+DV hdIK0B9LsQeGGN5EM+XPfLknQ4FzyxXLtGE+g8viSU7SSmdbnOOQU/y3V1EcLzP1oLPz Lr7pkSmAqL76yT1pm0EbjVlDlQSJOhgRorKlTE65LOJvGyghUXiT0pZSznKlG1eUgs8X 8UB2/jGvFtgexAxNDAHMtBs+F8buSaWGmBXfMoLQhShm6ryNHI7/v2RXcMKToXLgy9YV M1Ag== X-Gm-Message-State: AOAM5305MB7iA6hPAAUGTwjvCK+v79OrkbMx3fKS7siDTRfEd1ghLPEt K6203Ec+OvNk4czIWll4Yqd9lODDkr8= X-Google-Smtp-Source: ABdhPJyp8SlNo9mVxV6yywODlAC4rJVbBXZmDLOXYY3rxr/AF2hSw5nVp10x2JxJn8HFAY06BS5IZQ== X-Received: by 2002:a05:600c:500b:: with SMTP id n11mr16751558wmr.38.1638975077194; Wed, 08 Dec 2021 06:51:17 -0800 (PST) Received: from sqli.sqli.com ([195.53.121.100]) by smtp.googlemail.com with ESMTPSA id a9sm2990660wrt.66.2021.12.08.06.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 06:51:16 -0800 (PST) To: libc-alpha@sourceware.org Subject: [RFC v3 3/3] sys/types.h: Make snseconds_t user visible Date: Wed, 8 Dec 2021 15:48:00 +0100 Message-Id: <20211208144757.37641-3-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 , Andreas Schwab , Michael Kerrisk , =?utf-8?b?0L3QsNCx?= , Jakub Wilk , Joseph Myers Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Use a type that can be relied upon by users, for example for creating pointers. It is backwards compatible, as it is defined to be long whenever it can, and it makes the underlying type opaque, since the user never had a need to know what it is. First of all, this simplifies the implementation, allowing a different underlying type in kernel and in user space. The user only needs to know that it can hold [0, 999'999'999], and it's a signed type. To print it, casting to long or to intmax_t (or even int when it's 32-bit) should be safe. Using long was too specific of a contract with programmers. Using snseconds_t in user code adds extra readability to the code, since long is both meaningless and also unnecessarily explicit. 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 Cc: Andreas Schwab Cc: Paul Eggert Signed-off-by: Alejandro Colomar --- posix/sys/types.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/posix/sys/types.h b/posix/sys/types.h index 477a45f4af..dae71f92b7 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