Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp381771imk; Sat, 2 Jul 2022 21:50:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uID5opsb58dTEJjHV4BD6Z3QGA/jpzv6iP7Cj1/m30s922mHGNwqXu1w0Z7pvPq1uTailc X-Received: by 2002:a17:907:7f8e:b0:726:41df:cbc6 with SMTP id qk14-20020a1709077f8e00b0072641dfcbc6mr22793572ejc.230.1656823812438; Sat, 02 Jul 2022 21:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656823812; cv=none; d=google.com; s=arc-20160816; b=035HkDOEA/0r2Xwb8aOTVXbIVgHTjaCmV5T24rH7IzgFrC0q7t9/PVzYlg4Qgmb4Z4 3bFwkUnvE/RRoJWdulUeWMU9nLSLar322A+Z5csvzGbqOOlPKMlHVnjv+ytEATMoQtKJ YSvQjXIwGvobfbM/VUwyN9I3Pk99oc1uz2CzhUIzsssKJHrMwjS62JEHnjTsb5c4Dpue hwQlvon1F98yfxfCdA7LXYb5dM1I2CrdI4PFVsfXclePXhCE6MnmBKisSMQBvouIzUIY GXqk9FcG+LxKGvaCIGuecwEoHVZ5um8DkWsI8/YiOGtJC/H/eorykg7y0uyr4My6J4PM q2LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=If/pilaQUcOJoPemXdCwt98hRdp4GDkn/LpQze2e7pA=; b=pf8qZTa0FXvUJ9rnMas9FDSAh4InTeTzRoKVwd/elPXO4/1LTc4UkQC28jTq9q4frd xNq/SwxNIylo1PKrH53j1Q2PIiFuv41CkKMOak2fIprSJD+ERvPhey5wFcNl1Wy5PnMi RngURPQSronxWgMd03cHZ6RJp9fdbSj0696qXE6hq4ZHSAl0KEwmw81JEVvfRY9KgULr DnifhfKdaU9y6gEkEi0J/+AOq8523MlW1jVS6vDa6aBHCDTuj9nQTgoVZ/3vsbtN7WTi BywPmM/x1iOLYLzAP9oIqehLhoc0+R4MeEG3lIn4RlaXErT20z4fnfv0UWnZgr3gvy6t xy+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm2 header.b=fmcCA4HD; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=lLDxBgk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a05640226c300b0043571fa0fcasi16751073edd.449.2022.07.02.21.49.47; Sat, 02 Jul 2022 21:50:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm2 header.b=fmcCA4HD; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=lLDxBgk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231261AbiGCEsX (ORCPT + 99 others); Sun, 3 Jul 2022 00:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbiGCEsT (ORCPT ); Sun, 3 Jul 2022 00:48:19 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A353D60 for ; Sat, 2 Jul 2022 21:48:17 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id E545D320085B; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 03 Jul 2022 00:48:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1656823695; x=1656910095; bh=If /pilaQUcOJoPemXdCwt98hRdp4GDkn/LpQze2e7pA=; b=fmcCA4HDPHbQ7xfb5D OC/UHa/I8tJW5f8NI4bZj8xgcB6VRjSH4Vzda716/DzC2cNF+xQcz59loX7DJmSF OKin5hv8FKUQqBz4rOIXMlwu8nLnCcx0aheKeJWxPR5YRHq4/0ZRqkg4GG/TJJsE Zw4JLIKe7kQg4Lfx4GfOZzZOAgF8WSeKRTARtED/bEdYRHbUyFpPuQTXizE/Ii5x pLj7Asn4J2bnKkUOTn0bLza5+USCuEO7onHncA9cHc3mMht8bowjk4x3HvAIU+lz 80TcdX7Gp71NWs2LWxQY0IZzmajn0BAt/LaQ04uJzgyVboYJooyG46cacgpfhQqz SOgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1656823695; x=1656910095; bh=If/pilaQUcOJo PemXdCwt98hRdp4GDkn/LpQze2e7pA=; b=lLDxBgk4ym0i3Lh+u1hW/c63U9TEO torBNInjQURaIyBkmrvUyOhNpncXOZfICuhVIrM3VxOU8ccOvz8AjQVWKf9d1kVS 4cgjFPClIx+cZXjkU3f8u0ozQNVBXHUkkATi8HEUqinGqoSgvCooGjSa1ZxXD1D/ LUQzBxmCQooPLp9Asrmc5A26vqZtF2TAMVSuxelQS/qU9tiZm5QibxzG2rMm47IL gzoy9Fd3QooTV23hcLcr+VqNV3UXJkAK71dsQ2xw8tufD8hx5xYjlJn/FPs712BA SkI0LNKaQ6SMCgWQpa4QVN7qayuFxcolIV+ep/YOV/bzaRMtPDf2O9QVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehiedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepleejgfdvfefhudektddtveegtdekieegffdtkeeljeetudevffeltdei feeugeeinecuffhomhgrihhnpehsohhurhgtvgifrghrvgdrohhrghdpkhgvrhhnvghlrd horhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep rghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Jul 2022 00:48:15 -0400 (EDT) From: Andres Freund To: linux-kernel@vger.kernel.org Cc: Quentin Monnet , Arnaldo Carvalho de Melo , Jiri Olsa , Alexei Starovoitov Subject: [PATCH v1 2/3] tools: add dis-asm-compat.h to centralize handling of version differences Date: Sat, 2 Jul 2022 21:48:12 -0700 Message-Id: <20220703044814.892617-3-andres@anarazel.de> X-Mailer: git-send-email 2.35.1.677.gabf474a5dd In-Reply-To: <20220703044814.892617-1-andres@anarazel.de> References: <20220622231624.t63bkmkzphqvh3kx@alap3.anarazel.de> <20220703044814.892617-1-andres@anarazel.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org binutils changed the signature of init_disassemble_info(), which now causes compilation failures for tools/{perf,bpf} on e.g. debian unstable. Relevant binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=60a3da00bd5407f07 This commit introduces a wrapper for init_disassemble_info(), to avoid spreading #ifdef DISASM_INIT_STYLED to a bunch of places. It likely is worth adding a wrapper for disassember(), to avoid the already existing #ifdef DISASM_FOUR_ARGS_SIGNATURE. Cc: Quentin Monnet Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Alexei Starovoitov Link: http://lore.kernel.org/lkml/20220622181918.ykrs5rsnmx3og4sv@alap3.anarazel.de Signed-off-by: Andres Freund --- tools/include/tools/dis-asm-compat.h | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tools/include/tools/dis-asm-compat.h diff --git a/tools/include/tools/dis-asm-compat.h b/tools/include/tools/dis-asm-compat.h new file mode 100644 index 000000000000..d1d003ee3e2f --- /dev/null +++ b/tools/include/tools/dis-asm-compat.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TOOLS_DIS_ASM_COMPAT_H +#define _TOOLS_DIS_ASM_COMPAT_H + +#include +#include +#include + +/* define types for older binutils version, to centralize ifdef'ery a bit */ +#ifndef DISASM_INIT_STYLED +enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; +typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, const char*, ...); +#endif + +/* + * Trivial fprintf wrapper to be used as the fprintf_styled_func argument to + * init_disassemble_info_compat() when normal fprintf suffices. + */ +static inline int fprintf_styled(void *out, + enum disassembler_style style __maybe_unused, + const char *fmt, ...) +{ + va_list args; + int r; + + va_start(args, fmt); + r = vfprintf(out, fmt, args); + va_end(args); + + return r; +} + +/* + * Wrapper for init_disassemble_info() that hides version + * differences. Depending on binutils version and architecture either + * fprintf_func or fprintf_styled_func will be called. + */ +static inline void init_disassemble_info_compat(struct disassemble_info *info, + void *stream, + fprintf_ftype unstyled_func, + fprintf_styled_ftype styled_func __maybe_unused) +{ +#ifdef DISASM_INIT_STYLED + init_disassemble_info(info, stream, + unstyled_func, + styled_func); +#else + init_disassemble_info(info, stream, + unstyled_func); +#endif +} + +#endif /* _TOOLS_DIS_ASM_COMPAT_H */ -- 2.35.1.677.gabf474a5dd