Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1242992rwe; Sat, 27 Aug 2022 04:06:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7yZsAJDeYeuFbgX2TKhdRvQrD1YWKiCp3dta5jyyzxGeMuQHZPK7y7vi4i9Jz0TtTP3/Ys X-Received: by 2002:a17:907:7208:b0:73d:7097:ac6f with SMTP id dr8-20020a170907720800b0073d7097ac6fmr8165261ejc.388.1661598368545; Sat, 27 Aug 2022 04:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661598368; cv=none; d=google.com; s=arc-20160816; b=k9mWwJKe8Ji5bK14ijeNbtIbmu8Me0UrKXXYaIOBH+8pHKlB5rv6Mbyav9QT49FtRG fIkxW/i3dve801owXcTGmqQGGHQ67AJ310+mbshKq07zkOiIdKxPVIcY02muDaFY50f3 GSPxeHmAWdDcSFcwm6iYDrwEr9R6hAleZSs4MuL86eZp7pE6JFwz1IRhfHppP8vrQxtn TdTNqOLR5ZlZWjTFHXbIM34Ssgu99xcQmQog1ZzxxXGvqPuD8ArwwJWLJBnHH8ukSqod xcMuoB1T5JMbMZX+tMke1ne22uG10ta6vo4O7lfXA3uLsbNkxJ8sIPoca2+zGtJZke/Z hqAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UiHwxXfvf1lDenWPgsX45rCLCR+OFcWjJxU/UZK7aIo=; b=skES2q9QwQlXCagSxqSpvIU/XalvT4W1TwhXMPKOW862ikoV08EuKWShhKpYMZmppo M0fw3sHeBVXd8uFso34nKGITkukIt6cfSMMYxsLLg5GuCCd5EgcVOEOnXJvNSywVoO89 kQ15/AxRnw/7QCBT7KYUO4jL9AczC7eC9MsOhtl6JZvV8Pm6LWnETpVNeDDDBIR/4K2k Q2A1nWlIVIMmkNkPCv/hNfB0sGa31gNRPMdhFCRjVp6/nW2gXSPA3/ff43HM3vbP3raa LOFlGoAij1SF1OfwZgOjvlXEksUxhbBfLlwtriJfJsUjzEz8B1lugHemlUH7d9BcaCWF lRDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N3jkl6qB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb38-20020a170907962600b0073d8691cf38si3030572ejc.526.2022.08.27.04.05.40; Sat, 27 Aug 2022 04:06:08 -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=@gmail.com header.s=20210112 header.b=N3jkl6qB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234391AbiH0Kre (ORCPT + 99 others); Sat, 27 Aug 2022 06:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiH0Krc (ORCPT ); Sat, 27 Aug 2022 06:47:32 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00DE1785B4; Sat, 27 Aug 2022 03:47:28 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id f17so3846419pfk.11; Sat, 27 Aug 2022 03:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=UiHwxXfvf1lDenWPgsX45rCLCR+OFcWjJxU/UZK7aIo=; b=N3jkl6qBfSNVLEFzksiBm1DIrDicLiM88RZroDY5uc2qA38yAEVblgA3G76oMG7d50 x3M5Bl9JDfgliUFD5LjuksYya1DfUD+E8UGgOUGcNEYLJ/0HzEseNeVT3X6hYPWlpIZt 4xHJOOnsSVyVi7fpzFxZSTcrx9xoeMXvExO9Mrht7bQRRyaUgq3iCJIOIoldSJXPmC8k w2NEcZBS75d1i7JSDHP2BaVrgQKRPKiH5ALpgt0S+ZZlzP3W86O52OwkY1JMimJnV8VF 0mu9g7UcHPJpZnc/9L8i45TSdUU4nDMrvETKkxvbxHUCyBva7ZhZb6S9mKJSR5jNbUl0 qYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=UiHwxXfvf1lDenWPgsX45rCLCR+OFcWjJxU/UZK7aIo=; b=YxEad2+uEQlBhkmGMo9M14D1rj0wjp7XPHXiSe0uV9Hp/zEv2SaRsd5UFLV7V0eDyH becS9jVGgFZQ/Bn12sZEtqQx2+70aQ1Dwb1aSgbqAol9nPnqdJmYBScKRap2Qt0Ob96P hFSzL2UA40LiWiWevrGetHAMAB8Sf7u6NolzC+Trxby58FF67PIRd7AEKL7m8FrddOO1 QcBLIKqrcDdYOGVVdY1CflKjgeFNxhR3W33qJlI+ORDNrfMXLCuNVfNfvYS+c6K74UQG 4n+cd1lSmPDUuOjZHpDTwQbT0D/rPYZJxp+dPJBuPjhl4anVjlWs2kv3bLHx+HESTTxd Uc4Q== X-Gm-Message-State: ACgBeo2jGS7NJUcG72PDMaNFuGGQ8i3WRopJ/zLb7DyKrM0u194c5MZI aGnswh0mSWWLtdWC4XtmtIt50+MRVmgh+puw1e0= X-Received: by 2002:a65:6944:0:b0:41b:4483:35cc with SMTP id w4-20020a656944000000b0041b448335ccmr6796918pgq.296.1661597247459; Sat, 27 Aug 2022 03:47:27 -0700 (PDT) MIME-Version: 1.0 References: <20220826012614.552860-1-james.hilliard1@gmail.com> In-Reply-To: From: James Hilliard Date: Sat, 27 Aug 2022 04:47:14 -0600 Message-ID: Subject: Re: [PATCH] selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym To: Andrii Nakryiko Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Alan Maguire , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 On Fri, Aug 26, 2022 at 10:55 PM Andrii Nakryiko wrote: > > On Thu, Aug 25, 2022 at 6:26 PM James Hilliard > wrote: > > > > Both tolower and toupper are built in c functions, we should not > > Really? How come? Can you point out where this is specified in C > standard? From what I can tell you have to include to get > toupper()/tolower(). See background on this sort of issue: https://stackoverflow.com/a/20582607 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12213 (C99, 7.1.3p1) "All identifiers with external linkage in any of the following subclauses (including the future library directions) are always reserved for use as identifiers with external linkage." > > This seems like yet another GCC-BPF quirk? Seems GCC takes a stricter interpretation of the standard here than llvm. It's also documented behavior in GCC: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-std-2 See: The ISO C90 functions abort, abs, acos, asin, atan2, atan, calloc, ceil, cosh, cos, exit, exp, fabs, floor, fmod, fprintf, fputs, free, frexp, fscanf, isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, tolower, toupper, labs, ldexp, log10, log, malloc, memchr, memcmp, memcpy, memset, modf, pow, printf, putchar, puts, realloc, scanf, sinh, sin, snprintf, sprintf, sqrt, sscanf, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncat, strncmp, strncpy, strpbrk, strrchr, strspn, strstr, tanh, tan, vfprintf, vprintf and vsprintf are all recognized as built-in functions unless -fno-builtin is specified (or -fno-builtin-function is specified for an individual function). We could disable builtin functions but it seems more correct to just rename it so that it doesn't conflict. > > > redefine them as this can result in a build error. > > > > Fixes the following errors: > > progs/bpf_iter_ksym.c:10:20: error: conflicting types for built-in function 'tolower'; expected 'int(int)' [-Werror=builtin-declaration-mismatch] > > 10 | static inline char tolower(char c) > > | ^~~~~~~ > > progs/bpf_iter_ksym.c:5:1: note: 'tolower' is declared in header '' > > 4 | #include > > +++ |+#include > > 5 | > > progs/bpf_iter_ksym.c:17:20: error: conflicting types for built-in function 'toupper'; expected 'int(int)' [-Werror=builtin-declaration-mismatch] > > 17 | static inline char toupper(char c) > > | ^~~~~~~ > > progs/bpf_iter_ksym.c:17:20: note: 'toupper' is declared in header '' > > > > Signed-off-by: James Hilliard > > --- > > tools/testing/selftests/bpf/progs/bpf_iter_ksym.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c b/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c > > index 285c008cbf9c..9ba14c37bbcc 100644 > > --- a/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c > > +++ b/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c > > @@ -7,14 +7,14 @@ char _license[] SEC("license") = "GPL"; > > > > unsigned long last_sym_value = 0; > > > > -static inline char tolower(char c) > > +static inline char to_lower(char c) > > { > > if (c >= 'A' && c <= 'Z') > > c += ('a' - 'A'); > > return c; > > } > > > > -static inline char toupper(char c) > > +static inline char to_upper(char c) > > { > > if (c >= 'a' && c <= 'z') > > c -= ('a' - 'A'); > > @@ -54,7 +54,7 @@ int dump_ksym(struct bpf_iter__ksym *ctx) > > type = iter->type; > > > > if (iter->module_name[0]) { > > - type = iter->exported ? toupper(type) : tolower(type); > > + type = iter->exported ? to_upper(type) : to_lower(type); > > BPF_SEQ_PRINTF(seq, "0x%llx %c %s [ %s ] ", > > value, type, iter->name, iter->module_name); > > } else { > > -- > > 2.34.1 > >