public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>,
	gcc@gcc.gnu.org, Dave Martin <Dave.Martin@arm.com>,
	cfe-users@lists.llvm.org, linux-man@vger.kernel.org
Subject: Re: Ping: cacheflush.2
Date: Fri, 18 Dec 2020 09:51:45 -0700	[thread overview]
Message-ID: <b392d6ae-387f-6aff-5bb8-084ba7e74893@gmail.com> (raw)
In-Reply-To: <6ed5bc42-1d18-e963-fecc-cc9b1bfb2a2c@gmail.com>

On 12/18/20 3:42 AM, Alejandro Colomar (man-pages) wrote:
> Hi Martin,
> 
> I sent you an email, but I received a "delivery failure".
> If you're reading this from a list, could you answer, please?
> 
> Thanks,
> 
> Alex
> 
> On 12/14/20 11:34 PM, Alejandro Colomar (man-pages) wrote:
>> Hello Martin,
>>
>> Thanks for the correction!
>> Then the prototypes that changes from 'char *' to 'void *' in r269082
>> were not exposed to the user, right?
>> I guess then those are just internal implementation where GCC did use
>> 'char *'.

__builtin___clear_cache was added to GCC in r126535 (the __builtin_
prefix is added by the macro):

+DEF_EXT_LIB_BUILTIN    (BUILT_IN_CLEAR_CACHE, "__clear_cache", 
BT_FN_VOID_PTR_PTR, ATTR_NOTHROW_LIST)

The BT_FN_VOID_PTR_PTR macro describes its signature as returning
void and taking two void pointer arguments.  AFAIK, this has never
changed.  Contrary to that, the manual entry for the built-in added
in the same revision documented it as taking two char*.  That was
corrected to void* in r269082 to match.

There's a GCC internal declaration of __clear_cache (apparently
provided in libgcc for VxWorks).  It was added in r264479 and
it also used char*.  This was also changed to void* in r269082
to match the built-in.  Looks like this __clear_cache has just
been removed from libgcc in GCC 11:
https://gcc.gnu.org/pipermail/gcc-cvs/2020-December/338478.html

>>
>> Where is the actual prototype exposed to the user declared?

Built-in functions are declared implicitly by GCC.  They have no
explicit declarations like user-defined functions.  The implicit
internal "declarations" are specified in the GCC internal file
gcc/builtins.def, where they are hidden behind layers of macros.
For example, on the GCC 10 branch, the declaration for
__builtin___clear_cache is here:

https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/builtins.def;h=fa8b0641ab13b36f983c591a7020f6b432e5fb3d;hb=refs/heads/releases/gcc-10#l837

Martin

