[cfe-users] cacheflush.2

Alejandro Colomar (man-pages) via cfe-users cfe-users at lists.llvm.org
Fri Dec 11 10:14:07 PST 2020


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 *'.
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
>>>
>>
> 

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es


More information about the cfe-users mailing list