From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT 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 0660EC169C4 for ; Thu, 31 Jan 2019 18:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC078218AF for ; Thu, 31 Jan 2019 18:52:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lRx5uecG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbfAaSwK (ORCPT ); Thu, 31 Jan 2019 13:52:10 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44536 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727189AbfAaSwK (ORCPT ); Thu, 31 Jan 2019 13:52:10 -0500 Received: by mail-pl1-f196.google.com with SMTP id e11so1867884plt.11 for ; Thu, 31 Jan 2019 10:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zqLc5fLPyCw0T+VM1jTebql+sHgYuzYadeb/952GWNc=; b=lRx5uecGrPMjs3weGOQhI/hsryFFopMbeWsKTS6434OTvN2ybwmdlRljn0hxiMYD6s A0B0p6l+E0UgnLMKXzdmxPBj4AEui0temi7Rmm3cXGf0mVGKCUlplqmX825VS8C9TMAN OItniFQmCrDtOVn0N7wnESKU/XlchVFQUj/6qvi2k93kJCBLr7ZPLXE1KT4PbQJWRTFG jU+8rq6kLAep+lgcFOzZWt58Csrn5abkpq2OqmehVxiP8VYl6a6BIIja7nQLLOpvw2N7 MKJJlDhDJtaDNxHbmxUEtxOoyzWhtDg5RvXRFvT1g0zXDP8HJQdMrIAlVb5/eoHXNyAw F/1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zqLc5fLPyCw0T+VM1jTebql+sHgYuzYadeb/952GWNc=; b=L7qOVLQcDFsr4WmE4SEklkJLFhc4cHNfB90t/DOZ6q52cNWk2+Cayng3OoGY6nTJde STBZgUlu83LNTcQ8xqpyzjVzLZG15XCpvfP27Ib5+Bt/Phfkwv2X6lizc9kSHLbPnYlc 0xxn/yMtpSX+jsxOT7omOyIXRK4Du0iE22BBKN9KIOzSJZ6T0lltQDythKmbIJ73FRMx 1ra4UrOZLyowo+me4RSj45ZJBCJVlhCLXh4m60NPPTFaljIkJzAs2WCTaluUXlF5qbTD bpNXHzbfuTUof+47TYWyHWjj0TqfYjtCTdfe3Wzet1JASnu2xHvKEMra32Egc9tvk2Q7 GdmA== X-Gm-Message-State: AJcUukdaDLgSoS4JIumd3W2yvMpdkJHzQNG4ndaDKiA426XNSSuA6Q7e ka802SmYoT9KLk76OjaxCoA= X-Google-Smtp-Source: ALg8bN6pOiHwA6+UPrKS4ewtL8FGwWUIy/g8UYuu1QHjMGHGk/xaxVBxy+FuHlteQ18ttAv8D52AbA== X-Received: by 2002:a17:902:8a95:: with SMTP id p21mr36832722plo.183.1548960729564; Thu, 31 Jan 2019 10:52:09 -0800 (PST) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:200::5:1cca]) by smtp.gmail.com with ESMTPSA id h74sm14181365pfd.35.2019.01.31.10.52.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:52:08 -0800 (PST) Date: Thu, 31 Jan 2019 10:52:07 -0800 From: Alexei Starovoitov To: Magnus Karlsson Cc: bjorn.topel@intel.com, ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, jakub.kicinski@netronome.com, bjorn.topel@gmail.com, qi.z.zhang@intel.com, brouer@redhat.com, acme@kernel.org, yhs@fb.com Subject: Re: [PATCH bpf-next v3 1/3] libbpf: move pr_*() functions to common header file Message-ID: <20190131185206.6rvqxlvutpedwnqc@ast-mbp.dhcp.thefacebook.com> References: <1548774737-16579-1-git-send-email-magnus.karlsson@intel.com> <1548774737-16579-2-git-send-email-magnus.karlsson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1548774737-16579-2-git-send-email-magnus.karlsson@intel.com> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Jan 29, 2019 at 04:12:15PM +0100, Magnus Karlsson wrote: > Move the pr_*() functions in libbpf.c to a common header file called > libbpf_internal.h. This so that the later libbpf AF_XDP helper library > code in xsk.c can use these printing functions too. > > Signed-off-by: Magnus Karlsson > --- > tools/lib/bpf/libbpf.c | 30 +----------------------------- > tools/lib/bpf/libbpf_internal.h | 41 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 42 insertions(+), 29 deletions(-) > create mode 100644 tools/lib/bpf/libbpf_internal.h > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 2ccde17..1d7fe26 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -39,6 +39,7 @@ > #include > > #include "libbpf.h" > +#include "libbpf_internal.h" > #include "bpf.h" > #include "btf.h" > #include "str_error.h" > @@ -51,34 +52,6 @@ > #define BPF_FS_MAGIC 0xcafe4a11 > #endif > > -#define __printf(a, b) __attribute__((format(printf, a, b))) > - > -__printf(1, 2) > -static int __base_pr(const char *format, ...) > -{ > - va_list args; > - int err; > - > - va_start(args, format); > - err = vfprintf(stderr, format, args); > - va_end(args); > - return err; > -} > - > -static __printf(1, 2) libbpf_print_fn_t __pr_warning = __base_pr; > -static __printf(1, 2) libbpf_print_fn_t __pr_info = __base_pr; > -static __printf(1, 2) libbpf_print_fn_t __pr_debug; > - > -#define __pr(func, fmt, ...) \ > -do { \ > - if ((func)) \ > - (func)("libbpf: " fmt, ##__VA_ARGS__); \ > -} while (0) > - > -#define pr_warning(fmt, ...) __pr(__pr_warning, fmt, ##__VA_ARGS__) > -#define pr_info(fmt, ...) __pr(__pr_info, fmt, ##__VA_ARGS__) > -#define pr_debug(fmt, ...) __pr(__pr_debug, fmt, ##__VA_ARGS__) since these funcs are about to be used more widely let's clean this api while we still can. How about we convert it to single pr_log callback function with verbosity flag instead of three callbacks ?