From patchwork Fri Aug 13 01:25:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Du X-Patchwork-Id: 12434477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6945C4338F for ; Fri, 13 Aug 2021 01:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8044A60232 for ; Fri, 13 Aug 2021 01:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238116AbhHMB0c (ORCPT ); Thu, 12 Aug 2021 21:26:32 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:55405 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238139AbhHMB0c (ORCPT ); Thu, 12 Aug 2021 21:26:32 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 38EE95C0081; Thu, 12 Aug 2021 21:26:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 Aug 2021 21:26:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=naive.systems; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=lh885xoYjkGpc aMTuALUig7UH7CVNQqBjYBbRHJwB5c=; b=Ewx4ceMDGRHNN/B41Gx6M6hwcx5CE dqCBbT5nTtbInWTtNdbBJW4zjSYv9HS479qI6uePzLvb1IPiz2uXUmy6zGSsEfSs xDqXCmPKemC9h5WlNwrQow8fjn0ENmzDTXpowJYgMBck0vHZQZZJgsODdUttVFiW EyKrSJuF4v/81wzXRWEgSKxUbr2ByMRegRYB5XbRrKej0YJ1j+Ue17vkt8WV7tXS kzWvg0BZi335lKT77zrzJvQAu+752w2DjlIVoQsGH0lv9TG6y4h43jvfkSqjL1Fx Qw/AN10PxXObt0HOI5Qw8ufjiiFMCiEX27VF4n6CHlgWgeKerY7qcyM7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=lh885xoYjkGpcaMTuALUig7UH7CVNQqBjYBbRHJwB5c=; b=Uzbx8F8+ Uqj0wlLUBGQO5cFhnGPntCmRXqHwiErB0yBSFdJFtugI3l3ea1BQXiffaDtK76+9 LFZPUjmO1l49sy8kXW5fMaNhqNorJkDdmOsP0GadEpZOdB3SA6sK0s681eOHfX6N BT+NwkIp+W7N0EmLLmsIQ9Lskdt0MWujaIwAjJ/ttCBlr4A4U1KFHG3vv09x6jhS Bm+93xGbXEp7Qs+2qhwsWFMgCq4jCE5wuh2ANqPsHlcr9WbbJHWG7o0b+DCsrlHR sZqMWbb1tvI4bGncr+88BaWF9b+jD0XxI++XcohOG1NMxIagXgwq0B37xO+wTpb8 cshRmrto9M8u2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkeeggdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfgvucffuhcu oeguuhhkvgesnhgrihhvvgdrshihshhtvghmsheqnecuggftrfgrthhtvghrnhepteeute euffdvueefvefhvdfgudfhgeejheekfefftdelfedtkeekgfevffetteehnecuvehluhhs thgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepughukhgvsehnrghivh gvrdhshihsthgvmhhs X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Aug 2021 21:26:05 -0400 (EDT) From: Ke Du To: luc.vanoostenryck@gmail.com Cc: linux-sparse@vger.kernel.org, Ke Du , Xiao Jia Subject: [PATCH 1/2] expose more functions to C++ in header files Date: Thu, 12 Aug 2021 20:25:10 -0500 Message-Id: <20210813012511.65397-2-duke@naive.systems> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210813012511.65397-1-duke@naive.systems> References: <20210726182822.ylmd3vtm44txowoi@mail> <20210813012511.65397-1-duke@naive.systems> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Delete or shrink the ifndef __cplusplus guard to expose more facilities to C++, such as sparse_initialize and the FOR_EACH_PTR macro. Signed-off-by: Ke Du Reviewed-by: Xiao Jia --- lib.h | 4 ++-- ptrlist.h | 2 +- symbol.h | 3 --- token.h | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib.h b/lib.h index 9809feee..0e9bd0cd 100644 --- a/lib.h +++ b/lib.h @@ -85,8 +85,6 @@ DECLARE_PTR_LIST(string_list, char); typedef struct pseudo *pseudo_t; -#ifndef __cplusplus - #ifdef __GNUC__ #define FORMAT_ATTR(pos) __attribute__ ((__format__ (__printf__, pos, pos+1))) #define NORETURN_ATTR __attribute__ ((__noreturn__)) @@ -143,6 +141,8 @@ extern struct symbol_list *sparse_keep_tokens(char *filename); extern struct symbol_list *sparse(char *filename); extern void report_stats(void); +#ifndef __cplusplus + static inline int symbol_list_size(struct symbol_list *list) { return ptr_list_size((struct ptr_list *)(list)); diff --git a/ptrlist.h b/ptrlist.h index e281309f..67c7a208 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -109,6 +109,7 @@ extern void __free_ptr_list(struct ptr_list **); DO_REVERSE(ptr, __head##ptr, __list##ptr, __nr##ptr, __rname##new, \ new, __head##new, __list##new, __nr##new, PTR_ENTRY_UNTAG) +#endif // __cpluplus #define FOR_EACH_PTR(head, ptr) \ DO_FOR_EACH(head, ptr, __head##ptr, __list##ptr, __nr##ptr, __name##ptr, PTR_ENTRY_NOTAG) @@ -311,5 +312,4 @@ static inline void *tag_ptr(void *ptr, unsigned long tag) return (void *)(tag | (unsigned long)ptr); } -#endif // __cpluplus #endif /* PTR_LIST_H */ diff --git a/symbol.h b/symbol.h index 503c9f09..c9d221e7 100644 --- a/symbol.h +++ b/symbol.h @@ -220,8 +220,6 @@ struct symbol { pseudo_t pseudo; }; -#ifndef __cplusplus - /* Modifiers */ #define MOD_AUTO 0x00000001 #define MOD_REGISTER 0x00000002 @@ -591,5 +589,4 @@ static inline void combine_address_space(struct position pos, } } -#endif // __cplusplus #endif /* SYMBOL_H */ diff --git a/token.h b/token.h index 1f3601a9..804cc6f8 100644 --- a/token.h +++ b/token.h @@ -197,7 +197,7 @@ struct token { }; }; -#ifndef __cplusplus + #define MAX_STRING 8191 @@ -251,5 +251,4 @@ static inline int match_token_zero(struct token *token) return token->number[0] == '0' && !token->number[1]; } -#endif // __cplusplus #endif From patchwork Fri Aug 13 01:25:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Du X-Patchwork-Id: 12434479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2054C4338F for ; Fri, 13 Aug 2021 01:26:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF09360F57 for ; Fri, 13 Aug 2021 01:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238173AbhHMB05 (ORCPT ); Thu, 12 Aug 2021 21:26:57 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:43979 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238139AbhHMB05 (ORCPT ); Thu, 12 Aug 2021 21:26:57 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CE9745C0129; Thu, 12 Aug 2021 21:26:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 12 Aug 2021 21:26:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=naive.systems; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=pXU2IlpXOBXDH +xpk2NQLCpGgsTo3x4TM8oZtbWZWHI=; b=H2ystZ9NgPaWQttoEn9p39umauYxh EO9seIOLbRBFElM249eblMrM/yrYbos3WWL+w0k1I66Y3S2wMq8P8H+f4h1dCqgp DdVh7BrlMGP9x3NAGPYgFtvsyauJD5IWl0tDN0gDfZO3a1fwOmCTslgcYIiJbpsj eFQj6UkMSPFoo9FNQOI2Q9PDqEWyiuaXVwIhom4/HumrBxaLYP6xIEHVfxCmFyUi YZ/B31A+U4mcG9bGhVFp8KpiEgUCmr/qLN3ItLrtc4kYnBFJkG8Tssr6p6SMklmG YiPdOa6ObSwqfT9dkZ/QACRaJkvV501xEGEhYgYV6Y7ihYcy5gPwrqVjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=pXU2IlpXOBXDH+xpk2NQLCpGgsTo3x4TM8oZtbWZWHI=; b=rICW8RHr Zu1rvwd/+0NDoEw+WfTwvIZ9td+aupq+J+0MLPX0chQ5f/GtTATt1KqqAF2Lstxj rth1lBJdxRnpVeWqGW6fmJ73NXpg6vFcnhFBGhJuYt8YRUtV+OpPxznDmgT/kr9V hjc6rPVNPRZYTSSpUBn3qSBhM1vmu/yfjfAFEtAi5ep8lb+2WL9MvrKz/kts1huA QHi22emoxRjZJMgtQO6xBwKh4E5a+wf8T20aWk/ynk1gjHQlPyVqv2SRVq4ZaCFg I0qX0po5BxoZJPkWdaz6zlXFzzdvsSIseinnIi45oeVy0sTMh65R9U6NMzN7ImF/ Iz3ZllWrupVI/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkeeggdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfgvucffuhcu oeguuhhkvgesnhgrihhvvgdrshihshhtvghmsheqnecuggftrfgrthhtvghrnhepteeute euffdvueefvefhvdfgudfhgeejheekfefftdelfedtkeekgfevffetteehnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughukhgvsehnrghivh gvrdhshihsthgvmhhs X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Aug 2021 21:26:30 -0400 (EDT) From: Ke Du To: luc.vanoostenryck@gmail.com Cc: linux-sparse@vger.kernel.org, Ke Du , Xiao Jia Subject: [PATCH 2/2] make implicit type conversion explicit Date: Thu, 12 Aug 2021 20:25:11 -0500 Message-Id: <20210813012511.65397-3-duke@naive.systems> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210813012511.65397-1-duke@naive.systems> References: <20210726182822.ylmd3vtm44txowoi@mail> <20210813012511.65397-1-duke@naive.systems> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Make implicit type converison from void* to other types explicit so ptrlist.h and token.h can be included as C++ library. Without this change, when including these in C++, clang complains that it cannot initialize return object of a more specific type with an lvalue of type void*. Signed-off-by: Ke Du Reviewed-by: Xiao Jia --- ptrlist.h | 2 +- token.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index 67c7a208..9fd20f84 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -303,7 +303,7 @@ extern void split_ptr_list_head(struct ptr_list *); static inline void update_tag(void *p, unsigned long tag) { - unsigned long *ptr = p; + unsigned long *ptr = (unsigned long *)p; *ptr = tag | (~3UL & *ptr); } diff --git a/token.h b/token.h index 804cc6f8..7a97a478 100644 --- a/token.h +++ b/token.h @@ -204,7 +204,7 @@ struct token { static inline struct token *containing_token(struct token **p) { void *addr = (char *)p - ((char *)&((struct token *)0)->next - (char *)0); - return addr; + return (struct token *)addr; } #define token_type(x) ((x)->pos.type)