Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7602204ioo; Fri, 3 Jun 2022 09:39:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyQb4Kb5PGFPvFXtQH7h2qv+MK1QcSucdkXmBG1r78c4oazPrWnLO1+ziMH9ZthwQCCpWW X-Received: by 2002:a17:90a:a393:b0:1d0:e448:811d with SMTP id x19-20020a17090aa39300b001d0e448811dmr47391227pjp.97.1654274347940; Fri, 03 Jun 2022 09:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654274347; cv=none; d=google.com; s=arc-20160816; b=c6CqnRYFEz5VFTt2MDnMTVmEdeLgGSf4iVTtOhi+tVSZ+8kFgEFoDNDgvvLTWLvefy 5Bn2s5T1FwtezG5ZKXAEymVWW5a/cIELc+CXoin02CcroP12D8uP9IfcsJM2rFyUmBzw hGGqXZ7ANJ8vSVQwZD4xVGQCBAs6NQ4Hbs3o6T2cZvl1gjwgmE5e8de0GINeBo5Vd5qB ZTAqTjTwKAbykYuMF50YLKJg3xo8LmBiaKY9+wK/Eo22MbYg8+MHFa6j8Cy0+5hHAuli +uJ0EsC1qk+zAB5eRQTWkw7XBgXLk3gSYzsK5UzLiqP9vOhlIASsl+6c/j1eauZ7xzaM At0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=8MGcac1+NMnCFqTNkAP3LH9iYhQFVupT03fTHS13h/k=; b=qj/YiMdytGkprOF0+0iekmrJURVNqYgZGTBFbOP4dEpOVBlNHo5oN+sk8ortE1J/TZ smnEXWjQhVxkLgx/tfB7D6W6RRu8XsXMEavnclSNmlKJUEXtlqDhddLmDvit5ZtvjlXH 2PvDzp0OFlB9Kb0zcQMFDGNIZvqpG7ZlfRFh0q9tVsLNk+vev2/a+dBfadMitZWe9vV9 1ALg/cHqb4Wj5/9WzlA2ALJFCnHk244quWCfCwqpQ8P9H7NP8n1pmAH+OtWSN8FzxBHa wU50AFIZZi4kLcDgShtoXLc6ohcxsTKTQYIszLOfjbF/ORYhgNV9ZxLK5VcqmRIPS+7C tQOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=F1Frl6Xm; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a17090a9f0100b001e0cf692b8dsi14358836pjp.80.2022.06.03.09.38.52; Fri, 03 Jun 2022 09:39:07 -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=@google.com header.s=20210112 header.b=F1Frl6Xm; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235323AbiFCFwF (ORCPT + 99 others); Fri, 3 Jun 2022 01:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237523AbiFCFwD (ORCPT ); Fri, 3 Jun 2022 01:52:03 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43BC2AC0 for ; Thu, 2 Jun 2022 22:52:01 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id i8-20020a170902c94800b0016517194819so3700345pla.7 for ; Thu, 02 Jun 2022 22:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=8MGcac1+NMnCFqTNkAP3LH9iYhQFVupT03fTHS13h/k=; b=F1Frl6XmIOttiQHw5FYbqF5lSf7HlRCqVLHgOovpTeymFO1a9nMk21DnGkcnWy4hIV ZofZpNRqKGZ8xlqbJvoXaYY0iS7U9QTfQ6uNUByBlD9w/w+Co2Vs1TUrcf2R3FMqTwaM N4OxKdK3ljmff2HKEmldBCuFo49YnQjVgDwcJ1la+nvxmCo57wL+RrSJks4HfYIRKFVX YYMje3sos8w6ArzxpkSeu7M3qla0CTNY6jUFPOabo+MPoy6TEs5qajEt/P7fSdh3fgmn BJpO2las5+kqfhfJRbREihkHZgWFMXi/wOMsdYQShW6Gc9XRFv57eWR7nj/scGuK1Cw4 NY5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=8MGcac1+NMnCFqTNkAP3LH9iYhQFVupT03fTHS13h/k=; b=0AAlw+pYmti9+ZJKWY0V63xIBrVZc3lZmGR84GoBN0+IXsL0/FNX+flmH3G+17j7k/ OUD7BzILFmFqc28xabg7Db+geA0hXIAssGHLtKiUDEKOw4Yg1n8z24g84Q0eswe7KyMj ZcQCXV6zVacbueAfgq16Mj6eDNyuZoPVqQ4QHMkup+Mld3VMZLaY1bqiF7yzlXobtbDF bkB5o3G5/5+U2Zh7mM1NG7I/oBZC3ezIH/g/0TVTM8S0xr4z4MuPOYpQXAoze6mK/LW8 6YxasIB7jt+JwAXOYc2reXNEg5qL08xS3UnZq6J69B78mP+rJ8mw2UarHinrOQQrt3jb SNKg== X-Gm-Message-State: AOAM533O6E3LOkFzDO9oC/AY6Nmn4TeyvGVV9Hwm8e4Q69+MiNzQBUS8 o7fB6aK3nD+vdMgYpHGTDm741o8TWAQM X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:e5a:e82c:d3a4:578c]) (user=irogers job=sendgmr) by 2002:a17:90a:178f:b0:1e3:3ba:c185 with SMTP id q15-20020a17090a178f00b001e303bac185mr352114pja.1.1654235520615; Thu, 02 Jun 2022 22:52:00 -0700 (PDT) Date: Thu, 2 Jun 2022 22:51:56 -0700 Message-Id: <20220603055156.2830463-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog Subject: [PATCH v2] libbpf: Fix is_pow_of_2 From: Ian Rogers To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yuze Chi , Ian Rogers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 From: Yuze Chi Move the correct definition from linker.c into libbpf_internal.h. Reported-by: Yuze Chi Signed-off-by: Yuze Chi Signed-off-by: Ian Rogers --- tools/lib/bpf/libbpf.c | 5 ----- tools/lib/bpf/libbpf_internal.h | 5 +++++ tools/lib/bpf/linker.c | 5 ----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 3f4f18684bd3..346f941bb995 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -4954,11 +4954,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map) static void bpf_map__destroy(struct bpf_map *map); -static bool is_pow_of_2(size_t x) -{ - return x && (x & (x - 1)); -} - static size_t adjust_ringbuf_sz(size_t sz) { __u32 page_sz = sysconf(_SC_PAGE_SIZE); diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h index 4abdbe2fea9d..ef5d975078e5 100644 --- a/tools/lib/bpf/libbpf_internal.h +++ b/tools/lib/bpf/libbpf_internal.h @@ -580,4 +580,9 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man, const char *usdt_provider, const char *usdt_name, __u64 usdt_cookie); +static inline bool is_pow_of_2(size_t x) +{ + return x && (x & (x - 1)) == 0; +} + #endif /* __LIBBPF_LIBBPF_INTERNAL_H */ diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9aa016fb55aa..85c0fddf55d1 100644 --- a/tools/lib/bpf/linker.c +++ b/tools/lib/bpf/linker.c @@ -697,11 +697,6 @@ static int linker_load_obj_file(struct bpf_linker *linker, const char *filename, return err; } -static bool is_pow_of_2(size_t x) -{ - return x && (x & (x - 1)) == 0; -} - static int linker_sanity_check_elf(struct src_obj *obj) { struct src_sec *sec; -- 2.36.1.255.ge46751e96f-goog