Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2903251rwb; Fri, 2 Dec 2022 17:32:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6j0lGhWv7FXht9WCkvXmFmUlloXIvjRxlVlAviiGiRDbDQ8QUjN+5UnyIvr9w2xeb2PmTh X-Received: by 2002:a05:6402:1117:b0:46b:6da7:e8a9 with SMTP id u23-20020a056402111700b0046b6da7e8a9mr18439972edv.401.1670031156055; Fri, 02 Dec 2022 17:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670031156; cv=none; d=google.com; s=arc-20160816; b=aeH8t3Q2p6jyl229xPzdf16KIW0//7rVNqvump1JCoaOP0wBnOqC2KK8wPxI9Ivctn mDFFrbRkPnhpgquVWF+x7FrzlnzjHWSqNsZCk/QUD9f4IDjqoThGmjpRVc/n5udOiyC2 j3gQbMeCLhtmTxkqVByLI9uKNXcidUX8kr4w0N4qvHy42Y94/pQyQ4SUQ4HzWrQk6jXd EK/dvWxURvLEnEztL5JhwHXUXfxO1TU+3sihT5h3foSwR89NFkTQx1Lslq0ZokEoPJ0L nESMop/V342QKnhuDnStkP0mUA4laZ4pK2EfILGLdf2xkd+GZVpKSDMEPFaoVsegilLT CY9g== 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=wCAULVZ3kXh3arFt940euBarohCCAdayTSGVr11UNQE=; b=IRmlQ+M6Obt0QgBOlloTf9xpyAs6uDHUGinemKmkabGE+m2fEOASY9wsW9jXGKVtlA mUfuxcKzEwbLasQtVMs9LcpY1s/9nHKQXcQ3ufxjEdcPcBfiPkMgDGNCV3lYGEu/XXxJ sCE4WeYKbsEta3Ie4+CWmQe5/vl9e7Iq4j4vSP13RiXIiRcAUbpSisNa+PgXpbLXoAxP k9xU08kVCJEOONo+JIMIBE81l90cfUB42k0bATn6IX5xVAdAaDXTXKEb9br5UA3vqQvZ EZHhYWXSrNPsB9AH2Q5SyxLcHO6+C9kbru8qhVzVZBRPcqY3YgcJUdUQS2j3Q9GGHKac UpgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o1UYvdMw; 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 dz11-20020a0564021d4b00b0046a7f3ddb8csi7765602edb.523.2022.12.02.17.32.16; Fri, 02 Dec 2022 17:32:36 -0800 (PST) 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=o1UYvdMw; 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 S235349AbiLCAzE (ORCPT + 82 others); Fri, 2 Dec 2022 19:55:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235028AbiLCAyf (ORCPT ); Fri, 2 Dec 2022 19:54:35 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A418B1FB; Fri, 2 Dec 2022 16:53:58 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id fc4so8224749ejc.12; Fri, 02 Dec 2022 16:53:58 -0800 (PST) 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:subject:date:message-id:reply-to; bh=wCAULVZ3kXh3arFt940euBarohCCAdayTSGVr11UNQE=; b=o1UYvdMwwEDE3C8NpaeVcrWPOlcHesZjhpAL2qKoF7Zowpb/3VstnMBHy7bmeQt93K A5xqoq/9cXrWv+lQl5AVP1s1cO3kwnr6Hm7vpKLlz1PA3cbi2w8h6SyuGrVV7pDna2wP MdNQwp7QOPYavOIZysXnAZvrtAiHwXusFnDVIYizoS3qtTBdsbAjBqMcF8XI1dAkCV1j XUnJ9EPjfCMZbpBDVNmXENkdiQ1nCbeNV2q9MXdLFgqJ5/bWUOaMYPoIqfLqbgL8oidf 7QQSxuLnWau9qcMyx2hPBFapgIzbs05X+AbRs58IP2kZApKmCWdSmJgBUPfVA/kgORPk 0D7w== 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:subject:date:message-id :reply-to; bh=wCAULVZ3kXh3arFt940euBarohCCAdayTSGVr11UNQE=; b=vcXviy86SwG/FivDH7UQCOR7Q2I94dTzZI88bsNbutB0Shb4b7Cwg5tHkHAIvCVFXu TnGQGWJzBcjld/cvph0GZ2q2qFknrVsVttcxOQmsYogf74+M+6K5IFVLH2T5X/dsFxi/ TC5w/szu0k5YGeoMzHq0MNLy1+X3g4FvZ21szzH9AJB3BRTSOv3ZGMCmSfMZuRebs+6N CwKwRZ0LFu5ZKbeTf00KRg8DSaf4oIiDcY1LNvM6TwhV6ST45sHpkg8IqjluuB4CBYJt rjZxPiFeJ8OGwUWEN3y3Mf02d/SzvoMoK8D9f8c8GQOiQM9pA5qbOFxURa9LoTdDq4CI 8hMQ== X-Gm-Message-State: ANoB5pkyxe5MvP/qA+JNqoQO6+lw7N1OxX8wrT73AtKdljnvDO+HE0OJ 30+DbtkLc8EW6XPEp96QRTy6/CbTtfRZotQoHZA= X-Received: by 2002:a17:906:414c:b0:7a9:ecc1:2bd2 with SMTP id l12-20020a170906414c00b007a9ecc12bd2mr50745008ejk.545.1670028837001; Fri, 02 Dec 2022 16:53:57 -0800 (PST) MIME-Version: 1.0 References: <20220826012614.552860-1-james.hilliard1@gmail.com> In-Reply-To: From: Andrii Nakryiko Date: Fri, 2 Dec 2022 16:53:44 -0800 Message-ID: Subject: Re: [PATCH] selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym To: James Hilliard 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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, Dec 2, 2022 at 4:41 PM James Hilliard wrote: > > On Sat, Aug 27, 2022 at 1:08 PM Andrii Nakryiko > wrote: > > > > On Sat, Aug 27, 2022 at 3:47 AM James Hilliard > > wrote: > > > > > > 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." > > > > > > > Sigh, ok. Ghost functions: you can't use them without ctype.h, but you > > can't define your own either. Very nice. > > > > Can you please put all these details into a commit for the future? With that: > > Sure > > > > > Acked-by: Andrii Nakryiko > > Is this good to apply or should I send a v2? please add those details and resend v2? > > > > > > > > > > > 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 > > > > >