From patchwork Fri Dec 14 00:15:18 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: 10730125 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 5020F13AF for ; Fri, 14 Dec 2018 00:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41ABB2CDFD for ; Fri, 14 Dec 2018 00:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3601E2CEE6; Fri, 14 Dec 2018 00:15:48 +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 D53142CDFD for ; Fri, 14 Dec 2018 00:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727638AbeLNAPr (ORCPT ); Thu, 13 Dec 2018 19:15:47 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:42074 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeLNAPr (ORCPT ); Thu, 13 Dec 2018 19:15:47 -0500 Received: by mail-ed1-f65.google.com with SMTP id j6so3531206edp.9 for ; Thu, 13 Dec 2018 16:15:46 -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=UqE48cTlwuS18BRG2TAxkirWSAEL3sT8CNQLWzlwcls=; b=rvtu4VwePhX1THOi5neMTfLPhGKHjMN5gUGW6t2ecKLGo3JmdiAy3f8cW7mFhwLCDw pdbHJzZGtFkn5NG0c5rnh+KBGmDO/KyBxmz2RDufwwmF5WHO574XrNanbmyPopsIxLGp 5B/nJPJrGyZd+DVJyaaExaG642REZIuUHtORTa/F+8IDZ3Ljfb2e+NjbRzF6Z7nFOR1g rMvvYvJmDCKxVC1FoPi/riEoI2YocO9BHo2K7kXiPYCinVIiYLCo3JL6J1Cbqk6r3Hdh zvxQ0aXUti7WbMI2OnDF56fAaljiyxDcHTP7cw01hEuKNdEcFP95/szRQsmpH0JYESg7 XDJg== 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=UqE48cTlwuS18BRG2TAxkirWSAEL3sT8CNQLWzlwcls=; b=HoOXVyCRTb5yn+QREHSFIPtS/5Ov+yhVgR46OjGffTWwPZ+/GmFGJ1Y1hwwEnhg8pt 04ROCZKMAo/LeXYHbHIErYWNH9X1Ad13E0DHVWDvVuy77jcBtpc/oZSMer7TMi8lnMF4 9cjLq8GJx3LyMMh8W8vNYPd/8hMMoRiCoSbNZtus0f+LluNdDnxMZP/MycJL9lmfHxHu dcxNm5xFGHjzQkp+Dc5bP77mxYRZLyyhYArAFec8ybWHEnilwU5jNAObcsS+yMrlP50V plj02wcLu+59CCgCtc3LL6bwP9BZxs8sl6eWSX4PUS4122ZLrJU3dJNKNzHNwqQGQDZ3 qjug== X-Gm-Message-State: AA+aEWaIlVecT4XkwnkbSdhKJFsif0sIxUQ0UCebrfiifxjCNtLmXtWM B0okz9dGvc9Mx+QZG0j4RKz1F/8x X-Google-Smtp-Source: AFSGD/WnS4XLStKLTZO4XpFZhnHEa6micL9W9So7TDS+N6BeBJ5NteazXbC2HaFMG54Ip5MNsyJpYA== X-Received: by 2002:a17:906:5118:: with SMTP id w24-v6mr837712ejk.215.1544746545266; Thu, 13 Dec 2018 16:15:45 -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.15.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:44 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 01/19] add detection of native platform Date: Fri, 14 Dec 2018 01:15:18 +0100 Message-Id: <20181214001536.6259-2-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 The underlying type of most builtin types (size_t, int32_t, ...), as well as their size, the endianness and other parameters are platform dependent. The minimal is to have these parameters correct on the native machine. Use the diffrent predefined macros to detect the native machine. Signed-off-by: Luc Van Oostenryck --- machine.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 machine.h diff --git a/machine.h b/machine.h new file mode 100644 index 000000000..a01cdc207 --- /dev/null +++ b/machine.h @@ -0,0 +1,54 @@ +#ifndef MACHINE_H +#define MACHINE_H + +enum machine { + MACH_ARM, + MACH_ARM64, + MACH_I386, + MACH_X86_64, + MACH_MIPS32, + MACH_MIPS64, + MACH_PPC32, + MACH_PPC64, + MACH_RISCV32, + MACH_RISCV64, + MACH_SPARC32, + MACH_SPARC64, + MACH_M68K, + MACH_S390X, + MACH_UNKNOWN +}; + +#if defined(__aarch64__) +#define MACH_NATIVE MACH_ARM64 +#elif defined(__arm__) +#define MACH_NATIVE MACH_ARM +#elif defined(__x86_64__) || defined(__x86_64) +#define MACH_NATIVE MACH_X86_64 +#elif defined(__i386__) || defined(__i386) +#define MACH_NATIVE MACH_I386 +#elif defined(__mips64__) || (defined(__mips) && __mips == 64) +#define MACH_NATIVE MACH_MIPS64 +#elif defined(__mips__) || defined(__mips) +#define MACH_NATIVE MACH_MIPS32 +#elif defined(__powerpc64__) || defined(__ppc64__) +#define MACH_NATIVE MACH_PPC64 +#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) +#define MACH_NATIVE MACH_PPC32 +#elif defined(__riscv) && (__riscv_xlen == 64) +#define MACH_NATIVE MACH_RISCV64 +#elif defined(__riscv) && (__riscv_xlen == 32) +#define MACH_NATIVE MACH_RISCV32 +#elif defined(__sparc_v9__) +#define MACH_NATIVE MACH_SPARC64 +#elif defined(__sparc__) || defined(__sparc) +#define MACH_NATIVE MACH_SPARC32 +#elif defined(__m68k__) +#define MACH_NATIVE MACH_68K +#elif defined(__s390x__) || defined(__zarch__) +#define MACH_NATIVE MACH_S390X +#else +#define MACH_NATIVE MACH_UNKNOWN +#endif + +#endif From patchwork Fri Dec 14 00:15:19 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: 10730127 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 2EA9F13BF for ; Fri, 14 Dec 2018 00:15:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2138F2CDFD for ; Fri, 14 Dec 2018 00:15:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 159292CEF2; Fri, 14 Dec 2018 00:15:49 +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 A8BF72CDFD for ; Fri, 14 Dec 2018 00:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727757AbeLNAPs (ORCPT ); Thu, 13 Dec 2018 19:15:48 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35516 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbeLNAPs (ORCPT ); Thu, 13 Dec 2018 19:15:48 -0500 Received: by mail-ed1-f67.google.com with SMTP id x30so3576679edx.2 for ; Thu, 13 Dec 2018 16:15:47 -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=kHUDZ2zEefV3ujO+3YTqb57QwdJWxxjn64jkYV4CrFI=; b=fzOaXAi3A3Ejq0AGBpqWVsq89MJOe02QyMrzp11maQWl2Kk/qmoNEk4S0NEFRS79qX qxDss4IE0wp5zwyhouvEoJ/H0hw1ACs8lc21ATezkqJM3sSoGV0ONs5xqdx32xs6F8lp kbposl+KrHRJAKYS3UvSx1qx8hrU/7EaYMI8DzAHIXbFkte/gjR7t3SrPTLMnJAHMbZW L+Fs9XyVz/IH+EcfI3oiMIUjd8QQ4ys1YyDJZ2JU9mxfxpcjayzqiIGqu33gW/q67gUK DFfZHmjS2zmW36U5kSbxIlTr4kbcZbNTpHJQyLx8kCJmJ3rS8gIOpUrfMnYNo/XobzKd 3dSQ== 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=kHUDZ2zEefV3ujO+3YTqb57QwdJWxxjn64jkYV4CrFI=; b=rzOsJVPtJbWBoG05Fbs0sTfNIWhxOnmBQAxKkPJWB0g7qLBjXgKcF2EKlUFdWabtiI XsSaCOc55LodTXmFX5IDnmFR2YZ4NOXIVLqTlm24fwFd2tae5aCDUidfdmRnodINDq7r iGWrSVvN1VxIi4tb9Mc2Jlc4V3pkn3PMhip9ZM9p0274owIdHaEbePRam1NIdbhrqe9y zBXx1ZAjhCaKGUSgL1hz1+F/mmVI+ACKh5y/NnFxvnwjzX9PQAnimdYAcgz9BRL+XyKG k4xvSgAPA9+23jJOAa7N8/BDAEwBAHKl9Q+u5wtLG6m/3s5YCqPTDo6OVRBSLx/pejr4 JO6Q== X-Gm-Message-State: AA+aEWamYHcCitpBfvmtnoIy+VpnWYk41ghYk7rdFINFvTRIdT+t4mdz EeUR9S6HehkPRMxl1/1vU/fqqdUE X-Google-Smtp-Source: AFSGD/XajiNEAiHiml/yfUHZOPsrR0V0ilntQBmNAKa7ARnmqY+7IB+MtjnmiX2q+Gsjmh5Tt8Uv8w== X-Received: by 2002:a50:89e1:: with SMTP id h30mr1122011edh.28.1544746546310; Thu, 13 Dec 2018 16:15:46 -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.15.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:45 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 02/19] Consolidate 'machine detection' into "machine.h" Date: Fri, 14 Dec 2018 01:15:19 +0100 Message-Id: <20181214001536.6259-3-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 The file "lib.c' contains some defines and have some #ifdefery to detect the data model of the native machine (LP32/LP64). Same for the native endianness. Move these into "machine.h" where the platform detection is already done. Signed-off-by: Luc Van Oostenryck --- lib.c | 22 +--------------------- machine.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib.c b/lib.c index 5c2059f23..e205eb213 100644 --- a/lib.c +++ b/lib.c @@ -44,6 +44,7 @@ #include "scope.h" #include "linearize.h" #include "target.h" +#include "machine.h" #include "version.h" int verbose, optimize_level, optimize_size, preprocessing; @@ -312,29 +313,8 @@ static enum { STANDARD_C89, STANDARD_GNU89, STANDARD_GNU99, } standard = STANDARD_GNU89; -enum { - ARCH_LP32, - ARCH_X32, - ARCH_LP64, - ARCH_LLP64, -}; - -#ifdef __LP64__ -#define ARCH_M64_DEFAULT ARCH_LP64 -#elif defined(__x86_64__) || defined(__x86_64) -#define ARCH_M64_DEFAULT ARCH_X32 -#else -#define ARCH_M64_DEFAULT ARCH_LP32 -#endif - int arch_m64 = ARCH_M64_DEFAULT; int arch_msize_long = 0; - -#ifdef __BIG_ENDIAN__ -#define ARCH_BIG_ENDIAN 1 -#else -#define ARCH_BIG_ENDIAN 0 -#endif int arch_big_endian = ARCH_BIG_ENDIAN; diff --git a/machine.h b/machine.h index a01cdc207..1eacb556e 100644 --- a/machine.h +++ b/machine.h @@ -1,6 +1,29 @@ #ifndef MACHINE_H #define MACHINE_H +#ifdef __BIG_ENDIAN__ +#define ARCH_BIG_ENDIAN 1 +#else +#define ARCH_BIG_ENDIAN 0 +#endif + + +enum { + ARCH_LP32, + ARCH_X32, + ARCH_LP64, + ARCH_LLP64, +}; + +#ifdef __LP64__ +#define ARCH_M64_DEFAULT ARCH_LP64 +#elif defined(__x86_64__) || defined(__x86_64) +#define ARCH_M64_DEFAULT ARCH_X32 +#else +#define ARCH_M64_DEFAULT ARCH_LP32 +#endif + + enum machine { MACH_ARM, MACH_ARM64, From patchwork Fri Dec 14 00:15:20 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: 10730129 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 75AE213BF for ; Fri, 14 Dec 2018 00:15:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6885A2CDFD for ; Fri, 14 Dec 2018 00:15:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CD212CEF2; Fri, 14 Dec 2018 00:15:50 +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 178302CDFD for ; Fri, 14 Dec 2018 00:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727928AbeLNAPt (ORCPT ); Thu, 13 Dec 2018 19:15:49 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33602 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeLNAPt (ORCPT ); Thu, 13 Dec 2018 19:15:49 -0500 Received: by mail-ed1-f66.google.com with SMTP id p6so3577225eds.0 for ; Thu, 13 Dec 2018 16:15:48 -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=W9GYgiFgUScl/SG5jFxQrPteYgOlrD//gIQul0pVOes=; b=SzcIMsqkrPMoMLYEi05Dg6c8j3CceZOE6qyYbIayJzq8tKc+xjR/lUF9QlFeEUzOG4 JsksN04mvAa29KcouH75jFv1tQW5aQRD/q21Mu7Fw7quCjNh0EeWbx9U3vAj7s3q20aI zIKiXO2BBqeSq1Tehg1hTaxWsFSCbYMz70A0ija8KQRAnaX1GjWk7B/Ek5zbKNPzYbfU 6kr/SQjJK9rsdsUmjCs6jqK74Id3h+444i8prvL3guCeiN31ZQdQ3/GK/LHhEa3zzGXn Z5zU5oOnISwI12oxJiewR8pc1snP+n+N4YZddQMnbxd7hLwk1wvkjfWS+tXoo7nT5L34 EP1A== 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=W9GYgiFgUScl/SG5jFxQrPteYgOlrD//gIQul0pVOes=; b=FOSMbZeSKlEZCGjMZDiokFeCn4KOy9FJsHtitE1Dge4oL87iPvvCreQGT0IdXe6c/M USXv0El/jrv219WTbLTCkNjfToHsfpXBRKU+4U9beONVziLb4fnfnxxAxIDPJbU1VFRS aQ2Cbt7cMwQgRQ2e7v/ezHD/cXT+I/MWKwTvyY3GpL8js6jOLaQk3Jz6IeQmLFngL71a OkUum+tXSs4Xw7fFcIOXHeEwxNo5N4ub6zi1HIi0N5PvhqaSaX8kHHakIDtSzKme0DXi uup+/7sqQ7EGMbrJeJ7dbLLj46y3ymQK3pnYNbgV0d++3H3K+74G6yAle7o5ehNscn23 x0Ew== X-Gm-Message-State: AA+aEWaXGdwRcUZ8NEQ7XXK3VmmGbKxso819/QZnbXWUqrHFK4t8bK1+ 8UDJsRhXJBU6wq1pNG6sWsGQYCrQ X-Google-Smtp-Source: AFSGD/WuWM6yKqk9dJxYZq4hOKOWtycD3hSmtGiIlthvVSe2ZkfnCeBiVhj6m5H6KGoU8ZwZ3n/zvw== X-Received: by 2002:a05:6402:694:: with SMTP id f20mr993079edy.99.1544746547522; Thu, 13 Dec 2018 16:15:47 -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.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:47 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 03/19] test endianness with __BYTE_ORDER__ Date: Fri, 14 Dec 2018 01:15:20 +0100 Message-Id: <20181214001536.6259-4-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 The detection of the native endianness is currently done by testing if __BIG_ENDIAN__ is defined. However, not all native big endian platforms define this macro. Test the endianness with __BYTE_ORDER__. Signed-off-by: Luc Van Oostenryck --- machine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine.h b/machine.h index 1eacb556e..522f9ba08 100644 --- a/machine.h +++ b/machine.h @@ -1,7 +1,7 @@ #ifndef MACHINE_H #define MACHINE_H -#ifdef __BIG_ENDIAN__ +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) #define ARCH_BIG_ENDIAN 1 #else #define ARCH_BIG_ENDIAN 0 From patchwork Fri Dec 14 00:15:21 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: 10730131 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 4B96613AF for ; Fri, 14 Dec 2018 00:15:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D0E32CDFD for ; Fri, 14 Dec 2018 00:15:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 315CF2CEF2; Fri, 14 Dec 2018 00:15:52 +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 A3E1B2CDFD for ; Fri, 14 Dec 2018 00:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbeLNAPv (ORCPT ); Thu, 13 Dec 2018 19:15:51 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35518 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbeLNAPv (ORCPT ); Thu, 13 Dec 2018 19:15:51 -0500 Received: by mail-ed1-f65.google.com with SMTP id x30so3576728edx.2 for ; Thu, 13 Dec 2018 16:15:49 -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=pmaJ525GDxMy06bkJt8AzYEy2mFJVC/6XX6qRWHpgK0=; b=BqaxHtLRNq/sAQ7XebglqRnqrlixojj1A225j0q4IeEESt4SIqqG2IqnORw+n/t2E6 SdtlGDFO476PZUqMpd2UORl9ikA+yjRY5UU1BH+2PnsqqXugixCOzAdWVsH5nmgTXHpj wz2N7qIKZK4YydJ0wAJtHUuLysNnbVwRTKZP90EzNZvAwaKZbbVknLMdH/kOXkD1kWAC BVikt4FbZvenKNPnZn8SJ4v6c/LWWRqu6m8/dqNsZGh0O7zJUjAc9dmCsfKiMHXhPng7 Pl3Dh4/kgNIxk2qjYciHH8i2lnz4kn1amxXAOHkf02ylAgMpUaMAg/cwTzubgpU+HIS5 o+BQ== 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=pmaJ525GDxMy06bkJt8AzYEy2mFJVC/6XX6qRWHpgK0=; b=dIgevjPA/vMeDNvoPiMKTWXeWjgeibQn4nY38lKt/xDnwUaaXWxXmW9v+g78KwDi6k tQSc/LwoGLIy1ilnKUHJNDYdZaJPTa7u52gcPjKJi6JYdXmwW5xpO4DZd4f8GLJklZv0 V5aQlLQJl3hxLbty8zTqbQJZGXXLJsjDT+zAFHnwpRiTaOWRuX2K9t18FZUxo7tjv2yO bWpKNh3XDcSx4B1aVmC/kYHQCm4gaBWNL8NcQVgzlrtavZtUwLV6tFAhMbNGkpLc3Oop coDMtoEKynV7afwQHrLLPB+LxHvTCzOuty1n5/HrbWKUmKVEMATZTvYruZsufK0pN/TT oJGA== X-Gm-Message-State: AA+aEWYj8KX8bDZxSmGnZydjYXto7jXqA5PI4dCJNS95ZjlpAMtxDXFl Tir2dJ2SWGt9G3QP2/dvmILEvy/e X-Google-Smtp-Source: AFSGD/VMBm2Xri4Se64C2YlJOXdwDztQxu+fLDgVI2AxyX8YvtJhxahjSxVEmuR+9AufXmi84cfcug== X-Received: by 2002:a17:906:a88c:: with SMTP id ha12-v6mr838726ejb.107.1544746548592; Thu, 13 Dec 2018 16:15:48 -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.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:48 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 04/19] testsuite: test predef macros on LP32/LP64/LLP64 Date: Fri, 14 Dec 2018 01:15:21 +0100 Message-Id: <20181214001536.6259-5-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 Now these tests should succeed and be meaningful on all archs. Signed-off-by: Luc Van Oostenryck --- validation/preprocessor/predef-char-bit.c | 16 --------- validation/preprocessor/predef-llp64.c | 10 ++++++ validation/preprocessor/predef-lp32.c | 9 +++++ validation/preprocessor/predef-lp64.c | 9 +++++ validation/preprocessor/predef-max.c | 18 ---------- validation/preprocessor/predef-sizeof.c | 25 -------------- validation/preprocessor/predef.c | 42 +++++++++++++++++++++++ 7 files changed, 70 insertions(+), 59 deletions(-) delete mode 100644 validation/preprocessor/predef-char-bit.c create mode 100644 validation/preprocessor/predef-llp64.c create mode 100644 validation/preprocessor/predef-lp32.c create mode 100644 validation/preprocessor/predef-lp64.c delete mode 100644 validation/preprocessor/predef-max.c delete mode 100644 validation/preprocessor/predef-sizeof.c create mode 100644 validation/preprocessor/predef.c diff --git a/validation/preprocessor/predef-char-bit.c b/validation/preprocessor/predef-char-bit.c deleted file mode 100644 index fed0166e4..000000000 --- a/validation/preprocessor/predef-char-bit.c +++ /dev/null @@ -1,16 +0,0 @@ -#define TEST_BIT(X, T) if (__ ## X ## _BIT__ != 8 * sizeof(T)) return 1 - -int test(void) -{ - TEST_BIT(CHAR, char); - - return 0; -} - -/* - * check-name: predefined ___BIT__ - * check-command: test-linearize -Wno-decl $file - * check-output-ignore - * - * check-output-contains: ret\\..*\\$0 - */ diff --git a/validation/preprocessor/predef-llp64.c b/validation/preprocessor/predef-llp64.c new file mode 100644 index 000000000..a34b51b3a --- /dev/null +++ b/validation/preprocessor/predef-llp64.c @@ -0,0 +1,10 @@ +#include "predef.c" + +/* + * check-name: predefined macros for LLP64 + * check-command: test-linearize -Wno-decl -msize-llp64 $file + * check-known-to-fail + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ diff --git a/validation/preprocessor/predef-lp32.c b/validation/preprocessor/predef-lp32.c new file mode 100644 index 000000000..8fa2846c2 --- /dev/null +++ b/validation/preprocessor/predef-lp32.c @@ -0,0 +1,9 @@ +#include "predef.c" + +/* + * check-name: predefined macros for LP32 + * check-command: test-linearize -Wno-decl -m32 $file + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ diff --git a/validation/preprocessor/predef-lp64.c b/validation/preprocessor/predef-lp64.c new file mode 100644 index 000000000..0173ca40d --- /dev/null +++ b/validation/preprocessor/predef-lp64.c @@ -0,0 +1,9 @@ +#include "predef.c" + +/* + * check-name: predefined macros for LP64 + * check-command: test-linearize -Wno-decl -m64 $file + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ diff --git a/validation/preprocessor/predef-max.c b/validation/preprocessor/predef-max.c deleted file mode 100644 index ad4b7eaf1..000000000 --- a/validation/preprocessor/predef-max.c +++ /dev/null @@ -1,18 +0,0 @@ -#define TEST_MAX(X, Z) if (X != ((~ Z) >> 1)) return 1 - -int test_max(void) -{ - TEST_MAX(__INT_MAX__, 0U); - TEST_MAX(__LONG_MAX__, 0UL); - TEST_MAX(__LONG_LONG_MAX__, 0ULL); - - return 0; -} - -/* - * check-name: predefined ___MAX__ - * check-command: test-linearize -Wno-decl $file - * check-output-ignore - * - * check-output-contains: ret\\..*\\$0 - */ diff --git a/validation/preprocessor/predef-sizeof.c b/validation/preprocessor/predef-sizeof.c deleted file mode 100644 index 12be2dd1d..000000000 --- a/validation/preprocessor/predef-sizeof.c +++ /dev/null @@ -1,25 +0,0 @@ -#define TEST(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1 - -int test_sizeof(void) -{ - TEST(SHORT, short); - TEST(INT, int); - TEST(LONG, long); - TEST(LONG_LONG, long long); - TEST(INT128, __int128); - TEST(SIZE_T, __SIZE_TYPE__); - TEST(POINTER, void*); - TEST(FLOAT, float); - TEST(DOUBLE, double); - TEST(LONG_DOUBLE, long double); - - return 0; -} - -/* - * check-name: predefined __SIZEOF___ - * check-command: test-linearize -Wno-decl $file - * check-output-ignore - * - * check-output-contains: ret\\..*\\$0 - */ diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c new file mode 100644 index 000000000..ccb5d3619 --- /dev/null +++ b/validation/preprocessor/predef.c @@ -0,0 +1,42 @@ +#define BITS(T) (sizeof(T) * 8) +#define SIGN_BIT(T) (1ULL << (BITS(T) - 1)) +#define SMASK(T) (SIGN_BIT(T) - 1) +#define UMASK(T) (SIGN_BIT(T) | SMASK(T)) + +int test(void); +int test(void) +{ +#define TEST_BIT(X, T) if (__ ## X ## _BIT__ != BITS(T)) return 1 + TEST_BIT(CHAR, char); + +#define TEST_MAX(X, M) if (__ ## X ## _MAX__ != M) return 1 +#define TEST_SMAX(X, T) TEST_MAX(X, SMASK(T)) +#define TEST_UMAX(X, T) TEST_MAX(X, UMASK(T)) + TEST_SMAX(SCHAR, signed char); + TEST_SMAX(SHRT, short); + TEST_SMAX(INT, int); + TEST_SMAX(LONG, long); + TEST_SMAX(LONG_LONG, long long); + +#define TEST_SIZEOF(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1 + TEST_SIZEOF(SHORT, short); + TEST_SIZEOF(INT, int); + TEST_SIZEOF(LONG, long); + TEST_SIZEOF(LONG_LONG, long long); + TEST_SIZEOF(INT128, __int128); + TEST_SIZEOF(SIZE_T, __SIZE_TYPE__); + TEST_SIZEOF(POINTER, void*); + TEST_SIZEOF(FLOAT, float); + TEST_SIZEOF(DOUBLE, double); + TEST_SIZEOF(LONG_DOUBLE, long double); + + return 0; +} + +/* + * check-name: predefined macros: __SIZEOF___, ... + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ From patchwork Fri Dec 14 00:15:22 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: 10730133 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 BDDEE1759 for ; Fri, 14 Dec 2018 00:15:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF8D22CDFD for ; Fri, 14 Dec 2018 00:15:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3E242CEE0; Fri, 14 Dec 2018 00:15:52 +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 49BEB2CEFD for ; Fri, 14 Dec 2018 00:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728130AbeLNAPw (ORCPT ); Thu, 13 Dec 2018 19:15:52 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:46605 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeLNAPv (ORCPT ); Thu, 13 Dec 2018 19:15:51 -0500 Received: by mail-ed1-f67.google.com with SMTP id o10so3517185edt.13 for ; Thu, 13 Dec 2018 16:15:50 -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=TETFPlGSpRDNBMpIYt7tHq5uTRw7E42CdHTFIuQJRKo=; b=VD9VnV11o0FQGbbX0NNp7Hxu9h3fQRzhx3jU6wU+OJr//KxFHw8FSrsYhKdli7Z/e+ S3XS961faXRJHGxhiDsFkLr50+xlOGLh2IlboejpIpChj7vD2nroFRrdDfS7vD5rJYXF v2mwMdbof8kikWxqpyJwCLrgsRurhxKDS5BbGpGd+OaDMwfFDicLSEXDaHkLej6MA/7c uCn94P3OX3nnYJylq3keivpBE2q7+nj9BQvJqVRMl6aVc7gSGubqRlOeRQQ5D02H5CtU b4+O+Ns3jHxR1UsLpzpBjGlhVdgcgSVnoIrFm57aJY+CHDIfucc90FABzbCxPNfHBIyh rO3g== 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=TETFPlGSpRDNBMpIYt7tHq5uTRw7E42CdHTFIuQJRKo=; b=rJmWpU/59xSXmGBeyc1sdXvEf3dFTqai4J7UJ0YekXKg095wXEInJkno1Tu1hWA0hN Y8wVlu58OoKryA5Un7yXxnPA44TNFIFkfvR1WeQyV29CVR3Pmzi0l5uMrwyE57BYKf8t RzYZ2Crk9SJZXzv1clWedUvwqqe4QALxkDjbSo/kx0CHcuC/Ia/U5Ukdl4dUjQSKF+09 LnU4xikkLSZ3dYOrKm7wP2pvZxpQLun1osOfS1qZY8IzkH9uBy0eoDbJRIYIPbduwf7S i4v8FxDUewgxPtkIBbEzEh/hC7Z3CvbJc5rwIzNQwK+sfI0QRkQqV7EA6LxI8yEh6nUu pwIQ== X-Gm-Message-State: AA+aEWbij5qUiIY1PKgQWZQpRjQONRHs5cgk0kOdWBUrQ5Apejqv4LZG Njzxl6qPwlXey7DBaEEfzIHfQiHj X-Google-Smtp-Source: AFSGD/X3VEbRA7zFuuX5jSc+PQisXsMXmXnkmcceddNOUGlsFLxnrDBCMGFj6RdxeQAWhHgeio0JVA== X-Received: by 2002:a50:951a:: with SMTP id u26mr1096106eda.4.1544746549918; Thu, 13 Dec 2018 16:15:49 -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.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:49 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 05/19] fix '__SIZE_TYPE__' for LLP64 Date: Fri, 14 Dec 2018 01:15:22 +0100 Message-Id: <20181214001536.6259-6-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 size_t_ctype is set to uint, ulong or ullong, depending on the architecture (ullong is only used for LLP64). However, when emitting '__SIZE_TYPE__', it's only compared to ulong or uint. Fix this by using an small helper directly using the right struct symbol * and using builtin_typename() to output the right type. This way we're guaranteed that '__SIZE_TYPE__' is kept coherent with the internal type: size_t_ctype. Signed-off-by: Luc Van Oostenryck --- lib.c | 17 +++++++---------- validation/preprocessor/predef-llp64.c | 1 - 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib.c b/lib.c index e205eb213..9d3ac2afd 100644 --- a/lib.c +++ b/lib.c @@ -1156,6 +1156,12 @@ static void predefined_type_size(const char *name, const char *suffix, unsigned predefined_width(name, bits); } +static void predefined_type(const char *name, struct symbol *type) +{ + const char *typename = builtin_typename(type); + add_pre_buffer("#weak_define __%s_TYPE__ %s\n", name, typename); +} + static void predefined_macros(void) { predefine("__CHECKER__", 0, "1"); @@ -1249,16 +1255,7 @@ static void create_builtin_stream(void) // Temporary hack add_pre_buffer("#define _Pragma(x)\n"); - // gcc defines __SIZE_TYPE__ to be size_t. For linux/i86 and - // solaris/sparc that is really "unsigned int" and for linux/x86_64 - // it is "long unsigned int". In either case we can probably - // get away with this. We need the #weak_define as cgcc will define - // the right __SIZE_TYPE__. - if (size_t_ctype == &ulong_ctype) - add_pre_buffer("#weak_define __SIZE_TYPE__ long unsigned int\n"); - else - add_pre_buffer("#weak_define __SIZE_TYPE__ unsigned int\n"); - + predefined_type("SIZE", size_t_ctype); /* add the multiarch include directories, if any */ if (multiarch_dir && *multiarch_dir) { diff --git a/validation/preprocessor/predef-llp64.c b/validation/preprocessor/predef-llp64.c index a34b51b3a..0a758690c 100644 --- a/validation/preprocessor/predef-llp64.c +++ b/validation/preprocessor/predef-llp64.c @@ -3,7 +3,6 @@ /* * check-name: predefined macros for LLP64 * check-command: test-linearize -Wno-decl -msize-llp64 $file - * check-known-to-fail * check-output-ignore * * check-output-contains: ret\\..*\\$0 From patchwork Fri Dec 14 00:15:23 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: 10730135 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 E36F013BF for ; Fri, 14 Dec 2018 00:15:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5E512CDFD for ; Fri, 14 Dec 2018 00:15:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA31C2CEF2; Fri, 14 Dec 2018 00:15:53 +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 6E6A82CDFD for ; Fri, 14 Dec 2018 00:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbeLNAPx (ORCPT ); Thu, 13 Dec 2018 19:15:53 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:43115 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbeLNAPx (ORCPT ); Thu, 13 Dec 2018 19:15:53 -0500 Received: by mail-ed1-f67.google.com with SMTP id f9so3529580eds.10 for ; Thu, 13 Dec 2018 16:15:51 -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=CyvMTrPOrHXwpXEhWe63Tju4MCJw1qECGhxt5wQlSKA=; b=WQeE1C0/jx21M7IiJ9qlUct7AwssMqOOmqay92eCfeD+VM7BGjQ+HZK5ucxjzI68yN mbqaZHAU+6fyrOxXASMNw24jc+j0fg9Wb0XRx7y9Rja6GffFCCparlO0D8E5eYNJuCrY 3ckQiB7tY8njWB8qn9V+L0DI4qlyXY5QEkGCOoX9qbu5ihXPdbI6qV7m1+99CNJzu4iE +loSWF35TQyITqM8g0m1i0W9F9KWb4R49daXnDHH/knnYlbDI3UioKI5F3oECO61o4Ve DJ2dDBOrMEtP4PCb+CkhAcF7+9fN10p82RAQhwqiGx/xOnZbHgpS/FHzdW//NIt3J7Ee PWxg== 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=CyvMTrPOrHXwpXEhWe63Tju4MCJw1qECGhxt5wQlSKA=; b=ndk3BzuUZPGKKyw17FEX8nM2Isl7qdiCdl1+cI6oEVDRgMY5IwpiXlDLIzxNS8pAhg eTVb1gs1DnnPe0gxyLuKRu20SoAxs9fJNfhMtpgnQN1P7L3dPrNJbCb/4QA0FdUUfx90 VCiF2k0YrE+/IHufBjK4m1oJlyghPyp9jMhFEdd4ziIl+t9pg4z+qMMg5sIyHkfeJ+Av F1dmopFCB18O6IWG05PLUp9AN7ZPAV6pOguXWe+014q7JhhERJ/QrTLOlPkw+OG8y6by MPdXadXHJbR1mmRGVUQcqgMvGAXB5ykl1y/P2CfOYmOxgEEKOR+bLeYGoC6raJtuQirs cMkA== X-Gm-Message-State: AA+aEWZlTRVVb37RMIoJhlyO89aUpPVVtx9XGkjO6mTzXcVxltAFGGEE 1uoOJJdPV9SZFFw4M+Y2rFoUiEac X-Google-Smtp-Source: AFSGD/UZJyqSU30VYJTM9q2qjxw5VMRaPvJOR31r26+RbJnj7OARN6dljaSX7zC/r4nUoo6eNIdGXw== X-Received: by 2002:a50:f489:: with SMTP id s9mr1042070edm.101.1544746550800; Thu, 13 Dec 2018 16:15:50 -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.15.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:50 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 06/19] allow optional "_T" suffix to __SIZEOF_XXX__ Date: Fri, 14 Dec 2018 01:15:23 +0100 Message-Id: <20181214001536.6259-7-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 This allows to be more generic. Signed-off-by: Luc Van Oostenryck --- lib.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib.c b/lib.c index 9d3ac2afd..70c5c72bb 100644 --- a/lib.c +++ b/lib.c @@ -1124,11 +1124,11 @@ static char **handle_switch(char *arg, char **next) return next; } -static void predefined_sizeof(const char *name, unsigned bits) +static void predefined_sizeof(const char *name, const char *suffix, unsigned bits) { char buf[32]; - snprintf(buf, sizeof(buf), "__SIZEOF_%s__", name); + snprintf(buf, sizeof(buf), "__SIZEOF_%s%s__", name, suffix); predefine(buf, 1, "%d", bits/8); } @@ -1152,7 +1152,7 @@ static void predefined_max(const char *name, const char *suffix, unsigned bits) static void predefined_type_size(const char *name, const char *suffix, unsigned bits) { predefined_max(name, suffix, bits); - predefined_sizeof(name, bits); + predefined_sizeof(name, "", bits); predefined_width(name, bits); } @@ -1203,12 +1203,12 @@ static void predefined_macros(void) break; } - predefined_sizeof("SHORT", bits_in_short); + predefined_sizeof("SHORT", "", bits_in_short); predefined_max("SHRT", "", bits_in_short); predefined_width("SHRT", bits_in_short); predefined_max("SCHAR", "", bits_in_char); predefined_width("SCHAR", bits_in_char); - predefined_sizeof("WCHAR_T",bits_in_wchar); + predefined_sizeof("WCHAR", "_T", bits_in_wchar); predefined_max("WCHAR", "", bits_in_wchar); predefined_width("WCHAR", bits_in_wchar); predefine("__CHAR_BIT__", 1, "%d", bits_in_char); @@ -1217,17 +1217,17 @@ static void predefined_macros(void) predefined_type_size("LONG", "L", bits_in_long); predefined_type_size("LONG_LONG", "LL", bits_in_longlong); - predefined_sizeof("INT128", 128); + predefined_sizeof("INT128", "", 128); - predefined_sizeof("SIZE_T", bits_in_pointer); + predefined_sizeof("SIZE", "_T", bits_in_pointer); predefined_width( "SIZE", bits_in_pointer); - predefined_sizeof("PTRDIFF_T", bits_in_pointer); + predefined_sizeof("PTRDIFF", "_T", bits_in_pointer); predefined_width( "PTRDIFF", bits_in_pointer); - predefined_sizeof("POINTER", bits_in_pointer); + predefined_sizeof("POINTER", "", bits_in_pointer); - predefined_sizeof("FLOAT", bits_in_float); - predefined_sizeof("DOUBLE", bits_in_double); - predefined_sizeof("LONG_DOUBLE", bits_in_longdouble); + predefined_sizeof("FLOAT", "", bits_in_float); + predefined_sizeof("DOUBLE", "", bits_in_double); + predefined_sizeof("LONG_DOUBLE", "", bits_in_longdouble); predefine("__ORDER_LITTLE_ENDIAN__", 1, "1234"); predefine("__ORDER_BIG_ENDIAN__", 1, "4321"); From patchwork Fri Dec 14 00:15:24 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: 10730137 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 BC72013BF for ; Fri, 14 Dec 2018 00:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF10C2CDFD for ; Fri, 14 Dec 2018 00:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A39762CEF2; Fri, 14 Dec 2018 00:15:54 +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 591FC2CDFD for ; Fri, 14 Dec 2018 00:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728423AbeLNAPy (ORCPT ); Thu, 13 Dec 2018 19:15:54 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:33922 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeLNAPy (ORCPT ); Thu, 13 Dec 2018 19:15:54 -0500 Received: by mail-ed1-f67.google.com with SMTP id b3so3578618ede.1 for ; Thu, 13 Dec 2018 16:15:52 -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=SklLcsWgEdJxMRzBq9kshbAxAipmWafTQ6jONGNxKKM=; b=pX1agDS0VgXdmNpi2sITy25z9qkS+d5dHzTMKQJ4u7zeg0DsjXRKRY62i/5wTdBaJh 2OU4mfz2IR9Tp0CfMOpmY6eb0e4HHVhdx4KoJu5r56mq2lxvUHXqGE990w/hnNPwP9tn eu4w4Br0G7E6CaHqWI3f6Zm0YPIIIB6a6oXoyS2bV79u9f2hIDC8wVVwjH8BgTbEkO0J OhwITwTMu7Hx/NcovKOCIgWesDJUtHlB7wWFhX2FRj6ID+FJ04/JzCxi6ssgsh55S5H8 JXUgvBk+jp7Lytm6VpMeh/l1/alSXqe0B0P792nPCZVQNECpQA56u1w69AOq4+lDV1cX eUog== 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=SklLcsWgEdJxMRzBq9kshbAxAipmWafTQ6jONGNxKKM=; b=HfpyCI7L/qIdTSo6Xob9yDirrTcT7CVrSuWMTR86ac15CKr/jkaRWDZ2+endWmg/tc jahQ7SMdVAD06iAqfuu0T3UogdU9Z9aGzVl+SmkdLy3Uj9C9SFW8QsphM6+ZT9A9kLTP 3o4w7qiHowgVXzcBCBfQ3h1erz/N/FWHxAnLOIyZY82V/YCWfTp8sSYuIWHSMx5vG0Wz K5qUHnDVsGqBsNHmwj3I7FFKWuTUMxpkyQgMgldbJpt/UkjcZT9c13xsoRiLQHCbVEm9 NFD7Ndb7636nO8AdNR4IDi4oQSiuyOxz8v7EE5qGpPHh/hhN9G72zcaK5ZteHxDdWGhz 2CiA== X-Gm-Message-State: AA+aEWapYnnYJysSDLxcqFkxDBWYLl1Qir1n+uMqu7wuEP49qsgRKdXH 1JiL3bZX2DiosWljKoh4QZFBO9I6 X-Google-Smtp-Source: AFSGD/V+kmHTZoxgz9TwCA72GnzdomDL3gZe95N2jo+c6tlkFazJ733A+0G4XKU1677P3rb2Y4PO+A== X-Received: by 2002:aa7:d416:: with SMTP id z22mr1048571edq.3.1544746551929; Thu, 13 Dec 2018 16:15:51 -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.15.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:51 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 07/19] use bits_mask() for predefined_max() Date: Fri, 14 Dec 2018 01:15:24 +0100 Message-Id: <20181214001536.6259-8-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 Creating a bit mask using '(1 << n) - 1' is undefined if n is as big as the width of an int. Use the safe helper bits_mask() to create the mask/value for predefined_max(). Note: predefined_max() is currently correct only for signed types. Signed-off-by: Luc Van Oostenryck --- lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib.c b/lib.c index 70c5c72bb..8cd2a837f 100644 --- a/lib.c +++ b/lib.c @@ -46,6 +46,7 @@ #include "target.h" #include "machine.h" #include "version.h" +#include "bits.h" int verbose, optimize_level, optimize_size, preprocessing; int die_if_error = 0; @@ -1142,7 +1143,7 @@ static void predefined_width(const char *name, unsigned bits) static void predefined_max(const char *name, const char *suffix, unsigned bits) { - unsigned long long max = (1ULL << (bits - 1 )) - 1; + unsigned long long max = bits_mask(bits - 1); char buf[32]; snprintf(buf, sizeof(buf), "__%s_MAX__", name); From patchwork Fri Dec 14 00:15:25 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: 10730139 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 EF8E113AF for ; Fri, 14 Dec 2018 00:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19A42CDFD for ; Fri, 14 Dec 2018 00:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5AC32CEF2; Fri, 14 Dec 2018 00:15:56 +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 703782CDFD for ; Fri, 14 Dec 2018 00:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728433AbeLNAP4 (ORCPT ); Thu, 13 Dec 2018 19:15:56 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40327 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbeLNAP4 (ORCPT ); Thu, 13 Dec 2018 19:15:56 -0500 Received: by mail-ed1-f68.google.com with SMTP id d3so3544529edx.7 for ; Thu, 13 Dec 2018 16:15:54 -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=5ThBXFuQokD6FMwsNkoXImKExuW+Zo5SiqGbZCP6/9I=; b=jxzMdG/DLrIFLKgq7M8LHv9aI3I5FyOI8iE/x+bqIGboK8fSiND+e6H5/uqAKn1CBi 63Dt8+NLFDKr+03DLGdLL28V8MmnT+Lb9hWhB3zDQlnrA6IhrNbx0WkbkYUlAtyF9ahO L81pyN/uuowWCK92XFnk+C8VY3NqeXBiv9v6Goji4VTAFMMZbxBSl+Xvoo5IU1TFdM2j B1gO12J8DpEEv1LZbzdWcASr89IsRBtXhlv/YiQeBBqxi50VjR+xAwoPnnOZNW88Ow0C yoZaaKaZ5QE0xIF8qmtbf35e7rJgF5xFLipEcS6+8baDt6Xf6xhrcGL45QCAyGJTVSPT kpMw== 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=5ThBXFuQokD6FMwsNkoXImKExuW+Zo5SiqGbZCP6/9I=; b=eLGuLSaOe6we3fV+gLjEhCNU3OSlK3mfn3MR3GPYo1dovxo4wXYLlG+5o/RmRTE+gr 9wkpe9bDeshpZR03B7voZ4DbMxpJRAdjCUKfhX0dFT5Cy3EDZsQhCKj6fpqVJozYGYvg P7v0xIb5V3DHCgESQHncPQ8p9GEU22od5/vBe1XNVT1XiKTWMM9Ni+oCO7LKaqIfVhxz vwnScjhNvXFPNlrAi5YRFI36Egjpfud8ob1lgDJtvpoiJ5hpCAZjsPhnr5BiSkzUGPVK OobzQzJLIGB4NIFsti1ljTq7a4KSEcbdyEl6sBAW+9UljPodPvq7BqEvYnH/pBkZGAga FTBQ== X-Gm-Message-State: AA+aEWaCPFZGqvBqwx6PWgVpfndr+GqsdvdrxnFTUeftU1Hiuv5eMKR6 2KWA6iVenE6KGOURINTpVMRbhvR9 X-Google-Smtp-Source: AFSGD/WWwP977ihr1u74mGhy2Z2cAR6K3oC7YuSdLTSehaWBuLn4hkFu5NEi0YKJ5e+gcCzCgh9hsw== X-Received: by 2002:a50:98a6:: with SMTP id j35mr1038788edb.141.1544746553182; Thu, 13 Dec 2018 16:15:53 -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.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:52 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 08/19] add builtin_type_suffix() Date: Fri, 14 Dec 2018 01:15:25 +0100 Message-Id: <20181214001536.6259-9-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 With this helper, we can easily output constants with the correct type, like '0x123' for ints, '0x123UL' for unsigned longs, .... Signed-off-by: Luc Van Oostenryck --- show-parse.c | 73 ++++++++++++++++++++++++++++++---------------------- symbol.h | 1 + 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/show-parse.c b/show-parse.c index 6328439c9..7f9332fc0 100644 --- a/show-parse.c +++ b/show-parse.c @@ -218,38 +218,39 @@ static void FORMAT_ATTR(2) append(struct type_name *name, const char *fmt, ...) static struct ctype_name { struct symbol *sym; const char *name; + const char *suffix; } typenames[] = { - { & char_ctype, "char" }, - { &schar_ctype, "signed char" }, - { &uchar_ctype, "unsigned char" }, - { & short_ctype, "short" }, - { &sshort_ctype, "signed short" }, - { &ushort_ctype, "unsigned short" }, - { & int_ctype, "int" }, - { &sint_ctype, "signed int" }, - { &uint_ctype, "unsigned int" }, - { &slong_ctype, "signed long" }, - { & long_ctype, "long" }, - { &ulong_ctype, "unsigned long" }, - { & llong_ctype, "long long" }, - { &sllong_ctype, "signed long long" }, - { &ullong_ctype, "unsigned long long" }, - { & lllong_ctype, "long long long" }, - { &slllong_ctype, "signed long long long" }, - { &ulllong_ctype, "unsigned long long long" }, - - { &void_ctype, "void" }, - { &bool_ctype, "bool" }, - { &string_ctype, "string" }, - - { &float_ctype, "float" }, - { &double_ctype, "double" }, - { &ldouble_ctype,"long double" }, - { &incomplete_ctype, "incomplete type" }, - { &int_type, "abstract int" }, - { &fp_type, "abstract fp" }, - { &label_ctype, "label type" }, - { &bad_ctype, "bad type" }, + { & char_ctype, "char", "" }, + { &schar_ctype, "signed char", "" }, + { &uchar_ctype, "unsigned char", "" }, + { & short_ctype, "short", "" }, + { &sshort_ctype, "signed short", "" }, + { &ushort_ctype, "unsigned short", "" }, + { & int_ctype, "int", "" }, + { &sint_ctype, "signed int", "" }, + { &uint_ctype, "unsigned int", "U" }, + { & long_ctype, "long", "L" }, + { &slong_ctype, "signed long", "L" }, + { &ulong_ctype, "unsigned long", "UL" }, + { & llong_ctype, "long long", "LL" }, + { &sllong_ctype, "signed long long", "LL" }, + { &ullong_ctype, "unsigned long long", "ULL" }, + { & lllong_ctype, "long long long", "LLL" }, + { &slllong_ctype, "signed long long long", "LLL" }, + { &ulllong_ctype, "unsigned long long long", "ULLL" }, + + { &void_ctype, "void", "" }, + { &bool_ctype, "bool", "" }, + { &string_ctype, "string", "" }, + + { &float_ctype, "float", "F" }, + { &double_ctype, "double", "" }, + { &ldouble_ctype,"long double", "L" }, + { &incomplete_ctype, "incomplete type", "" }, + { &int_type, "abstract int", "" }, + { &fp_type, "abstract fp", "" }, + { &label_ctype, "label type", "" }, + { &bad_ctype, "bad type", "" }, }; const char *builtin_typename(struct symbol *sym) @@ -262,6 +263,16 @@ const char *builtin_typename(struct symbol *sym) return NULL; } +const char *builtin_type_suffix(struct symbol *sym) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(typenames); i++) + if (typenames[i].sym == sym) + return typenames[i].suffix; + return NULL; +} + const char *builtin_ctypename(struct ctype *ctype) { int i; diff --git a/symbol.h b/symbol.h index 5a3d7cef5..f9fb4bc5a 100644 --- a/symbol.h +++ b/symbol.h @@ -317,6 +317,7 @@ extern struct symbol *examine_symbol_type(struct symbol *); extern struct symbol *examine_pointer_target(struct symbol *); extern const char *show_typename(struct symbol *sym); extern const char *builtin_typename(struct symbol *sym); +extern const char *builtin_type_suffix(struct symbol *sym); extern const char *builtin_ctypename(struct ctype *ctype); extern const char* get_type_name(enum type type); From patchwork Fri Dec 14 00:15:26 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: 10730141 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 9EA8D13BF for ; Fri, 14 Dec 2018 00:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 900F92CDFD for ; Fri, 14 Dec 2018 00:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8498E2CEF2; Fri, 14 Dec 2018 00:15:57 +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 11E4C2CDFD for ; Fri, 14 Dec 2018 00:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727042AbeLNAP4 (ORCPT ); Thu, 13 Dec 2018 19:15:56 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45901 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeLNAP4 (ORCPT ); Thu, 13 Dec 2018 19:15:56 -0500 Received: by mail-ed1-f68.google.com with SMTP id d39so3519619edb.12 for ; Thu, 13 Dec 2018 16:15:54 -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=HZzMsOBQgFHcs5/jARoVgbXcbM0YTRnYjCbwH0uNSWw=; b=KYtWufcH003bvnbVElSCFVti9F2bc4Alkbh6TYEUP1rFgGJ5Pyfw3PcyXS0l40UXW4 6G9QWW9+0iAd/i8BZ6VEVCyIF/xuYpzciIfnjiPZItAL+16+kvjZtzn2lkxAW1BXdpPs vdT/MwDsQtq+CQJ4U1FLZ364MoeHgywyDMekSXWwFJPmkYGcE2yjwTAsmWLG/TxxH0lg dtriouk8oRWEsJDjMSMQgZXaHQPPMPY05rIetpHu6AKWOYGyzQd8H3pxy09RAe5d+S+x 9B6WEL6b2fwkfaGjGk/tx+L58eb8jQWttPZmyf47Nckilt8FZDLTJBFJDGCiII5sZPvs BJpg== 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=HZzMsOBQgFHcs5/jARoVgbXcbM0YTRnYjCbwH0uNSWw=; b=YshNN9HxhiDRWMJor0gIwQeqOBiFmfmB9Tfd3g3mnzoIWHD471UIOTktgWayY1z4y1 8AHrhAX9/uUhEYQNqc3Fd+s2+P0t+gM2JKQEnvThn8YTNQvKNIuGV8JmRWpO5Fs0EYHG LGgL+jBi8jRSxczU14Qx8smFW2CJJ8Td9j2q5YljlSuYawPyRgxZBlATPFIJVQWhv2eo pW47d/7iSUPDneGhTL+QD4zRApPjpkSkbQCS+RQgw/P+2AUFo+l3DX5J1DVdaN2bLrZG nXzab7tRjECvK8GhWGJnvhfl5kWIJB7ZS7owKKCQR6edUWTyxTZoAptaRAVxqgQEMCIb DApw== X-Gm-Message-State: AA+aEWYb9PqVfP+29QaPMzGi3hzBDAsnGcDRXn6vYpbWKOdv81/so4LU sqVXIVElaELVDdGqOGsaxc8JIClp X-Google-Smtp-Source: AFSGD/WhQWs/xErbWsUkLRoFqpuwitmZRmO0X7Y7AM9bXImvFQOMdtXhIK/j/9gzFs3VNUTmUfeWpA== X-Received: by 2002:a50:ac47:: with SMTP id w7mr1109898edc.260.1544746553959; Thu, 13 Dec 2018 16:15:53 -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.15.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:53 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 09/19] make predefined_type_size() more generic Date: Fri, 14 Dec 2018 01:15:26 +0100 Message-Id: <20181214001536.6259-10-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 This allows to have a single function to output the size, the type, the maximal value, ... Signed-off-by: Luc Van Oostenryck --- lib.c | 61 ++++++++++++++++++++------------ validation/preprocessor/predef.c | 3 ++ 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/lib.c b/lib.c index 8cd2a837f..2a383f000 100644 --- a/lib.c +++ b/lib.c @@ -1125,6 +1125,15 @@ static char **handle_switch(char *arg, char **next) return next; } +#define PTYPE_SIZEOF (1U << 0) +#define PTYPE_T (1U << 1) +#define PTYPE_MAX (1U << 2) +#define PTYPE_MIN (1U << 3) +#define PTYPE_WIDTH (1U << 4) +#define PTYPE_TYPE (1U << 5) +#define PTYPE_ALL (PTYPE_MAX|PTYPE_SIZEOF|PTYPE_WIDTH) +#define PTYPE_ALL_T (PTYPE_MAX|PTYPE_SIZEOF|PTYPE_WIDTH|PTYPE_T) + static void predefined_sizeof(const char *name, const char *suffix, unsigned bits) { char buf[32]; @@ -1143,26 +1152,37 @@ static void predefined_width(const char *name, unsigned bits) static void predefined_max(const char *name, const char *suffix, unsigned bits) { - unsigned long long max = bits_mask(bits - 1); + unsigned long long max = bits_mask(bits); char buf[32]; snprintf(buf, sizeof(buf), "__%s_MAX__", name); predefine(buf, 1, "%#llx%s", max, suffix); } -static void predefined_type_size(const char *name, const char *suffix, unsigned bits) -{ - predefined_max(name, suffix, bits); - predefined_sizeof(name, "", bits); - predefined_width(name, bits); -} - static void predefined_type(const char *name, struct symbol *type) { const char *typename = builtin_typename(type); add_pre_buffer("#weak_define __%s_TYPE__ %s\n", name, typename); } +static void predefined_ctype(const char *name, struct symbol *type, int flags) +{ + unsigned bits = type->bit_size; + + if (flags & PTYPE_SIZEOF) { + const char *suffix = (flags & PTYPE_T) ? "_T" : ""; + predefined_sizeof(name, suffix, bits); + } + if (flags & PTYPE_MAX) { + const char *suffix = builtin_type_suffix(type); + predefined_max(name, suffix, bits - is_signed_type(type)); + } + if (flags & PTYPE_TYPE) + predefined_type(name, type); + if (flags & PTYPE_WIDTH) + predefined_width(name, bits); +} + static void predefined_macros(void) { predefine("__CHECKER__", 0, "1"); @@ -1204,27 +1224,24 @@ static void predefined_macros(void) break; } - predefined_sizeof("SHORT", "", bits_in_short); - predefined_max("SHRT", "", bits_in_short); - predefined_width("SHRT", bits_in_short); - predefined_max("SCHAR", "", bits_in_char); - predefined_width("SCHAR", bits_in_char); predefined_sizeof("WCHAR", "_T", bits_in_wchar); predefined_max("WCHAR", "", bits_in_wchar); predefined_width("WCHAR", bits_in_wchar); predefine("__CHAR_BIT__", 1, "%d", bits_in_char); - predefined_type_size("INT", "", bits_in_int); - predefined_type_size("LONG", "L", bits_in_long); - predefined_type_size("LONG_LONG", "LL", bits_in_longlong); + predefined_ctype("SHORT", &short_ctype, PTYPE_SIZEOF); + predefined_ctype("SHRT", &short_ctype, PTYPE_MAX|PTYPE_WIDTH); + predefined_ctype("SCHAR", &char_ctype, PTYPE_MAX|PTYPE_WIDTH); + + predefined_ctype("INT", &int_ctype, PTYPE_ALL); + predefined_ctype("LONG", &long_ctype, PTYPE_ALL); + predefined_ctype("LONG_LONG", &llong_ctype, PTYPE_ALL); predefined_sizeof("INT128", "", 128); - predefined_sizeof("SIZE", "_T", bits_in_pointer); - predefined_width( "SIZE", bits_in_pointer); - predefined_sizeof("PTRDIFF", "_T", bits_in_pointer); - predefined_width( "PTRDIFF", bits_in_pointer); - predefined_sizeof("POINTER", "", bits_in_pointer); + predefined_ctype("PTRDIFF", ssize_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); + predefined_ctype("SIZE", size_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); + predefined_ctype("POINTER", &ptr_ctype, PTYPE_SIZEOF); predefined_sizeof("FLOAT", "", bits_in_float); predefined_sizeof("DOUBLE", "", bits_in_double); @@ -1256,8 +1273,6 @@ static void create_builtin_stream(void) // Temporary hack add_pre_buffer("#define _Pragma(x)\n"); - predefined_type("SIZE", size_t_ctype); - /* add the multiarch include directories, if any */ if (multiarch_dir && *multiarch_dir) { add_pre_buffer("#add_system \"/usr/include/%s\"\n", multiarch_dir); diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index ccb5d3619..298bdd93c 100644 --- a/validation/preprocessor/predef.c +++ b/validation/preprocessor/predef.c @@ -17,6 +17,8 @@ int test(void) TEST_SMAX(INT, int); TEST_SMAX(LONG, long); TEST_SMAX(LONG_LONG, long long); + TEST_SMAX(PTRDIFF, __PTRDIFF_TYPE__); + TEST_UMAX(SIZE, __SIZE_TYPE__); #define TEST_SIZEOF(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1 TEST_SIZEOF(SHORT, short); @@ -24,6 +26,7 @@ int test(void) TEST_SIZEOF(LONG, long); TEST_SIZEOF(LONG_LONG, long long); TEST_SIZEOF(INT128, __int128); + TEST_SIZEOF(PTRDIFF_T, __PTRDIFF_TYPE__); TEST_SIZEOF(SIZE_T, __SIZE_TYPE__); TEST_SIZEOF(POINTER, void*); TEST_SIZEOF(FLOAT, float); From patchwork Fri Dec 14 00:15:27 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: 10730143 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 5E85113AF for ; Fri, 14 Dec 2018 00:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE5C2CDFD for ; Fri, 14 Dec 2018 00:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 432952CEF2; Fri, 14 Dec 2018 00:15:59 +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 2CBB52CDFD for ; Fri, 14 Dec 2018 00:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbeLNAP6 (ORCPT ); Thu, 13 Dec 2018 19:15:58 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:44914 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbeLNAP5 (ORCPT ); Thu, 13 Dec 2018 19:15:57 -0500 Received: by mail-ed1-f68.google.com with SMTP id y56so3526683edd.11 for ; Thu, 13 Dec 2018 16:15:56 -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=ZJc4/pjb6/ep2iR0svAZKTTeMN6+HgL/qHr+v1vF2xg=; b=LDzBsyjKE1NyOvzzZrsKT8IpMspGs6zvB6XWKMCJb2aOknQpse8MUCnfY/Mg6Y8Vhx iSL3wzhWAhluDPjEp6BLEwfoQQOHiwACjzftKAlvcMwOte1AMW4tMtPbVTnW9v+hPgE+ 0GyHFp2ZRuWCKHd6R0m7Hk7h2iVj+9ahSP9dG2dyIKCIU9eDqpcoDLoIrYIcBmmf3kg2 wqZD4i9HzQm5QF37razFXaBsI1TiJT16JPX8EkuYW41AOhLWhySoBqct1jb1GC06ISJ4 Bn02RuSgzRAc+/zHyiP3RsQobUQSniTcUWw9mOxC6cE7WDIVPmLdjePUlLX9dBbK0TF4 HqSg== 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=ZJc4/pjb6/ep2iR0svAZKTTeMN6+HgL/qHr+v1vF2xg=; b=P+etSpFSELGKZRCiNSHIHweAb/Z5QaANxyEYITXoc5VjG1NOLdSt/gRaJnw+on1Nz7 E97cfqzy1iPAUpqvxBjD5lCYwf8DJXgjXxSQp1ldaYIawpY8e5E+5vM0YeY0Rti3DGj7 Vn3kyMSvHXn7UMO1P0PoyeRp5j0n/BseXuOCT7TEFTCtGP4vLzfaxrAmw059y24BCgy6 2vPbNSEFk9h/lvIXwfa7FqtrTxO+1nBl6MH+hzd1xAh7lv5EmNPuGTPw3UTcQLTnyibH 1lAByMEWSiLp8avs38cbdS29iicM9/Xqn8O8ryJ+iMif2xjAP2j2co62aI1UOfHGdhE6 L2RA== X-Gm-Message-State: AA+aEWZrasmYcD8i2FKfGqATjdBJHFonJf8Dxq/UuaHK2gKeoMYa4mZr GLuyZ04lk6T4NIHv20cq2VCji/59 X-Google-Smtp-Source: AFSGD/UtIM9edmUcnkKIB4oPkveZ5j+49BBWc+nYBh+C9UhEKQlJDNqRag4njFOC8yw3D8tzGhZKEQ== X-Received: by 2002:a17:906:195b:: with SMTP id b27-v6mr861207eje.220.1544746554993; Thu, 13 Dec 2018 16:15:54 -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.15.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:54 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 10/19] give a type to wchar Date: Fri, 14 Dec 2018 01:15:27 +0100 Message-Id: <20181214001536.6259-11-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 This allows to use predefined_ctype() on wchar_t. Note: currently __WCHAR_TYPE__ is defined to 'int' but this is incorrect on: i386, m68k, ppc32, ... Signed-off-by: Luc Van Oostenryck --- char.c | 4 ++-- lib.c | 6 +++--- lib.h | 1 + symbol.h | 1 + target.c | 27 +++++++++++++++++++++++++-- target.h | 3 +-- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/char.c b/char.c index c52521bc8..f26b2a806 100644 --- a/char.c +++ b/char.c @@ -84,7 +84,7 @@ void get_char_constant(struct token *token, unsigned long long *val) end = p + type - TOKEN_WIDE_CHAR; } p = parse_escape(p, &v, end, - type < TOKEN_WIDE_CHAR ? bits_in_char : bits_in_wchar, token->pos); + type < TOKEN_WIDE_CHAR ? bits_in_char : wchar_ctype->bit_size, token->pos); if (p != end) warning(token->pos, "multi-character character constant"); @@ -113,7 +113,7 @@ struct token *get_string_constant(struct token *token, struct expression *expr) done = next; } } - bits = is_wide ? bits_in_wchar : bits_in_char; + bits = is_wide ? wchar_ctype->bit_size: bits_in_char; while (token != done) { unsigned v; const char *p = token->string->data; diff --git a/lib.c b/lib.c index 2a383f000..dde9f7c36 100644 --- a/lib.c +++ b/lib.c @@ -317,6 +317,7 @@ static enum { STANDARD_C89, int arch_m64 = ARCH_M64_DEFAULT; int arch_msize_long = 0; int arch_big_endian = ARCH_BIG_ENDIAN; +int arch_mach = MACH_NATIVE; #define CMDLINE_INCLUDE 20 @@ -1224,14 +1225,12 @@ static void predefined_macros(void) break; } - predefined_sizeof("WCHAR", "_T", bits_in_wchar); - predefined_max("WCHAR", "", bits_in_wchar); - predefined_width("WCHAR", bits_in_wchar); predefine("__CHAR_BIT__", 1, "%d", bits_in_char); predefined_ctype("SHORT", &short_ctype, PTYPE_SIZEOF); predefined_ctype("SHRT", &short_ctype, PTYPE_MAX|PTYPE_WIDTH); predefined_ctype("SCHAR", &char_ctype, PTYPE_MAX|PTYPE_WIDTH); + predefined_ctype("WCHAR", wchar_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("INT", &int_ctype, PTYPE_ALL); predefined_ctype("LONG", &long_ctype, PTYPE_ALL); @@ -1408,6 +1407,7 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list list = NULL; if (filelist) { // Initialize type system + init_target(); init_ctype(); predefined_macros(); diff --git a/lib.h b/lib.h index cde74e93e..a97e70b67 100644 --- a/lib.h +++ b/lib.h @@ -196,6 +196,7 @@ extern int funsigned_char; extern int arch_m64; extern int arch_msize_long; extern int arch_big_endian; +extern int arch_mach; extern void dump_macro_definitions(void); extern struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **files); diff --git a/symbol.h b/symbol.h index f9fb4bc5a..287be628b 100644 --- a/symbol.h +++ b/symbol.h @@ -303,6 +303,7 @@ extern void init_symbols(void); extern void init_builtins(int stream); extern void declare_builtins(void); extern void init_ctype(void); +extern void init_target(void); extern struct symbol *alloc_symbol(struct position, int type); extern void show_type(struct symbol *); extern const char *modifier_string(unsigned long mod); diff --git a/target.c b/target.c index 86a9e2e63..27503e244 100644 --- a/target.c +++ b/target.c @@ -2,9 +2,11 @@ #include "symbol.h" #include "target.h" +#include "machine.h" struct symbol *size_t_ctype = &uint_ctype; struct symbol *ssize_t_ctype = &int_ctype; +struct symbol *wchar_ctype = &int_ctype; /* * For "__attribute__((aligned))" @@ -22,8 +24,6 @@ int bits_in_long = 32; int bits_in_longlong = 64; int bits_in_longlonglong = 128; -int bits_in_wchar = 32; - int max_int_alignment = 4; /* @@ -46,3 +46,26 @@ int pointer_alignment = 4; */ int bits_in_enum = 32; int enum_alignment = 4; + + +void init_target(void) +{ + switch (arch_mach) { + case MACH_X86_64: + if (arch_m64 == ARCH_LP64) + break; + /* fall through */ + case MACH_I386: + case MACH_M68K: + case MACH_SPARC32: + case MACH_PPC32: + wchar_ctype = &long_ctype; + break; + case MACH_ARM: + case MACH_ARM64: + wchar_ctype = &uint_ctype; + break; + default: + break; + } +} diff --git a/target.h b/target.h index 8326fa21a..74f51ffeb 100644 --- a/target.h +++ b/target.h @@ -3,6 +3,7 @@ extern struct symbol *size_t_ctype; extern struct symbol *ssize_t_ctype; +extern struct symbol *wchar_ctype; /* * For "__attribute__((aligned))" @@ -20,8 +21,6 @@ extern int bits_in_long; extern int bits_in_longlong; extern int bits_in_longlonglong; -extern int bits_in_wchar; - extern int max_int_alignment; /* From patchwork Fri Dec 14 00:15:28 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: 10730145 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 59CFF13AF for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 496CA2CDFD for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D8A42CEFF; Fri, 14 Dec 2018 00:16:01 +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 E59042CDFD for ; Fri, 14 Dec 2018 00:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728576AbeLNAQA (ORCPT ); Thu, 13 Dec 2018 19:16:00 -0500 Received: from mail-ed1-f52.google.com ([209.85.208.52]:35894 "EHLO mail-ed1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeLNAP6 (ORCPT ); Thu, 13 Dec 2018 19:15:58 -0500 Received: by mail-ed1-f52.google.com with SMTP id f23so3568350edb.3 for ; Thu, 13 Dec 2018 16:15:57 -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=w/Z4fSNfXbHuUu3Rw18/BoyYR1tyz8xRkYM2p9PG5fY=; b=a+4zw8V3zP40zOfzCaG9FDswy7yibtu8R7afqHYER3uikc3UX6aNdzCJfe0CJAwFDS KYGzjkQS9KDp3mbQ57slTcgEwYsYzNTBQMpIwiyDU87E5g4SYMNDlXPjPdczeQOWUHbp zT35m9m+9CsdSFLYABgRMp/k7KjdXauPiXGJxZxZOQK8utDEIo8Haq9Cgui0UbmrOquw /jDnrU5nooXpYdBT071MPrc3EtsCDLrfcJAvnt0fVbOkAEpI1PbxRodMlxGaGVGiRNnT 6iYHSjIUlayLzRGEiybvgnnf7suaJasIkseQBLBF2mJHtUKQ/XoucWbkeq+0TKAn7aTQ 2emQ== 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=w/Z4fSNfXbHuUu3Rw18/BoyYR1tyz8xRkYM2p9PG5fY=; b=Ph6RnCiezMld6G+7DvGHYankmhRbeWFgyWQsamd6kGYU9jv3M9auBPvGlVQiaZta8s 6Rbydz4LJAyISlF0CA8HSAtY6ukpHcIWLXg3Oz9WVBFspqbld9lzKY2iLmp3CKY137u+ ZS9P/oVLpKt3mQeW6RUcQVpfppfJ16wWJ6k2kgObIZUZYTiuJDUATNhT5N4VGVcnKp3I sPVjQ7tHnbnduz7JYMGplolry9FfdcT0h/wfx7rY2wd0sc/vAWwCltAUFvG8is8szjO/ MmFnii18HbNQIO8sQOxkzyJALoxh3vnJaLFjrR4wnyQKStfBoofJG3eZOdPxTyy66Hym remg== X-Gm-Message-State: AA+aEWavP3j2r9xw1z5UUB5tzwnet7un2pZtzI3zipUayaf7iBIv1ybE S72IQuQyL8wPpN0QGI0JHapvYIuF X-Google-Smtp-Source: AFSGD/XgTspE3jmvbbwpS9RmS1NiVBNhS8t4SKcrSqTWhTaJMiw44wlhlOdZwg5yxjJ52VIvGh8APw== X-Received: by 2002:a50:8e16:: with SMTP id 22mr1129988edw.32.1544746556111; Thu, 13 Dec 2018 16:15:56 -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.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:55 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 11/19] use the type for predefined_max() Date: Fri, 14 Dec 2018 01:15:28 +0100 Message-Id: <20181214001536.6259-12-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 --- lib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib.c b/lib.c index dde9f7c36..d03bb856e 100644 --- a/lib.c +++ b/lib.c @@ -1151,8 +1151,10 @@ static void predefined_width(const char *name, unsigned bits) predefine(buf, 1, "%d", bits); } -static void predefined_max(const char *name, const char *suffix, unsigned bits) +static void predefined_max(const char *name, struct symbol *type) { + const char *suffix = builtin_type_suffix(type); + unsigned bits = type->bit_size - is_signed_type(type); unsigned long long max = bits_mask(bits); char buf[32]; @@ -1174,10 +1176,8 @@ static void predefined_ctype(const char *name, struct symbol *type, int flags) const char *suffix = (flags & PTYPE_T) ? "_T" : ""; predefined_sizeof(name, suffix, bits); } - if (flags & PTYPE_MAX) { - const char *suffix = builtin_type_suffix(type); - predefined_max(name, suffix, bits - is_signed_type(type)); - } + if (flags & PTYPE_MAX) + predefined_max(name, type); if (flags & PTYPE_TYPE) predefined_type(name, type); if (flags & PTYPE_WIDTH) From patchwork Fri Dec 14 00:15:29 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: 10730147 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 CCF0E13BF for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCE3C2CDFD for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE7162CEFF; Fri, 14 Dec 2018 00:16:01 +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 59E4B2CEFD for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbeLNAQA (ORCPT ); Thu, 13 Dec 2018 19:16:00 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:43126 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbeLNAP7 (ORCPT ); Thu, 13 Dec 2018 19:15:59 -0500 Received: by mail-ed1-f67.google.com with SMTP id f9so3529722eds.10 for ; Thu, 13 Dec 2018 16:15:58 -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=Llq1Eh7Kd5F/x64MlDhEEWZX8TtleNQab1ebwgNwiNs=; b=vcoXwXFvc2GloLFk1QN/uCoQgyZr7KTwLuLOoGZyVAPls84tCthq+oAS5WSvFqzS3h +vFejjKQKUL609hOaFRNxPpO55l0PR09Hiw0EmRLnf0Y+IFYKHysFpcxEC6ZZeiELux8 ek2vY8/iCL27zmcrCmmU7D1043KPCtAI/68pC4LNIhrxGZoW69vq24BfrQ61O3CRspHB fO1eydGipCCrMT1ho08NNTPspk2iNwF6Dz8wKcCzaDf1IXkt23RMKCyAbIA4ofzWewVV Xg5IkC8KQniC78PTcHKzRiFdVZ2N9WdlROkkE8DzzavqNgMUNprYtXvDv0DYUreQdnft DTZw== 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=Llq1Eh7Kd5F/x64MlDhEEWZX8TtleNQab1ebwgNwiNs=; b=drQkrW0NMalJdsersAFyHRd7XZMeuvkCZOMthwYRG7UMnfkthIb1MyZ1+GutIPxyJW 4vJzxmZSh1t2/TugQxkQiRQa6JQ85yAfuE9lTF5si2rGxkKz4rTRmTZRf55aHjw5Almz s6+MvoZYNL/cwcLuJWWceVmqfq712hw6wI0eGOM7D5WgJH/36oXnat5DxlrcMbrcmROx bGsMG2OUEUersPmpMF3Tq6PB5oJsBSTrW6LwWUR06YtCWnwFmkr2q8u+gCj+TViO4/aH ZcwlNhSLqSWdahl+G591Kz/XpPVf01GXHlm88PaUfwWnvhgc4FpOaAM2lPAcqJB+4RCd 4wrQ== X-Gm-Message-State: AA+aEWbh5EbrTltyAox7mq6hdRmBtUeWtTM6gCjeLcV8Y0PcPvr5R8mn dbkzH3OUAHnO1yVijfFskfyTZzXC X-Google-Smtp-Source: AFSGD/V59uhiheFQWkfQVuIUDxtEwUfK7UDl+nQ1wsdOTY+8Bm3Qe20yktn12x8PIwB511LN6X8jFA== X-Received: by 2002:a17:906:7751:: with SMTP id o17-v6mr840838ejn.15.1544746557246; Thu, 13 Dec 2018 16:15:57 -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.15.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:56 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 12/19] add predefined macros for wint_t Date: Fri, 14 Dec 2018 01:15:29 +0100 Message-Id: <20181214001536.6259-13-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 This type seems to use 'unsigned int' on all archs but for Darwin & FreeBSD. Signed-off-by: Luc Van Oostenryck --- lib.c | 1 + target.c | 5 +++++ target.h | 1 + 3 files changed, 7 insertions(+) diff --git a/lib.c b/lib.c index d03bb856e..359b3ed49 100644 --- a/lib.c +++ b/lib.c @@ -1231,6 +1231,7 @@ static void predefined_macros(void) predefined_ctype("SHRT", &short_ctype, PTYPE_MAX|PTYPE_WIDTH); predefined_ctype("SCHAR", &char_ctype, PTYPE_MAX|PTYPE_WIDTH); predefined_ctype("WCHAR", wchar_ctype, PTYPE_ALL_T|PTYPE_TYPE); + predefined_ctype("WINT", wint_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("INT", &int_ctype, PTYPE_ALL); predefined_ctype("LONG", &long_ctype, PTYPE_ALL); diff --git a/target.c b/target.c index 27503e244..279d1142d 100644 --- a/target.c +++ b/target.c @@ -7,6 +7,7 @@ struct symbol *size_t_ctype = &uint_ctype; struct symbol *ssize_t_ctype = &int_ctype; struct symbol *wchar_ctype = &int_ctype; +struct symbol *wint_ctype = &uint_ctype; /* * For "__attribute__((aligned))" @@ -68,4 +69,8 @@ void init_target(void) default: break; } + +#if defined(__FreeBSD__) || defined(__APPLE__) + wint_ctype = &int_ctype; +#endif } diff --git a/target.h b/target.h index 74f51ffeb..998d25af5 100644 --- a/target.h +++ b/target.h @@ -4,6 +4,7 @@ extern struct symbol *size_t_ctype; extern struct symbol *ssize_t_ctype; extern struct symbol *wchar_ctype; +extern struct symbol *wint_ctype; /* * For "__attribute__((aligned))" From patchwork Fri Dec 14 00:15:30 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: 10730149 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 EC7573E9D for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE19E2CEE0 for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1C832CDFD; Fri, 14 Dec 2018 00:16:01 +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 7AC572CEE0 for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727245AbeLNAQB (ORCPT ); Thu, 13 Dec 2018 19:16:01 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:44917 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728540AbeLNAQA (ORCPT ); Thu, 13 Dec 2018 19:16:00 -0500 Received: by mail-ed1-f65.google.com with SMTP id y56so3526761edd.11 for ; Thu, 13 Dec 2018 16:15:59 -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=RdMNSjtT27hm7Vr6xCyv2glRQzEYLWVaHEd0a2SsLoo=; b=KBxBit/HrPYCdPASoOnfwZJlxLfMEz6Q2IB/5zDHnYu2MMuL1mpf3+9HuSDJQ1UUB2 Pqjf7reLSqFnaGB0fCR531R59kVtu5sgMrdN49O84tJFRsjE/Zd+AvQtzcLy5C5whA5T omR+vmL/T+F7hgX8AKuIgpNAMVxegAquOQuuI9ILQDmCpEyF4ZHVbLGJDG5nXOGxknXu 22iwM7vIXdOW6nGhwuA2eq2iEMQe9pWGpyc2RZY30tBrMEiRlq9ee7hhPpzB3CXa/ras +JtpgwPD42u+YYLt/zFTf2FZs37ec89AZsHX4GIqT2wCNIu9Caqt7rafpibpr/Uu+suI t5Ig== 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=RdMNSjtT27hm7Vr6xCyv2glRQzEYLWVaHEd0a2SsLoo=; b=TOTQgWVTsYnVvyyvr18i0IHJmITDPFa/UvwwUKOkNmbweYcHfACCS87RI64t1WkgCx DY0yv3wO0+fyiE5pAnrl+yol8OmOU2y4av9gQgcwM+V63RUazLi4778S1WcVP47K3eEh HdvzlryX4XduBE+TrBQ9mclXjnqYKfHlGrsviVwD4B8MhwuoNU8IggAtXl1/PPEOitID a9d8UyZUzgwRK3lXfRdwcAC5GMtToES5fGF5hqNnUqUO8emoKjgku5Kvh7vLN/aN13vP 1M8s4sfdOaKd7nLF8VbIbUZdL1oZVD/cn3c1zZbXzxUhjFKpBikQzndb6MKzJb9HEKM6 zh4g== X-Gm-Message-State: AA+aEWbHNIUt9HpMHlT/DmBod9kd43D8iv8eOF0V6oI428sZJ0jl2mVV BJVqQMBVunvHCpry/U3Q5y+QkO2J X-Google-Smtp-Source: AFSGD/VECiwrONb8VJ+GIHNWKyI309fiCOjzNjG4gAuBWb8G4t+xEWRXYnasey3g6Vnst7ok+4Cs4Q== X-Received: by 2002:aa7:dace:: with SMTP id x14mr1102238eds.13.1544746558191; Thu, 13 Dec 2018 16:15:58 -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.15.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:57 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 13/19] add predefined macros for [u]intptr Date: Fri, 14 Dec 2018 01:15:30 +0100 Message-Id: <20181214001536.6259-14-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 Luckily, it seems all archs use for them the same types as size_t & ssize_t. Signed-off-by: Luc Van Oostenryck --- lib.c | 2 ++ validation/preprocessor/predef.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib.c b/lib.c index 359b3ed49..50d5b61d3 100644 --- a/lib.c +++ b/lib.c @@ -1239,6 +1239,8 @@ static void predefined_macros(void) predefined_sizeof("INT128", "", 128); + predefined_ctype("INTPTR", ssize_t_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); + predefined_ctype("UINTPTR", size_t_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("PTRDIFF", ssize_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("SIZE", size_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("POINTER", &ptr_ctype, PTYPE_SIZEOF); diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index 298bdd93c..df0944b33 100644 --- a/validation/preprocessor/predef.c +++ b/validation/preprocessor/predef.c @@ -17,6 +17,8 @@ int test(void) TEST_SMAX(INT, int); TEST_SMAX(LONG, long); TEST_SMAX(LONG_LONG, long long); + TEST_SMAX(INTPTR, __INTPTR_TYPE__); + TEST_UMAX(UINTPTR, __UINTPTR_TYPE__); TEST_SMAX(PTRDIFF, __PTRDIFF_TYPE__); TEST_UMAX(SIZE, __SIZE_TYPE__); From patchwork Fri Dec 14 00:15:31 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: 10730151 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 3F68D1759 for ; Fri, 14 Dec 2018 00:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 311952CDFD for ; Fri, 14 Dec 2018 00:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25A392CEE0; Fri, 14 Dec 2018 00:16:02 +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 BDAED2CF02 for ; Fri, 14 Dec 2018 00:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbeLNAQB (ORCPT ); Thu, 13 Dec 2018 19:16:01 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41308 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbeLNAQB (ORCPT ); Thu, 13 Dec 2018 19:16:01 -0500 Received: by mail-ed1-f68.google.com with SMTP id z28so3539881edi.8 for ; Thu, 13 Dec 2018 16:15:59 -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=aSXqy+TNCJ+IsrdCwhHAx72zLUYi7UozrL0QKWEDaN8=; b=F6LrdA4ZJHTv8PHlAMJPHvUQdFNZUpN3OWN0K6cmZfS3v4n9v4IN9ky0/f+74rbGoD BEpThW/nLtICsFPseSh5uWDEipXi/pxDwNQkOuGIgp/kQD8xVHE/EpRLTXqgBxACxStU wcr/zLh3EPhLlCdQrw0f9l9eTf6Vz1Y5TYrjgICBYzpJUK1SsyMF6ZrM+oj1T5HKJ9Fw trmgXBan8Chd3mYhzi0cyvEU3Fh4yraSNT3vTZDgVgsznYeFmQ+DkiSf3OgdxH9wigpP 5z6PCfg3xJ5sYDX2v5JqL9KqVOIieFEJkEJTltF7wkNMa8CUPoFrZg7t4LjZw5owZ/Cr 0T7A== 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=aSXqy+TNCJ+IsrdCwhHAx72zLUYi7UozrL0QKWEDaN8=; b=JLTw/5rFkLoRa9EKMoho+KWHvuK6Q7S6dtSdNIaKNO6TVOgosWwjLRcBhoNdmvvB0b OAkTI29kBhdbuoFcrJkMWg5lR0Y4vcN0VDF/JT6EcTX/6kn3zdJKoYyWYvZVW/g0BqiB yBH8oxTQ+Bw6ShFRX9p1wCB19lMsn5XApg4LAVhjJvD4F22C2cqfjMG3dcphd75okAbK EsbFvXZtQT8SX5W88mS7G76CByp+w4uMVuu6tFJEJdFaPD62ls4V+Le2kEbz7V0LWQ56 FmQC3rGfVOGiFLv/uHNHNU4X0H4tFi4GWxVhTktXX4StKajg6zGe5Br27bk/zKBy2iIS b/iQ== X-Gm-Message-State: AA+aEWY1EEnVeAf8BcdkT5s9nIN8g2vecjBcbcpOEEWaLxHgb2VjKnrV xcDCOQ6IqJI7PR+LMbR+n3y72PYd X-Google-Smtp-Source: AFSGD/WgrPhJeIPGwZtS3OotYwFQ+wkXtFbYxPfoWn2W9L1qnFBfz2nz+NZ3iGxOCxJDaG0D4sGEHg== X-Received: by 2002:a50:b103:: with SMTP id k3mr998251edd.247.1544746559115; Thu, 13 Dec 2018 16:15:59 -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.15.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:58 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 14/19] add predefined macros for [u]intmax Date: Fri, 14 Dec 2018 01:15:31 +0100 Message-Id: <20181214001536.6259-15-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 Seems to use [u]long for all LP64 archs and [u]llong and all LP32 ones (but OpenBSD but it seems to not defines the corresponding macros). Signed-off-by: Luc Van Oostenryck --- lib.c | 6 ++++++ target.c | 2 ++ target.h | 2 ++ validation/preprocessor/predef.c | 2 ++ 4 files changed, 12 insertions(+) diff --git a/lib.c b/lib.c index 50d5b61d3..3a4f9820a 100644 --- a/lib.c +++ b/lib.c @@ -474,12 +474,16 @@ static void handle_arch_m64_finalize(void) goto case_x86_64; case ARCH_LP32: /* default values */ + intmax_ctype = &llong_ctype; + uintmax_ctype = &ullong_ctype; return; case ARCH_LP64: bits_in_long = 64; max_int_alignment = 8; size_t_ctype = &ulong_ctype; ssize_t_ctype = &long_ctype; + intmax_ctype = &long_ctype; + uintmax_ctype = &ulong_ctype; predefine("__LP64__", 1, "1"); predefine("_LP64", 1, "1"); goto case_64bit_common; @@ -1239,6 +1243,8 @@ static void predefined_macros(void) predefined_sizeof("INT128", "", 128); + predefined_ctype("INTMAX", intmax_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); + predefined_ctype("UINTMAX", uintmax_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("INTPTR", ssize_t_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); predefined_ctype("UINTPTR", size_t_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_ctype("PTRDIFF", ssize_t_ctype, PTYPE_ALL_T|PTYPE_TYPE); diff --git a/target.c b/target.c index 279d1142d..313288258 100644 --- a/target.c +++ b/target.c @@ -6,6 +6,8 @@ struct symbol *size_t_ctype = &uint_ctype; struct symbol *ssize_t_ctype = &int_ctype; +struct symbol *intmax_ctype = &llong_ctype; +struct symbol *uintmax_ctype = &ullong_ctype; struct symbol *wchar_ctype = &int_ctype; struct symbol *wint_ctype = &uint_ctype; diff --git a/target.h b/target.h index 998d25af5..d764d4182 100644 --- a/target.h +++ b/target.h @@ -3,6 +3,8 @@ extern struct symbol *size_t_ctype; extern struct symbol *ssize_t_ctype; +extern struct symbol *intmax_ctype; +extern struct symbol *uintmax_ctype; extern struct symbol *wchar_ctype; extern struct symbol *wint_ctype; diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index df0944b33..22e89bbc0 100644 --- a/validation/preprocessor/predef.c +++ b/validation/preprocessor/predef.c @@ -17,6 +17,8 @@ int test(void) TEST_SMAX(INT, int); TEST_SMAX(LONG, long); TEST_SMAX(LONG_LONG, long long); + TEST_SMAX(INTMAX, __INTMAX_TYPE__); + TEST_UMAX(UINTMAX, __UINTMAX_TYPE__); TEST_SMAX(INTPTR, __INTPTR_TYPE__); TEST_UMAX(UINTPTR, __UINTPTR_TYPE__); TEST_SMAX(PTRDIFF, __PTRDIFF_TYPE__); From patchwork Fri Dec 14 00:15:32 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: 10730153 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 7755213AF for ; Fri, 14 Dec 2018 00:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694072CDFD for ; Fri, 14 Dec 2018 00:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DBC32CEF2; Fri, 14 Dec 2018 00:16:03 +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 11D8C2CDFD for ; Fri, 14 Dec 2018 00:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728587AbeLNAQC (ORCPT ); Thu, 13 Dec 2018 19:16:02 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35536 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbeLNAQC (ORCPT ); Thu, 13 Dec 2018 19:16:02 -0500 Received: by mail-ed1-f65.google.com with SMTP id x30so3576983edx.2 for ; Thu, 13 Dec 2018 16:16:01 -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=utG2oJcLHk7+iLZq5QNnzrHUgcvVA3GZdyixRFFTy9Y=; b=EwBlvj5BJuESMnhUOT1fSP5LqFl6l5pV+Jm+NeOdE/LDCMKNhSNs+v8RXglZ9HHIsj 2ZHBcfB6OmfOlp+woEVgM995Qfcc9J0lk+krNvWTVmgw8Nf962zTsPrh33nBVFeXJUjs LvFI+/HW79oq+NH5GmiFO24yJ/S9GymFbHi/+bWOiQBlIsh8sU5afPBYSns9/sjhhN07 oDJx8sgxHNlYtS9n7QzwMqnmlRDEl2VTMGq+AEOLO/PFniP1mwA39AS17HVl2Qec/Coh zC8yVb3VEh4CCriGY5FVJv0alDDH7UQyw+h2PCDCo/vNmjV1P2Ke4rDreOIbDg7MGftA AW+g== 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=utG2oJcLHk7+iLZq5QNnzrHUgcvVA3GZdyixRFFTy9Y=; b=lqHkwDGKSc9dyw6OCdppd4ypbdQduRmdOFBocQiF45wvjbqRUkldF3Rz1TPgn49cXS 75xLlv4DWpjwZkgipuSHrbzpPF9BJya4KLZsR31mGk0ngoEcAIT6RasMRtCIZwdtzSk6 kOgvTP0A61qKPJQdHJpXG5Wp6xQ8TnHv3EnZ9YLd/mGwuI69PdtYo6b4gmqVfCA2BknJ 1QDHmyIovdHXkNiWLa+lFOAHgN9jtkHiYLeE72toRJHsuMO+cDIw53ILlddbeNsQF5X+ utB0nR4CYtbeXML6GISrIgZf6brJapG1Fo84/mHF81bK3+FviYTNQXGAjbT8slXUjIrg 5w0A== X-Gm-Message-State: AA+aEWYmgPhXi1LWndcLNmV5cLsSompI3vDP0pyn5hPwxZrOfgDan+ds vcHPId2ALd2V0WGTP/5AS3EwWrDg X-Google-Smtp-Source: AFSGD/UqznWrSAgMiiqfGghBKq7G/77DxErQmcMGqxS4K43Tj037Q0aaJqT8PXx7wwFVZUkVTqiv0g== X-Received: by 2002:a50:b667:: with SMTP id c36mr1122535ede.190.1544746560432; Thu, 13 Dec 2018 16:16:00 -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.15.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:15:59 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 15/19] add predefined macros for [u]int{8,16}_t Date: Fri, 14 Dec 2018 01:15:32 +0100 Message-Id: <20181214001536.6259-16-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 All LP64 & LP32 use [u]char and [u]short for these ones. Signed-off-by: Luc Van Oostenryck --- lib.c | 5 +++++ validation/preprocessor/predef.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib.c b/lib.c index 3a4f9820a..cd427e078 100644 --- a/lib.c +++ b/lib.c @@ -1241,6 +1241,11 @@ static void predefined_macros(void) predefined_ctype("LONG", &long_ctype, PTYPE_ALL); predefined_ctype("LONG_LONG", &llong_ctype, PTYPE_ALL); + predefined_ctype("INT8", &schar_ctype, PTYPE_MAX|PTYPE_TYPE); + 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_sizeof("INT128", "", 128); predefined_ctype("INTMAX", intmax_ctype, PTYPE_MAX|PTYPE_TYPE|PTYPE_WIDTH); diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index 22e89bbc0..7a7b575a3 100644 --- a/validation/preprocessor/predef.c +++ b/validation/preprocessor/predef.c @@ -17,6 +17,10 @@ int test(void) TEST_SMAX(INT, int); TEST_SMAX(LONG, long); TEST_SMAX(LONG_LONG, long long); + TEST_MAX( INT8, 0x7f); + TEST_MAX(UINT8, 0xffU); + TEST_MAX( INT16, 0x7fff); + TEST_MAX(UINT16, 0xffffU); TEST_SMAX(INTMAX, __INTMAX_TYPE__); TEST_UMAX(UINTMAX, __UINTMAX_TYPE__); TEST_SMAX(INTPTR, __INTPTR_TYPE__); From patchwork Fri Dec 14 00:15:33 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: 10730155 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 9EB3B13BF for ; Fri, 14 Dec 2018 00:16:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 908BA2CDFD for ; Fri, 14 Dec 2018 00:16:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 850B92CEF2; Fri, 14 Dec 2018 00:16:04 +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 220502CDFD for ; Fri, 14 Dec 2018 00:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728596AbeLNAQD (ORCPT ); Thu, 13 Dec 2018 19:16:03 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33622 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbeLNAQD (ORCPT ); Thu, 13 Dec 2018 19:16:03 -0500 Received: by mail-ed1-f66.google.com with SMTP id p6so3577558eds.0 for ; Thu, 13 Dec 2018 16:16:02 -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=QE7TXtmjQVIUJ+MYXhjYih7p31vVzveYnmRQ5EF1IFI=; b=AQ8pz/FceiDD4xZd6wlYjy1WYvgBzAaWvQWPdotgfhT+0DHQPgL1Oo4u3CWoXMTXTX BDEia3cfdTvREwtZ+5JLqlVNwX69lcvhPYlPAO3FA0OjT2ray2cMHnMq2c2RALTPs2kk BoTxgAKJdjQwfeq3pnM6j9s0u3fLSXJ6VTkFR28lXJS+2QnXLgm7IHdydDtq7ApATCoM fy9Ev6hhYRpm7KYAqe+L9Z8F+0W7qScCoBKYDw5dVJ6TWeeNuK1XqJt1Ei0S3Lczgxwz 7mgQkfdWYUid1hiwC4B3Ang3DpBodSYI+eLag/M6hH+W/KWRrY4kOs45JAbDqE+lnD2a KKFQ== 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=QE7TXtmjQVIUJ+MYXhjYih7p31vVzveYnmRQ5EF1IFI=; b=iMWbZ/agxgEI7tRdwdayMWe89wYNGaSyBjaPXmnbzrhK4siX0aVj2c8AK6p1PsyRvW JiUOkm1nRHyeJF0k2TNg2ZzmD/9nskouzHJIzbj/kEyqPc+zr2TB+uhv4Wax5s8UE6PX kOxdLTFvrpCEUh4hocX46UgwyKmD6MT26R2NqYI+SmNtxIj6fCpx+v8G/Helka2iaTHT 3GF/EPENoCQlcgIodZANxOqdYw8g0WYzs6/01rclAHMKecQWkzW2p9jbqgcHnm46BYdZ 3oEFnCUH2Qszhaw/jwqDlAye00tmPw6oOSK0MszGJ//nhYA5obcEKbzXzEBvHTQ3Mqp7 9Jig== X-Gm-Message-State: AA+aEWainHc9UMel6zyQOiP6GCSIGzgVdCf/8Blg9w+W0+Rh+QqGdMm7 RTXP+0FK0MsRFWeNUTEYwckYNAK4 X-Google-Smtp-Source: AFSGD/UatGbgWXIZf7OdRBq2ltTv0/KoXSozT9tox3L7KvIgkEz86RoAZUdjQBnqvUEEIh+Z1C6BLw== X-Received: by 2002:a50:940b:: with SMTP id p11mr1004363eda.135.1544746561597; Thu, 13 Dec 2018 16:16:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:16:01 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 16/19] add predefined macros for [u]int64_t Date: Fri, 14 Dec 2018 01:15:33 +0100 Message-Id: <20181214001536.6259-17-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 All LP32 archs use [u]llong and all LP64 use [u]long for these but Darwin which seems to always use [u]llong. Signed-off-by: Luc Van Oostenryck --- lib.c | 8 ++++++++ target.c | 6 ++++++ target.h | 2 ++ validation/preprocessor/predef.c | 2 ++ 4 files changed, 18 insertions(+) diff --git a/lib.c b/lib.c index cd427e078..f9015ef35 100644 --- a/lib.c +++ b/lib.c @@ -471,9 +471,13 @@ static void handle_arch_m64_finalize(void) max_int_alignment = 8; predefine("__ILP32__", 1, "1"); predefine("_ILP32", 1, "1"); + int64_ctype = &llong_ctype; + uint64_ctype = &ullong_ctype; goto case_x86_64; case ARCH_LP32: /* default values */ + int64_ctype = &llong_ctype; + uint64_ctype = &ullong_ctype; intmax_ctype = &llong_ctype; uintmax_ctype = &ullong_ctype; return; @@ -492,6 +496,8 @@ static void handle_arch_m64_finalize(void) max_int_alignment = 8; size_t_ctype = &ullong_ctype; ssize_t_ctype = &llong_ctype; + int64_ctype = &llong_ctype; + uint64_ctype = &ullong_ctype; predefine("__LLP64__", 1, "1"); goto case_64bit_common; case_64bit_common: @@ -1245,6 +1251,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("INT64", int64_ctype, PTYPE_MAX|PTYPE_TYPE); + predefined_ctype("UINT64", uint64_ctype, PTYPE_MAX|PTYPE_TYPE); predefined_sizeof("INT128", "", 128); diff --git a/target.c b/target.c index 313288258..fe3756f80 100644 --- a/target.c +++ b/target.c @@ -8,6 +8,8 @@ struct symbol *size_t_ctype = &uint_ctype; struct symbol *ssize_t_ctype = &int_ctype; 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 *wchar_ctype = &int_ctype; struct symbol *wint_ctype = &uint_ctype; @@ -75,4 +77,8 @@ void init_target(void) #if defined(__FreeBSD__) || defined(__APPLE__) wint_ctype = &int_ctype; #endif +#if defined(__APPLE__) + int64_ctype = &llong_ctype; + uint64_ctype = &ullong_ctype; +#endif } diff --git a/target.h b/target.h index d764d4182..7b1d96498 100644 --- a/target.h +++ b/target.h @@ -5,6 +5,8 @@ extern struct symbol *size_t_ctype; extern struct symbol *ssize_t_ctype; extern struct symbol *intmax_ctype; extern struct symbol *uintmax_ctype; +extern struct symbol *int64_ctype; +extern struct symbol *uint64_ctype; extern struct symbol *wchar_ctype; extern struct symbol *wint_ctype; diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c index 7a7b575a3..f00a471fc 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( INT64, 0x7fffffffffffffffLL); + TEST_MAX(UINT64, 0xffffffffffffffffULL); TEST_SMAX(INTMAX, __INTMAX_TYPE__); TEST_UMAX(UINTMAX, __UINTMAX_TYPE__); TEST_SMAX(INTPTR, __INTPTR_TYPE__); 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__); From patchwork Fri Dec 14 00:15:35 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: 10730159 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 B886013AF for ; Fri, 14 Dec 2018 00:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABD712CDFD for ; Fri, 14 Dec 2018 00:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A01902CEFD; Fri, 14 Dec 2018 00:16:06 +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 462512CDFD for ; Fri, 14 Dec 2018 00:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728425AbeLNAQG (ORCPT ); Thu, 13 Dec 2018 19:16:06 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:37943 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbeLNAQF (ORCPT ); Thu, 13 Dec 2018 19:16:05 -0500 Received: by mail-ed1-f67.google.com with SMTP id h50so3555132ede.5 for ; Thu, 13 Dec 2018 16:16:04 -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=iPNiHsJqH2lBOzrbq+4ehq7jHKf5dy9gV4y6HCAGC28=; b=JfetNircDdYpKVw75cUywbEUK7j00mdGPyhiGptve9VL8sM3AsLgcJGHmN1lugmLCB b7cGU0exnTN88VxG0FMm5NZkFQuOmirxWcl2PuW8VdR4ui7cpjFo41UkgQ2yWJSR/uOT iXuyMkbcDCDWHKMpOo31+2uK9UrWKzpxcA3SwvxuaiYrh57LyrI4U52OG2RSeSGqM3aO 6GMAbx5PdzM8YPR2H+G876e3s7EyMOlfsxjglqKDU7I109BYA6hnfiVwMik3DMFCTTNX hq9zkGyNnwkhgPUzieQBXiTgf/P3T87O4yfPInkW6B9+lxwrGo3yjeEMn2Y9h0pgC1l8 NFoA== 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=iPNiHsJqH2lBOzrbq+4ehq7jHKf5dy9gV4y6HCAGC28=; b=ZCT+xZQyHPQfhrAo86r6KaCDogUIojlWxoG1/YymDCVU8gg2FQbpVwI6If1G48tG5l XdkIDNQDmQeaw2dbL/cviE91Xyb09xwKIX507bEtbU4dleE98INhL8TSSGKzl+T86r+s vSfKNFcCCRoLVLic4BJf1eockf3QvthXePk2deVXa2aPZi7YzYdKXHOyvZe/8Fym8L9Z eQIr/3WyGW+Kp3iGOb6Ovih1mIMmuhqugz3q8VMqwC5hD5a3+rr04+sLW74TmCMDKmm+ 1/6clD6qv7+9PEp9zInvJZZv8e2K1rwiCS+MFqMEhVqLukM8kq/tX4erfn1Thp5nSmmd mSmQ== X-Gm-Message-State: AA+aEWaggOKXLDUh0zT/YYPRhHnqlV6Uk+VOytUlgWctdEXl0d5Mgp7M AvbR8rWQNN9e+itVbQwhMjghAxiT X-Google-Smtp-Source: AFSGD/WNy/mdazfTV4FSFQTObB1QclvGN0G+CUa+qayZHhNfcQcObdt2kvOcBD/v6JSBU4cN8+X+kQ== X-Received: by 2002:a17:906:c5a:: with SMTP id t26-v6mr866652ejf.140.1544746563431; Thu, 13 Dec 2018 16:16:03 -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.02 (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 18/19] add predefined macros for char{16,32}_t Date: Fri, 14 Dec 2018 01:15:35 +0100 Message-Id: <20181214001536.6259-19-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 types are supposed to be defined the same as uint_least{8,16}_t. So define them as 'ushort' and 'uint'. Note: it seems that some archs define char32_t as 'ulong' although their 'uint' is 32bit ... Signed-off-by: Luc Van Oostenryck --- lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib.c b/lib.c index 3084b6197..23d5ec417 100644 --- a/lib.c +++ b/lib.c @@ -1250,6 +1250,8 @@ static void predefined_macros(void) predefined_ctype("SCHAR", &char_ctype, PTYPE_MAX|PTYPE_WIDTH); predefined_ctype("WCHAR", wchar_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("WINT", wint_ctype, PTYPE_ALL_T|PTYPE_TYPE); + predefined_ctype("CHAR16", &ushort_ctype, PTYPE_TYPE); + predefined_ctype("CHAR32", &uint_ctype, PTYPE_TYPE); predefined_ctype("INT", &int_ctype, PTYPE_ALL); predefined_ctype("LONG", &long_ctype, PTYPE_ALL); From patchwork Fri Dec 14 00:15:36 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: 10730161 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 E9E9213BF for ; Fri, 14 Dec 2018 00:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4262CDFD for ; Fri, 14 Dec 2018 00:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFCCC2CEF2; Fri, 14 Dec 2018 00:16:06 +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 8247B2CEE0 for ; Fri, 14 Dec 2018 00:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbeLNAQG (ORCPT ); Thu, 13 Dec 2018 19:16:06 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:41315 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728612AbeLNAQF (ORCPT ); Thu, 13 Dec 2018 19:16:05 -0500 Received: by mail-ed1-f66.google.com with SMTP id z28so3540004edi.8 for ; Thu, 13 Dec 2018 16:16:05 -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=tVFB86skACZqaAn/OvGTJm8QctEteMPr3wWsZ/0zMno=; b=f+7axiNIjKqONYOqzZDDK4vSeosvIqGoEW/XqriDkNYVTzGPBqyOVYDGpWeGfI5kKD TliCCdkuPEYSZ9BGCbNb72rCxd4rNch2IwIhUSzM4i28hM1AU0POFS7nU7MYBCwIIXSL qc+9W1dXMqCM/bpaAZGGkdytyz4S2/8t+8t+BbDvi+wIWuzFCiz8WVz0ZYmhZ//FSDvF y/Iy6c+A25if/EkSrgKHY2YhrH065WgoREheZDYLSds+OaDrJZE9269SfCAVSeNxhS5Q wHCj8ck8ihoGj34koDiJJNwZ3N6LsXKtSLQl2zqaGoupofb0MdYi1+f/tBY1FLxLYEMf OB/g== 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=tVFB86skACZqaAn/OvGTJm8QctEteMPr3wWsZ/0zMno=; b=nqKr8zqXLnhJCO7w7FD99mjXZtMoVgl2VDdhw1oCEiz9UKnF2cFAdhpdAOsca7O6Al r/6cV0VT/wvxpRp8UmZiNBlc1B7+Wnms3Yg411WXy8wqmunRQ7FPWnriyEx3iV3S9Rqf pzRQW4ezFjGNMsYT8AoJ1/45+yT0Sm0qU+vK6pb0i0R9kK+q6n7gFbz9EEjpd5C8Q1F4 cmMZbxXHMddqj8Ho1tG0OaaR6+nAob4aY9iTZfrONDKETWkQRESxK5/SiWfVyW0yoptE utrN6kTJ2ql8CS1xoxNjAWncYn5Fq94VxKfBwJ5YpLoGdKmo7mVJorBKBJoTkCrztotx PtXA== X-Gm-Message-State: AA+aEWZLLOLtjHYc09+RIjDGCzvZGikfvZL/9/QfKB9q8WtubIAj47oc oyKMf9a+i2DXBuiHIo56/h+hBSBU X-Google-Smtp-Source: AFSGD/X0C+wszd5+HH0HedubEDcOkd5yH/z9Ja6DqhDJ7ikZYsdYDI/r12+hUu1LgLppltTSAgWVgQ== X-Received: by 2002:a17:906:2452:: with SMTP id a18-v6mr813556ejb.17.1544746564157; Thu, 13 Dec 2018 16:16:04 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 16:16:03 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Ramsay Jones , Luc Van Oostenryck Subject: [PATCH v3 19/19] fix the size of long double Date: Fri, 14 Dec 2018 01:15:36 +0100 Message-Id: <20181214001536.6259-20-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 The odd on here is, of course i386, with its 80-bit extended floats taking 12 bytes. Idem for __m68k__. Signed-off-by: Luc Van Oostenryck --- target.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/target.c b/target.c index ad12b630c..1f71743e3 100644 --- a/target.c +++ b/target.c @@ -38,9 +38,9 @@ int max_int_alignment = 4; */ int bits_in_float = 32; int bits_in_double = 64; -int bits_in_longdouble = 80; +int bits_in_longdouble = 128; -int max_fp_alignment = 8; +int max_fp_alignment = 16; /* * Pointer data type @@ -93,6 +93,27 @@ void init_target(void) break; } + switch (arch_mach) { + case MACH_ARM: + case MACH_MIPS32: + case MACH_S390X: + case MACH_SPARC32: + bits_in_longdouble = 64; + max_fp_alignment = 8; + break; + case MACH_X86_64: + if (arch_m64 == ARCH_LP64) + break; + /* fall through */ + case MACH_I386: + case MACH_M68K: + bits_in_longdouble = 96; + max_fp_alignment = 4; + break; + default: + break; + } + #if defined(__FreeBSD__) || defined(__APPLE__) wint_ctype = &int_ctype; #endif