>>
>> Thanks,
>>
>> Alex
>>
>> P.S.: Michael, wait for a patch revision (v6).
>>
>> On 12/14/20 10:13 PM, Martin Sebor wrote:
>>> On 12/11/20 11:14 AM, Alejandro Colomar (man-pages) via Gcc wrote:
>>>> It looks like GCC recently moved from 'char *' to 'void *'.
>>>> This SO question[1] (4 years ago) quotes the GCC docs
>>>> and they had 'char *'.
>>>
>>> __builtin___clear_cache in GCC has always been declared to take
>>> void*.  The signature in the manual was recently corrected to match
>>> the implementation, i.e., from char* to void*, in r269082.
>>>
>>> Martin
>>>
>>>> Maybe Clang hasn't noticed the change.
>>>> I'll report a bug.
>>>>
>>>> [1]: https://stackoverflow.com/q/35741814/6872717
>>>>
>>>> On 12/9/20 8:15 PM, Alejandro Colomar (man-pages) wrote:
>>>>> Hi Heinrich,
>>>>>
>>>>> It looks like a bug (or at least an undocumented divergence from GCC) in
>>>>> Clang/LLVM.  Or I couldn't find the documentation for it.
>>>>>
>>>>> Clang uses 'char *':
>>>>> https://github.com/llvm/llvm-project/blob/7faf62a80bfc3a9dfe34133681fcc31f8e8d658b/clang/include/clang/Basic/Builtins.def#L583
>>>>>
>>>>>
>>>>> GCC uses 'void *':
>>>>> https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
>>>>>
>>>>> I CCd Clang and GCC lists; maybe they know about that divergence.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Alex
>>>>>
>>>>> On 12/9/20 7:48 PM, Heinrich Schuchardt wrote:
>>>>>> On 12/9/20 7:34 PM, Alejandro Colomar (man-pages) wrote:
>>>>>>> Hi Heinrich & Michael,
>>>>>>>
>>>>>>> What about the following?:
>>>>>>>
>>>>>>> [
>>>>>>> NOTES
>>>>>>>           GCC provides a similar function, which may be useful on
>>>>>>> archi‐
>>>>>>>           tectures that lack this system call:
>>>>>>>
>>>>>>>               void __builtin___clear_cache(void *begin, void *end);
>>>>>>> ]
>>>>>>
>>>>>> I just checked building with Clang/LLVM. There the arguments are of
>>>>>> type
>>>>>> (char *). See the following error output:
>>>>>>
>>>>>> +arch/sandbox/cpu/cache.c:19:26: error: passing 'uint8_t *' (aka
>>>>>> 'unsigned char *') to parameter of type 'char *' converts between
>>>>>> pointers to integer types with different sign [-Werror,-Wpointer-sign]
>>>>>> +        __builtin___clear_cache(state->ram_buf,
>>>>>> +                                ^~~~~~~~~~~~~~
>>>>>> +arch/sandbox/cpu/cache.c:20:12: error: passing 'uint8_t *' (aka
>>>>>> 'unsigned char *') to parameter of type 'char *' converts between
>>>>>> pointers to integer types with different sign [-Werror,-Wpointer-sign]
>>>>>> +                                state->ram_buf + state->ram_size);
>>>>>> +                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>
>>>>>> Best regards
>>>>>>
>>>>>> Heinrich
>>>>>>
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Alex
>>>>>>>
>>>>>>> On 12/9/20 7:04 PM, Heinrich Schuchardt wrote:
>>>>>>>> Hello Michael,
>>>>>>>>
>>>>>>>> function cacheflush() does not exist on many architectures.
>>>>>>>>
>>>>>>>> It would have saved me a lot of time if the man-page had referenced
>>>>>>>> GCC's
>>>>>>>>
>>>>>>>> void __builtin___clear_cache(void *begin, void *end)
>>>>>>>>
>>>>>>>> Maybe you can add it to NOTES.
>>>>>>>>
>>>>>>>> Best regards
>>>>>>>>
>>>>>>>> heirnich
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 


  reply	other threads:[~2020-12-18 16:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <794cf0d1-d528-4b5a-3ce0-b1b5f588dc6d@gmx.de>
     [not found] ` <ca265930-00d7-44f5-b2dd-535a5cf0310a@gmail.com>
     [not found]   ` <5257a883-29f0-6eaa-5708-d1f47356a57a@gmx.de>
2020-12-09 19:15     ` cacheflush.2 Alejandro Colomar (man-pages)
2020-12-11 18:14       ` cacheflush.2 Alejandro Colomar (man-pages)
2020-12-14 21:13         ` cacheflush.2 Martin Sebor
2020-12-14 22:34           ` cacheflush.2 Alejandro Colomar (man-pages)
2020-12-18 10:42             ` Ping: cacheflush.2 Alejandro Colomar (man-pages)
2020-12-18 16:51               ` Martin Sebor [this message]
2020-12-19 14:04                 ` Alejandro Colomar (man-pages)
     [not found]   ` <20201210181726.GT6882@arm.com>
     [not found]     ` <747d56e0-c102-ab40-add4-530a48a43a4d@gmx.de>
2020-12-10 20:56       ` RFC v2: cacheflush.2 Alejandro Colomar (man-pages)
2020-12-11  8:15         ` Michael Kerrisk (man-pages)
2020-12-11 18:02           ` Alejandro Colomar (man-pages)
2020-12-11 18:22             ` RFC v3: " Alejandro Colomar (man-pages)
2020-12-11 18:26               ` RFC v4: " Alejandro Colomar (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b392d6ae-387f-6aff-5bb8-084ba7e74893@gmail.com \
    --to=msebor@gmail.com \
    --cc=Dave.Martin@arm.com \
    --cc=alx.manpages@gmail.com \
    --cc=cfe-users@lists.llvm.org \
    --cc=gcc@gcc.gnu.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).