From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7303 invoked from network); 31 May 2023 14:03:52 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 31 May 2023 14:03:52 -0000 Received: (qmail 10168 invoked by uid 550); 31 May 2023 14:03:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 10130 invoked from network); 31 May 2023 14:03:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=yfDbaf/QVjv3JK7MusbTpk7tzhqZawvRw5crzEFMfAU=; b=p5nxI3ZUsRapKqcCeUNG60WheKyD2taZjFo0aukw4g87OV1cfvDlZCKO rTG0nLDdc/7KZ7jbKJyi/g+AkK8oEfEFp7G5JDMGezkPA0hRuhSdelweb ax4NKmLRMxSFIQsKUURok4mdlTKJS0rn/5EQYfKDm6EZZ8zt+K72RB4VI s=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Jens.Gustedt@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.00,207,1681164000"; d="scan'208";a="57462174" From: Jens Gustedt To: musl@lists.openwall.com Date: Wed, 31 May 2023 16:03:34 +0200 Message-Id: <323b1aaf4c7e31010ead4eae127d0d580f319ce6.1685535458.git.Jens.Gustedt@inria.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [musl] [C23 stdckdint.h 1/1] C23: add the stdckdint.h header for checked integer operations These macros have a direct correspondence to gcc builtins, so the implementation is trivial for compilers that have this. Note that this only intefaces the type-generic features, so no function symbol is added to the library. Since also this is a new header that only exposes its contents when it is explicitly included, no feature test macros are needed. As there are no function symbols added, for the compilation of musl itself this header makes no change. If on the other hand a user uses a macro from this header with a compiler that does not support that functionality, the compilation will fail. --- include/stdckdint.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 include/stdckdint.h diff --git a/include/stdckdint.h b/include/stdckdint.h new file mode 100644 index 00000000..893126dc --- /dev/null +++ b/include/stdckdint.h @@ -0,0 +1,8 @@ +#ifndef __STDC_VERSION_STDCKDINT_H__ +#define __STDC_VERSION_STDCKDINT_H__ 202311L + +#define ckd_add(R, A, B) __builtin_add_overflow ((A), (B), (R)) +#define ckd_sub(R, A, B) __builtin_sub_overflow ((A), (B), (R)) +#define ckd_mul(R, A, B) __builtin_mul_overflow ((A), (B), (R)) + +#endif -- 2.34.1