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