From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by sourceware.org (Postfix) with ESMTPS id DDD203858C56 for ; Mon, 11 Apr 2022 01:09:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DDD203858C56 Received: by mail-io1-xd2a.google.com with SMTP id y65so386259iof.1 for ; Sun, 10 Apr 2022 18:09:19 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=T6oXoLztGmfszUiU1nxrMoNXI418CUNUnAx6+KWkkJs=; b=RQbBRTSAYp/OvOi0Z6Zt3vJoeRBXKcas2MIuTWuJlUxez7e5sa3Ad8C04LvHC6dNiR idWcr52DJtdDcjrFXh8YJAxbjPWWgtvRxzg4zSG0U7UECqDeAXg/HnlaeAjXTOF8eRSy KmTf77oswHjWX+wMG5jIA3dBgtYKzhjCha6FGBMbBO7f2Xr0O9SwvPJ8pdqZn5rAOc+3 am9bIHpBfO7PzimU8pNLXbc/EWtrVk8G3I22jo88jCzhupOa8Kje8JWu3XoRJVbtPluq 0zRXdNwGOB3Q3K6X/PF4qFwEb/yF765yNDWE2WFNG0FYfinxa4ZumjI9gt7RuZuXi66+ vM7Q== X-Gm-Message-State: AOAM530cVe+GaA26nfrRV2oV09mDc2bytpl+L7fMaSwJYtoTn6GBICeL f/qAlDCBxXHl0aVBQp2KFwHgJ0XsR3s= X-Google-Smtp-Source: ABdhPJxPsF5hWwQr0j0Z4d3I1xnQ0CWxKrVVJAbeLwaixjsJwt6TNsjrMefkUwDg6x69OTUg4te9vg== X-Received: by 2002:a5d:8a09:0:b0:64c:96af:2c29 with SMTP id w9-20020a5d8a09000000b0064c96af2c29mr12462474iod.171.1649639358931; Sun, 10 Apr 2022 18:09:18 -0700 (PDT) Received: from localhost.localdomain ([173.245.202.36]) by smtp.googlemail.com with ESMTPSA id g14-20020a056602150e00b0064d30c94155sm5291114iow.37.2022.04.10.18.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 18:09:18 -0700 (PDT) From: Noah Goldstein To: libc-alpha@sourceware.org Subject: [PATCH v1 1/2] stdlib: Refactor {u}int_fast defs in stdint Date: Sun, 10 Apr 2022 20:09:12 -0500 Message-Id: <20220411010913.1061799-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Mon, 11 Apr 2022 01:09:22 -0000 The goal is to make it easier to provide system specific defs for the sizes of {u}int_fast{8|16|32|64}. Note this commit does not change any of the previous values. Full xcheck passes on x86_64. --- stdlib/stdint.h | 70 +----------------------- sysdeps/generic/int-fast.h | 107 +++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 69 deletions(-) create mode 100644 sysdeps/generic/int-fast.h diff --git a/stdlib/stdint.h b/stdlib/stdint.h index 2d666f79fd..00f41e9ffb 100644 --- a/stdlib/stdint.h +++ b/stdlib/stdint.h @@ -52,35 +52,6 @@ typedef __uint_least32_t uint_least32_t; typedef __uint_least64_t uint_least64_t; -/* Fast types. */ - -/* Signed. */ -typedef signed char int_fast8_t; -#if __WORDSIZE == 64 -typedef long int int_fast16_t; -typedef long int int_fast32_t; -typedef long int int_fast64_t; -#else -typedef int int_fast16_t; -typedef int int_fast32_t; -__extension__ -typedef long long int int_fast64_t; -#endif - -/* Unsigned. */ -typedef unsigned char uint_fast8_t; -#if __WORDSIZE == 64 -typedef unsigned long int uint_fast16_t; -typedef unsigned long int uint_fast32_t; -typedef unsigned long int uint_fast64_t; -#else -typedef unsigned int uint_fast16_t; -typedef unsigned int uint_fast32_t; -__extension__ -typedef unsigned long long int uint_fast64_t; -#endif - - /* Types for `void *' pointers. */ #if __WORDSIZE == 64 # ifndef __intptr_t_defined @@ -148,37 +119,7 @@ typedef __uintmax_t uintmax_t; # define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) -/* Minimum of fast signed integral types having a minimum size. */ -# define INT_FAST8_MIN (-128) -# if __WORDSIZE == 64 -# define INT_FAST16_MIN (-9223372036854775807L-1) -# define INT_FAST32_MIN (-9223372036854775807L-1) -# else -# define INT_FAST16_MIN (-2147483647-1) -# define INT_FAST32_MIN (-2147483647-1) -# endif -# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) -/* Maximum of fast signed integral types having a minimum size. */ -# define INT_FAST8_MAX (127) -# if __WORDSIZE == 64 -# define INT_FAST16_MAX (9223372036854775807L) -# define INT_FAST32_MAX (9223372036854775807L) -# else -# define INT_FAST16_MAX (2147483647) -# define INT_FAST32_MAX (2147483647) -# endif -# define INT_FAST64_MAX (__INT64_C(9223372036854775807)) - -/* Maximum of fast unsigned integral types having a minimum size. */ -# define UINT_FAST8_MAX (255) -# if __WORDSIZE == 64 -# define UINT_FAST16_MAX (18446744073709551615UL) -# define UINT_FAST32_MAX (18446744073709551615UL) -# else -# define UINT_FAST16_MAX (4294967295U) -# define UINT_FAST32_MAX (4294967295U) -# endif -# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) +#include /* Values to test for integral types holding `void *' pointer. */ @@ -293,15 +234,6 @@ typedef __uintmax_t uintmax_t; # define INT_LEAST64_WIDTH 64 # define UINT_LEAST64_WIDTH 64 -# define INT_FAST8_WIDTH 8 -# define UINT_FAST8_WIDTH 8 -# define INT_FAST16_WIDTH __WORDSIZE -# define UINT_FAST16_WIDTH __WORDSIZE -# define INT_FAST32_WIDTH __WORDSIZE -# define UINT_FAST32_WIDTH __WORDSIZE -# define INT_FAST64_WIDTH 64 -# define UINT_FAST64_WIDTH 64 - # define INTPTR_WIDTH __WORDSIZE # define UINTPTR_WIDTH __WORDSIZE diff --git a/sysdeps/generic/int-fast.h b/sysdeps/generic/int-fast.h new file mode 100644 index 0000000000..554593d393 --- /dev/null +++ b/sysdeps/generic/int-fast.h @@ -0,0 +1,107 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _INT_FAST_H +#define _INT_FAST_H 1 + +#define __PRIMITIVE_INT_FAST_CAT(X, Y) X##Y +#define __INT_FAST_CAT(X, Y) __PRIMITIVE_INT_FAST_CAT (X, Y) + +#ifndef __HAS_INT_FAST_DEFS + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +#if __WORDSIZE == 64 +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +#else +typedef int int_fast16_t; +typedef int int_fast32_t; +__extension__ +typedef long long int int_fast64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +#else +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +__extension__ +typedef unsigned long long int uint_fast64_t; +#endif + +/* Base types for INT_FAST{SIZE}. */ +# define __INT_FAST8_BASE INT8 +# if __WORDSIZE == 64 +# define __INT_FAST16_BASE INT64 +# define __INT_FAST32_BASE INT64 +# else +# define __INT_FAST16_BASE INT32 +# define __INT_FAST32_BASE INT32 +# endif +# define __INT_FAST64_BASE INT64 + +# define __UINT_FAST8_BASE UINT8 +# if __WORDSIZE == 64 +# define __UINT_FAST16_BASE UINT64 +# define __UINT_FAST32_BASE UINT64 +# else +# define __UINT_FAST16_BASE UINT32 +# define __UINT_FAST32_BASE UINT32 +# endif +# define __UINT_FAST64_BASE UINT64 + +#endif + +/* Minimum of fast signed integral types having a minimum size. */ +#define INT_FAST8_MIN __INT_FAST_CAT (__INT_FAST8_BASE, _MIN) +#define INT_FAST16_MIN __INT_FAST_CAT (__INT_FAST16_BASE, _MIN) +#define INT_FAST32_MIN __INT_FAST_CAT (__INT_FAST32_BASE, _MIN) +#define INT_FAST64_MIN __INT_FAST_CAT (__INT_FAST64_BASE, _MIN) + +/* Maximum of fast signed integral types having a minimum size. */ +#define INT_FAST8_MAX __INT_FAST_CAT (__INT_FAST8_BASE, _MAX) +#define INT_FAST16_MAX __INT_FAST_CAT (__INT_FAST16_BASE, _MAX) +#define INT_FAST32_MAX __INT_FAST_CAT (__INT_FAST32_BASE, _MAX) +#define INT_FAST64_MAX __INT_FAST_CAT (__INT_FAST64_BASE, _MAX) + +/* Maximum of fast unsigned integral types having a minimum size. */ +#define UINT_FAST8_MAX __INT_FAST_CAT (__UINT_FAST8_BASE, _MAX) +#define UINT_FAST16_MAX __INT_FAST_CAT (__UINT_FAST16_BASE, _MAX) +#define UINT_FAST32_MAX __INT_FAST_CAT (__UINT_FAST32_BASE, _MAX) +#define UINT_FAST64_MAX __INT_FAST_CAT (__UINT_FAST64_BASE, _MAX) + + +#define INT_FAST8_WIDTH __INT_FAST_CAT (__INT_FAST8_BASE, _WIDTH) +#define INT_FAST16_WIDTH __INT_FAST_CAT (__INT_FAST16_BASE, _WIDTH) +#define INT_FAST32_WIDTH __INT_FAST_CAT (__INT_FAST32_BASE, _WIDTH) +#define INT_FAST64_WIDTH __INT_FAST_CAT (__INT_FAST64_BASE, _WIDTH) + +#define UINT_FAST8_WIDTH __INT_FAST_CAT (__UINT_FAST8_BASE, _WIDTH) +#define UINT_FAST16_WIDTH __INT_FAST_CAT (__UINT_FAST16_BASE, _WIDTH) +#define UINT_FAST32_WIDTH __INT_FAST_CAT (__UINT_FAST32_BASE, _WIDTH) +#define UINT_FAST64_WIDTH __INT_FAST_CAT (__UINT_FAST64_BASE, _WIDTH) + +#endif -- 2.25.1