From patchwork Fri Dec 14 00:15:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10730157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1C2413BF for ; Fri, 14 Dec 2018 00:16:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E39142CDFD for ; Fri, 14 Dec 2018 00:16:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D80EF2CEF2; Fri, 14 Dec 2018 00:16:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70CE22CDFD for ; Fri, 14 Dec 2018 00:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728625AbeLNAQF (ORCPT ); Thu, 13 Dec 2018 19:16:05 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:44927 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbeLNAQF (ORCPT ); Thu, 13 Dec 2018 19:16:05 -0500 Received: by mail-ed1-f67.google.com with SMTP id y56so3526882edd.11 for ; Thu, 13 Dec 2018 16:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gkEF+hrKL7ZaRgboO4BwLI/FOPz1/BegKMsP7rmPJGw=; b=JYYdxAPpDX/XCvk919Q/fYyEM5K5QIRH2jdeNH9zVvxtqVL5FaPvx0PGq/2eGz4i3j 2b3Rh83eTGt2NXtiu2MdXGsp239IBygovVx7jxuA9hQ31ZqrAJUmeIk+ZBfn9lqVIdbv i5+dNzD1dML4ZZkAH1rEpzFTZkJbEal9QzdkzckrmrwfhoNhP+9NETWCP/H7QySi4RuM mL4QJLaLKHMkDtu+k9e23gnVb7HMucgMaGdMYFMbHKnshuqJPiNqmQFnGYh/Z+Ji1OT6 jQREp4uuTDUaL4GDwfxrhLFNrn8Fs3xomY5br0ILayQvuuwBTdCDtOMq0f2ocTk0+FBm K3JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gkEF+hrKL7ZaRgboO4BwLI/FOPz1/BegKMsP7rmPJGw=; b=JyncjG55hZOW6Nx1MyJ+ZI/SD3pf/F7rEFeubAl/+GkgFmVholVMPFTQ/Z3BGdyIr8 //u1zuuQ9fwpjEXVU4YUYo8uUZEthjAuaYwRrCDSifJMw1ZdkZgfYVAqojpBrbrBiEmr XGFyn9ut1c+eipqCSFz3xolRj/9v2Eq5zrnaY3kJqcGUOFngQTBnVrJGZSMI5Q4PuuGV n/Hi6tjmXP2/T2fLJd+QOW0f8HfR8MWvlTWX1FBI6P42mOqZqcLo22ouwPDu8AGAHtyD s3my9Xn8FoYfqbmcKQXOPsRdTfABwZyHeD9jcwiaxfNK6l312BWXqVN1U5G+BMlmalvW /clw== X-Gm-Message-State: AA+aEWZ2v9YarmEPzpDGS/TunVyrF9D1nSKx2jofMP48b1gpm5WEcLvW eVkpCUhI316WGSoPPMACvO558Dbi X-Google-Smtp-Source: AFSGD/WgC4J7oac1MYfe3uJscKpEQnwm8ajrs3RTvJrg8PdLdlI3gfRn1im16xlQ4jmtSwwCA7YlJg== X-Received: by 2002:a50:9a83:: with SMTP id p3mr1062880edb.279.1544746562694; Thu, 13 Dec 2018 16:16:02 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:4081:8a00:5930:404c:ddbe:1aaf]) by smtp.gmail.com with ESMTPSA id f20sm986489edf.19.2018.12.13.16.16.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:16:02 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 17/19] add predefined macros for [u]int32_t Date: Fri, 14 Dec 2018 01:15:34 +0100 Message-Id: <20181214001536.6259-18-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214001536.6259-1-luc.vanoostenryck@gmail.com> References: <20181214001536.6259-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These are a pain. All LP64 archs use [u]int. Good. But some LP32 archs use [u]int and some others use [u]long. Some even use [u]int for some ABI and [u]loing for some others (bare metal). This really need to be target-specific to be correct. Signed-off-by: Luc Van Oostenryck --- lib.c | 10 ++++++++++ target.c | 19 +++++++++++++++++++ target.h | 2 ++ validation/preprocessor/predef.c | 2 ++ 4 files changed, 33 insertions(+) diff --git a/lib.c b/lib.c index f9015ef35..3084b6197 100644 --- a/lib.c +++ b/lib.c @@ -476,6 +476,14 @@ static void handle_arch_m64_finalize(void) goto case_x86_64; case ARCH_LP32: /* default values */ +#if defined(__m68k__) \ + || ((defined(__sparc__) || defined(__sparc)) && !defined(__sparc_v9__)) \ + || defined(__mips__) || defined(__mips) \ + || defined(__powerpc__) || defined(__PPC__) || defined(PPC) \ + || defined(__riscv__) || defined(__riscv) + int32_ctype = &long_ctype; + uint32_ctype = &ulong_ctype; +#endif int64_ctype = &llong_ctype; uint64_ctype = &ullong_ctype; intmax_ctype = &llong_ctype; @@ -1251,6 +1259,8 @@ static void predefined_macros(void) predefined_ctype("UINT8", &uchar_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("INT16", &short_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("UINT16", &ushort_ctype, PTYPE_MAX|PTYPE_TYPE); + predefined_ctype("INT32", int32_ctype, PTYPE_MAX|PTYPE_TYPE); + predefined_ctype("UINT32", uint32_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("INT64", int64_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("UINT64", uint64_ctype, PTYPE_MAX|PTYPE_TYPE); diff --git a/target.c b/target.c index fe3756f80..ad12b630c 100644 --- a/target.c +++ b/target.c @@ -10,6 +10,8 @@ struct symbol *intmax_ctype = &llong_ctype; struct symbol *uintmax_ctype = &ullong_ctype; struct symbol *int64_ctype = &long_ctype; struct symbol *uint64_ctype = &ulong_ctype; +struct symbol *int32_ctype = &int_ctype; +struct symbol *uint32_ctype = &uint_ctype; struct symbol *wchar_ctype = &int_ctype; struct symbol *wint_ctype = &uint_ctype; @@ -74,6 +76,23 @@ void init_target(void) break; } + switch (arch_mach) { + case MACH_MIPS64: + if (arch_m64 == ARCH_LP64) + break; + /* fall through */ + case MACH_M68K: + case MACH_SPARC32: + case MACH_PPC32: + case MACH_MIPS32: + case MACH_RISCV32: + int32_ctype = &long_ctype; + uint32_ctype = &ulong_ctype; + break; + default: + break; + } + #if defined(__FreeBSD__) || defined(__APPLE__) wint_ctype = &int_ctype; #endif diff --git a/target.h b/target.h index 7b1d96498..8bbe494f8 100644 --- a/target.h +++ b/target.h @@ -7,6 +7,8 @@ extern struct symbol *intmax_ctype; extern struct symbol *uintmax_ctype; extern struct symbol *int64_ctype; extern struct symbol *uint64_ctype; +extern struct symbol *int32_ctype; +extern struct symbol *uint32_ctype; extern struct symbol *wchar_ctype; extern struct symbol *wint_ctype; diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index f00a471fc..5678acedf 100644 --- a/validation/preprocessor/predef.c +++ b/validation/preprocessor/predef.c @@ -21,6 +21,8 @@ int test(void) TEST_MAX(UINT8, 0xffU); TEST_MAX( INT16, 0x7fff); TEST_MAX(UINT16, 0xffffU); + TEST_MAX( INT32, 0x7fffffff); + TEST_MAX(UINT32, 0xffffffffU); TEST_MAX( INT64, 0x7fffffffffffffffLL); TEST_MAX(UINT64, 0xffffffffffffffffULL); TEST_SMAX(INTMAX, __INTMAX_TYPE__);