All of lore.kernel.org
 help / color / mirror / Atom feed
* cacheflush.2
@ 2020-12-09 18:04 Heinrich Schuchardt
  2020-12-09 18:34 ` cacheflush.2 Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Heinrich Schuchardt @ 2020-12-09 18:04 UTC (permalink / raw)
  To: linux-man, Michael Kerrisk (man-pages)

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-09 18:04 cacheflush.2 Heinrich Schuchardt
@ 2020-12-09 18:34 ` Alejandro Colomar (man-pages)
  2020-12-09 18:48   ` cacheflush.2 Heinrich Schuchardt
  2020-12-10 18:17   ` cacheflush.2 Dave Martin
  0 siblings, 2 replies; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-09 18:34 UTC (permalink / raw)
  To: Heinrich Schuchardt, Michael Kerrisk (man-pages); +Cc: linux-man

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);
]

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; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-09 18:34 ` cacheflush.2 Alejandro Colomar (man-pages)
@ 2020-12-09 18:48   ` Heinrich Schuchardt
  2020-12-09 19:15     ` cacheflush.2 Alejandro Colomar (man-pages)
  2020-12-10 18:17   ` cacheflush.2 Dave Martin
  1 sibling, 1 reply; 27+ messages in thread
From: Heinrich Schuchardt @ 2020-12-09 18:48 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages), Michael Kerrisk (man-pages); +Cc: linux-man

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
>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-09 18:48   ` cacheflush.2 Heinrich Schuchardt
@ 2020-12-09 19:15     ` Alejandro Colomar (man-pages)
  2020-12-11 18:14       ` cacheflush.2 Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-09 19:15 UTC (permalink / raw)
  To: Heinrich Schuchardt, Michael Kerrisk (man-pages)
  Cc: linux-man, gcc, cfe-users

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; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-09 18:34 ` cacheflush.2 Alejandro Colomar (man-pages)
  2020-12-09 18:48   ` cacheflush.2 Heinrich Schuchardt
@ 2020-12-10 18:17   ` Dave Martin
  2020-12-10 19:20     ` cacheflush.2 Heinrich Schuchardt
  1 sibling, 1 reply; 27+ messages in thread
From: Dave Martin @ 2020-12-10 18:17 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages)
  Cc: Heinrich Schuchardt, Michael Kerrisk (man-pages), linux-man

On Wed, Dec 09, 2020 at 07:34:09PM +0100, 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);
> ]
> 
> Cheers,
> 
> Alex

Maybe we should discourage people from calling the cacheflush syscall?

I think that people shouldn't be using the syscall unless they really
need the finer grained control it provides, and are prepared to take a
hit to portability.

(On arches where userspace is allowed to do cache flushing directly,
__builtin___clear_cache() should transparently do the right thing, with
no syscall overhead -- if not, that's probably a bug in the toolchain or
compiler support library.)

[...]

Cheers
---Dave

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-10 18:17   ` cacheflush.2 Dave Martin
@ 2020-12-10 19:20     ` Heinrich Schuchardt
  2020-12-10 20:56       ` RFC v2: cacheflush.2 Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Heinrich Schuchardt @ 2020-12-10 19:20 UTC (permalink / raw)
  To: Dave Martin, Alejandro Colomar (man-pages)
  Cc: Michael Kerrisk (man-pages), linux-man

On 12/10/20 7:17 PM, Dave Martin wrote:
> On Wed, Dec 09, 2020 at 07:34:09PM +0100, 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);
>> ]
>>
>> Cheers,
>>
>> Alex
>
> Maybe we should discourage people from calling the cacheflush syscall?
>
> I think that people shouldn't be using the syscall unless they really
> need the finer grained control it provides, and are prepared to take a
> hit to portability.
>
> (On arches where userspace is allowed to do cache flushing directly,
> __builtin___clear_cache() should transparently do the right thing, with
> no syscall overhead -- if not, that's probably a bug in the toolchain or
> compiler support library.)

What the compiler builtin does depends on the architecture (e.g. nothing
for x86, cacheflush() for MIPS, a private syscall (0xf0002) on ARM,
assembly code on ARM64, ...) and on the the operating system (Linux,
BSD, OS X). For portable code the builtin is really the best choice.

Best regards

Heinrich

>
> [...]
>
> Cheers
> ---Dave
>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* RFC v2: Re: cacheflush.2
  2020-12-10 19:20     ` cacheflush.2 Heinrich Schuchardt
@ 2020-12-10 20:56       ` Alejandro Colomar (man-pages)
  2020-12-11  8:15         ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-10 20:56 UTC (permalink / raw)
  To: Heinrich Schuchardt, Dave Martin
  Cc: Michael Kerrisk (man-pages), linux-man, gcc, cfe-users

Hi all,

v2:

[
NOTES
       Unless  you  need  the finer grained control that this system
       call provides, you probably want  to  use  the  GCC  built-in
       function  __builtin___clear_cache(),  which  provides  a more
       portable interface:

           void __builtin___clear_cache(void *begin, void *end);
]

If you like it, I'll send the patch.

BTW, I'll also have a look and document the different prototypes for
cacheflush(2).

Thanks,

Alex

On 12/10/20 8:20 PM, Heinrich Schuchardt wrote:
> On 12/10/20 7:17 PM, Dave Martin wrote:
>> On Wed, Dec 09, 2020 at 07:34:09PM +0100, 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);
>>> ]
>>>
>>> Cheers,
>>>
>>> Alex
>>
>> Maybe we should discourage people from calling the cacheflush syscall?
>>
>> I think that people shouldn't be using the syscall unless they really
>> need the finer grained control it provides, and are prepared to take a
>> hit to portability.
>>
>> (On arches where userspace is allowed to do cache flushing directly,
>> __builtin___clear_cache() should transparently do the right thing, with
>> no syscall overhead -- if not, that's probably a bug in the toolchain or
>> compiler support library.)
> 
> What the compiler builtin does depends on the architecture (e.g. nothing
> for x86, cacheflush() for MIPS, a private syscall (0xf0002) on ARM,
> assembly code on ARM64, ...) and on the the operating system (Linux,
> BSD, OS X). For portable code the builtin is really the best choice.
> 
> Best regards
> 
> Heinrich
> 
>>
>> [...]
>>
>> Cheers
>> ---Dave
>>
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: RFC v2: Re: cacheflush.2
  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)
  0 siblings, 1 reply; 27+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-12-11  8:15 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages), Heinrich Schuchardt, Dave Martin
  Cc: mtk.manpages, linux-man, gcc, cfe-users

i Alex,

On 12/10/20 9:56 PM, Alejandro Colomar (man-pages) wrote:
> Hi all,
> 
> v2:
> 
> [
> NOTES
>        Unless  you  need  the finer grained control that this system
>        call provides, you probably want  to  use  the  GCC  built-in
>        function  __builtin___clear_cache(),  which  provides  a more
>        portable interface:
> 
>            void __builtin___clear_cache(void *begin, void *end);
> ]

This seems a reasonable text to me, but I think it would be helpful
to say a little more precisely what kind of portability we are
talking about here.

Greater ortability across Linux architectures? Greater portability
across platforms supported by GCC (including non-Linux) platforms?
Something else?

Thanks,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: RFC v2: Re: cacheflush.2
  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)
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-11 18:02 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages), Heinrich Schuchardt, Dave Martin
  Cc: linux-man, gcc, cfe-users

Hi Michael,

On 12/11/20 9:15 AM, Michael Kerrisk (man-pages) wrote:
> i Alex,
> 
> On 12/10/20 9:56 PM, Alejandro Colomar (man-pages) wrote:
>> Hi all,
>>
>> v2:
>>
>> [
>> NOTES
>>        Unless  you  need  the finer grained control that this system
>>        call provides, you probably want  to  use  the  GCC  built-in
>>        function  __builtin___clear_cache(),  which  provides  a more
>>        portable interface:
>>
>>            void __builtin___clear_cache(void *begin, void *end);
>> ]
> 
> This seems a reasonable text to me, but I think it would be helpful
> to say a little more precisely what kind of portability we are
> talking about here.
Sure.

> 
> Greater ortability across Linux architectures? Greater portability
> across platforms supported by GCC (including non-Linux) platforms?
> Something else?

'... which provides a portable interface across platforms supported by
GCC:' sounds good.

Maybe GCC devs have something more to add.

Thanks,

Alex

> 
> Thanks,
> 
> Michael
> 
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-09 19:15     ` cacheflush.2 Alejandro Colomar (man-pages)
@ 2020-12-11 18:14       ` Alejandro Colomar (man-pages)
  2020-12-14 21:13         ` cacheflush.2 Martin Sebor
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-11 18:14 UTC (permalink / raw)
  To: Heinrich Schuchardt, Michael Kerrisk (man-pages)
  Cc: linux-man, gcc, cfe-users, Dave Martin

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* RFC v3: Re: cacheflush.2
  2020-12-11 18:02           ` Alejandro Colomar (man-pages)
@ 2020-12-11 18:22             ` Alejandro Colomar (man-pages)
  2020-12-11 18:26               ` RFC v4: " Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-11 18:22 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages), Heinrich Schuchardt, Dave Martin
  Cc: linux-man, gcc, cfe-users

Hi all,

Please review this text:

[
NOTES
       Unless  you  need  the finer grained control that this system
       call provides, you probably want  to  use  the  GCC  built-in
       function  __builtin___clear_cache(),  which  provides  a more
       portable interface:

           void __builtin___clear_cache(void *begin, void *end);

       On platforms that don't require  instruction  cache  flushes,
       __builtin___clear_cache() has no effect.

       Note:  On  some  GCC-compatible compilers, such as clang, the
       prototype for this function uses char * instead of void *.
]

Thanks,

Alex

On 12/11/20 7:02 PM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
> 
> On 12/11/20 9:15 AM, Michael Kerrisk (man-pages) wrote:
>> i Alex,
>>
>> On 12/10/20 9:56 PM, Alejandro Colomar (man-pages) wrote:
>>> Hi all,
>>>
>>> v2:
>>>
>>> [
>>> NOTES
>>>        Unless  you  need  the finer grained control that this system
>>>        call provides, you probably want  to  use  the  GCC  built-in
>>>        function  __builtin___clear_cache(),  which  provides  a more
>>>        portable interface:
>>>
>>>            void __builtin___clear_cache(void *begin, void *end);
>>> ]
>>
>> This seems a reasonable text to me, but I think it would be helpful
>> to say a little more precisely what kind of portability we are
>> talking about here.
> Sure.
> 
>>
>> Greater ortability across Linux architectures? Greater portability
>> across platforms supported by GCC (including non-Linux) platforms?
>> Something else?
> 
> '... which provides a portable interface across platforms supported by
> GCC:' sounds good.
> 
> Maybe GCC devs have something more to add.

> 
> Thanks,
> 
> Alex
> 
>>
>> Thanks,
>>
>> Michael
>>
>>
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* RFC v4: Re: cacheflush.2
  2020-12-11 18:22             ` RFC v3: " Alejandro Colomar (man-pages)
@ 2020-12-11 18:26               ` Alejandro Colomar (man-pages)
  2020-12-14 11:43                   ` Alejandro Colomar
  2020-12-15 13:30                   ` Alejandro Colomar
  0 siblings, 2 replies; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-11 18:26 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages), Heinrich Schuchardt, Dave Martin
  Cc: linux-man, gcc, cfe-users

I forgot to add a junk to the text.

v4:

NOTES
       Unless  you  need  the finer grained control that this system
       call provides, you probably want  to  use  the  GCC  built-in
       function __builtin___clear_cache(), which provides a portable
       interface across platforms supported by  GCC  and  compatible
       compilers:

//Maybe 'and compatible compilers' is redundant and I should remove it?

           void __builtin___clear_cache(void *begin, void *end);

       On  platforms  that  don't require instruction cache flushes,
       __builtin___clear_cache() has no effect.

       Note: On some GCC-compatible compilers, such  as  clang,  the
       prototype for this function uses char * instead of void *.


On 12/11/20 7:22 PM, Alejandro Colomar (man-pages) wrote:
> Hi all,
> 
> Please review this text:
> 
> [
> NOTES
>        Unless  you  need  the finer grained control that this system
>        call provides, you probably want  to  use  the  GCC  built-in
>        function  __builtin___clear_cache(),  which  provides  a more
>        portable interface:
> 
>            void __builtin___clear_cache(void *begin, void *end);
> 
>        On platforms that don't require  instruction  cache  flushes,
>        __builtin___clear_cache() has no effect.
> 
>        Note:  On  some  GCC-compatible compilers, such as clang, the
>        prototype for this function uses char * instead of void *.
> ]
> 
> Thanks,
> 
> Alex
> 
> On 12/11/20 7:02 PM, Alejandro Colomar (man-pages) wrote:
>> Hi Michael,
>>
>> On 12/11/20 9:15 AM, Michael Kerrisk (man-pages) wrote:
>>> i Alex,
>>>
>>> On 12/10/20 9:56 PM, Alejandro Colomar (man-pages) wrote:
>>>> Hi all,
>>>>
>>>> v2:
>>>>
>>>> [
>>>> NOTES
>>>>        Unless  you  need  the finer grained control that this system
>>>>        call provides, you probably want  to  use  the  GCC  built-in
>>>>        function  __builtin___clear_cache(),  which  provides  a more
>>>>        portable interface:
>>>>
>>>>            void __builtin___clear_cache(void *begin, void *end);
>>>> ]
>>>
>>> This seems a reasonable text to me, but I think it would be helpful
>>> to say a little more precisely what kind of portability we are
>>> talking about here.
>> Sure.
>>
>>>
>>> Greater ortability across Linux architectures? Greater portability
>>> across platforms supported by GCC (including non-Linux) platforms?
>>> Something else?
>>
>> '... which provides a portable interface across platforms supported by
>> GCC:' sounds good.
>>
>> Maybe GCC devs have something more to add.
> 
>>
>> Thanks,
>>
>> Alex
>>
>>>
>>> Thanks,
>>>
>>> Michael
>>>
>>>
>>
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v5] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
  2020-12-11 18:26               ` RFC v4: " Alejandro Colomar (man-pages)
@ 2020-12-14 11:43                   ` Alejandro Colomar
  2020-12-15 13:30                   ` Alejandro Colomar
  1 sibling, 0 replies; 27+ messages in thread
From: Alejandro Colomar @ 2020-12-14 11:43 UTC (permalink / raw)
  To: Michael Kerrisk, Dave Martin, Heinrich Schuchardt, linux-man
  Cc: Alejandro Colomar, Vineet Gupta, linux-snps-arc, Guo Ren,
	linux-csky, Thomas Bogendoerfer, linux-mips, Nick Hu,
	Greentime Hu, Vincent Chen, gcc-patches, cfe-users, cfe-dev

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man2/cacheflush.2 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
index aba625721..7a2eed506 100644
--- a/man2/cacheflush.2
+++ b/man2/cacheflush.2
@@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
 but nowadays, Linux provides a
 .BR cacheflush ()
 system call on some other architectures, but with different arguments.
+.SH NOTES
+Unless you need the finer grained control that this system call provides,
+you probably want to use the GCC built-in function
+.BR __builtin___clear_cache (),
+which provides a portable interface
+across platforms supported by GCC and compatible compilers:
+.PP
+.in +4n
+.EX
+.BI "void __builtin___clear_cache(void *" begin ", void *" end );
+.EE
+.in
+.PP
+On platforms that don't require instruction cache flushes,
+.BR __builtin___clear_cache ()
+has no effect.
+.PP
+.IR Note :
+Until GCC 9.1.0,
+the prototype for this built-in function used
+.I char *
+instead of
+.I void *
+for the parameters.
 .SH BUGS
 Linux kernels older than version 2.6.11 ignore the
 .I addr
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v5] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
@ 2020-12-14 11:43                   ` Alejandro Colomar
  0 siblings, 0 replies; 27+ messages in thread
From: Alejandro Colomar @ 2020-12-14 11:43 UTC (permalink / raw)
  To: Michael Kerrisk, Dave Martin, Heinrich Schuchardt, linux-man
  Cc: Alejandro Colomar, Thomas Bogendoerfer, Vincent Chen, Nick Hu,
	Vineet Gupta, linux-mips, linux-csky, Guo Ren, Greentime Hu,
	gcc-patches, linux-snps-arc, cfe-users, cfe-dev

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man2/cacheflush.2 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
index aba625721..7a2eed506 100644
--- a/man2/cacheflush.2
+++ b/man2/cacheflush.2
@@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
 but nowadays, Linux provides a
 .BR cacheflush ()
 system call on some other architectures, but with different arguments.
+.SH NOTES
+Unless you need the finer grained control that this system call provides,
+you probably want to use the GCC built-in function
+.BR __builtin___clear_cache (),
+which provides a portable interface
+across platforms supported by GCC and compatible compilers:
+.PP
+.in +4n
+.EX
+.BI "void __builtin___clear_cache(void *" begin ", void *" end );
+.EE
+.in
+.PP
+On platforms that don't require instruction cache flushes,
+.BR __builtin___clear_cache ()
+has no effect.
+.PP
+.IR Note :
+Until GCC 9.1.0,
+the prototype for this built-in function used
+.I char *
+instead of
+.I void *
+for the parameters.
 .SH BUGS
 Linux kernels older than version 2.6.11 ignore the
 .I addr
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
  2020-12-14 11:43                   ` Alejandro Colomar
@ 2020-12-14 12:00                     ` Heinrich Schuchardt
  -1 siblings, 0 replies; 27+ messages in thread
From: Heinrich Schuchardt @ 2020-12-14 12:00 UTC (permalink / raw)
  To: Alejandro Colomar, Michael Kerrisk, Dave Martin, linux-man
  Cc: Vineet Gupta, linux-snps-arc, Guo Ren, linux-csky,
	Thomas Bogendoerfer, linux-mips, Nick Hu, Greentime Hu,
	Vincent Chen, gcc-patches, cfe-users, cfe-dev

On 12/14/20 12:43 PM, Alejandro Colomar wrote:
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   man2/cacheflush.2 | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
>
> diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
> index aba625721..7a2eed506 100644
> --- a/man2/cacheflush.2
> +++ b/man2/cacheflush.2
> @@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
>   but nowadays, Linux provides a
>   .BR cacheflush ()
>   system call on some other architectures, but with different arguments.
> +.SH NOTES
> +Unless you need the finer grained control that this system call provides,
> +you probably want to use the GCC built-in function
> +.BR __builtin___clear_cache (),
> +which provides a portable interface
> +across platforms supported by GCC and compatible compilers:
> +.PP
> +.in +4n
> +.EX
> +.BI "void __builtin___clear_cache(void *" begin ", void *" end );
> +.EE
> +.in
> +.PP
> +On platforms that don't require instruction cache flushes,
> +.BR __builtin___clear_cache ()
> +has no effect.
> +.PP
> +.IR Note :
> +Until GCC 9.1.0,
> +the prototype for this built-in function used
> +.I char *
> +instead of
> +.I void *
> +for the parameters.
>   .SH BUGS
>   Linux kernels older than version 2.6.11 ignore the
>   .I addr
>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v5] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
@ 2020-12-14 12:00                     ` Heinrich Schuchardt
  0 siblings, 0 replies; 27+ messages in thread
From: Heinrich Schuchardt @ 2020-12-14 12:00 UTC (permalink / raw)
  To: Alejandro Colomar, Michael Kerrisk, Dave Martin, linux-man
  Cc: Thomas Bogendoerfer, Vincent Chen, Nick Hu, Vineet Gupta,
	linux-mips, linux-csky, Guo Ren, Greentime Hu, gcc-patches,
	linux-snps-arc, cfe-users, cfe-dev

On 12/14/20 12:43 PM, Alejandro Colomar wrote:
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   man2/cacheflush.2 | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
>
> diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
> index aba625721..7a2eed506 100644
> --- a/man2/cacheflush.2
> +++ b/man2/cacheflush.2
> @@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
>   but nowadays, Linux provides a
>   .BR cacheflush ()
>   system call on some other architectures, but with different arguments.
> +.SH NOTES
> +Unless you need the finer grained control that this system call provides,
> +you probably want to use the GCC built-in function
> +.BR __builtin___clear_cache (),
> +which provides a portable interface
> +across platforms supported by GCC and compatible compilers:
> +.PP
> +.in +4n
> +.EX
> +.BI "void __builtin___clear_cache(void *" begin ", void *" end );
> +.EE
> +.in
> +.PP
> +On platforms that don't require instruction cache flushes,
> +.BR __builtin___clear_cache ()
> +has no effect.
> +.PP
> +.IR Note :
> +Until GCC 9.1.0,
> +the prototype for this built-in function used
> +.I char *
> +instead of
> +.I void *
> +for the parameters.
>   .SH BUGS
>   Linux kernels older than version 2.6.11 ignore the
>   .I addr
>


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-11 18:14       ` cacheflush.2 Alejandro Colomar (man-pages)
@ 2020-12-14 21:13         ` Martin Sebor
  2020-12-14 22:34           ` cacheflush.2 Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Sebor @ 2020-12-14 21:13 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages),
	Heinrich Schuchardt, Michael Kerrisk (man-pages)
  Cc: linux-man, Dave Martin, cfe-users, gcc

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
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: cacheflush.2
  2020-12-14 21:13         ` cacheflush.2 Martin Sebor
@ 2020-12-14 22:34           ` Alejandro Colomar (man-pages)
  2020-12-18 10:42             ` Ping: cacheflush.2 Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-14 22:34 UTC (permalink / raw)
  To: Martin Sebor, Heinrich Schuchardt, Michael Kerrisk (man-pages)
  Cc: linux-man, Dave Martin, cfe-users, gcc

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

Where is the actual prototype exposed to the user declared?

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
>>>>>
>>>>
>>>
>>
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
  2020-12-11 18:26               ` RFC v4: " Alejandro Colomar (man-pages)
@ 2020-12-15 13:30                   ` Alejandro Colomar
  2020-12-15 13:30                   ` Alejandro Colomar
  1 sibling, 0 replies; 27+ messages in thread
From: Alejandro Colomar @ 2020-12-15 13:30 UTC (permalink / raw)
  To: Michael Kerrisk, Dave Martin, Heinrich Schuchardt, linux-man,
	Martin Sebor
  Cc: Alejandro Colomar, Vineet Gupta, linux-snps-arc, Guo Ren,
	linux-csky, Thomas Bogendoerfer, linux-mips, Nick Hu,
	Greentime Hu, Vincent Chen, gcc-patches, cfe-users, cfe-dev

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Cc: Martin Sebor <msebor@redhat.com>
Cc: Dave Martin <Dave.Martin@arm.com>
---

v6:
- GCC has always exposed 'void *', as Martin Sebor noted.
  It's Clang (and maybe others) that (following GCC's docs)
  exposed 'char *'.

 man2/cacheflush.2 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
index aba625721..7a2eed506 100644
--- a/man2/cacheflush.2
+++ b/man2/cacheflush.2
@@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
 but nowadays, Linux provides a
 .BR cacheflush ()
 system call on some other architectures, but with different arguments.
+.SH NOTES
+Unless you need the finer grained control that this system call provides,
+you probably want to use the GCC built-in function
+.BR __builtin___clear_cache (),
+which provides a portable interface
+across platforms supported by GCC and compatible compilers:
+.PP
+.in +4n
+.EX
+.BI "void __builtin___clear_cache(void *" begin ", void *" end );
+.EE
+.in
+.PP
+On platforms that don't require instruction cache flushes,
+.BR __builtin___clear_cache ()
+has no effect.
+.PP
+.IR Note :
+On some GCC-compatible compilers,
+the prototype for this built-in function uses
+.I char *
+instead of
+.I void *
+for the parameters.
 .SH BUGS
 Linux kernels older than version 2.6.11 ignore the
 .I addr
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
@ 2020-12-15 13:30                   ` Alejandro Colomar
  0 siblings, 0 replies; 27+ messages in thread
From: Alejandro Colomar @ 2020-12-15 13:30 UTC (permalink / raw)
  To: Michael Kerrisk, Dave Martin, Heinrich Schuchardt, linux-man,
	Martin Sebor
  Cc: Alejandro Colomar, Thomas Bogendoerfer, Vincent Chen, Nick Hu,
	Vineet Gupta, linux-mips, linux-csky, Guo Ren, Greentime Hu,
	gcc-patches, linux-snps-arc, cfe-users, cfe-dev

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Cc: Martin Sebor <msebor@redhat.com>
Cc: Dave Martin <Dave.Martin@arm.com>
---

v6:
- GCC has always exposed 'void *', as Martin Sebor noted.
  It's Clang (and maybe others) that (following GCC's docs)
  exposed 'char *'.

 man2/cacheflush.2 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
index aba625721..7a2eed506 100644
--- a/man2/cacheflush.2
+++ b/man2/cacheflush.2
@@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
 but nowadays, Linux provides a
 .BR cacheflush ()
 system call on some other architectures, but with different arguments.
+.SH NOTES
+Unless you need the finer grained control that this system call provides,
+you probably want to use the GCC built-in function
+.BR __builtin___clear_cache (),
+which provides a portable interface
+across platforms supported by GCC and compatible compilers:
+.PP
+.in +4n
+.EX
+.BI "void __builtin___clear_cache(void *" begin ", void *" end );
+.EE
+.in
+.PP
+On platforms that don't require instruction cache flushes,
+.BR __builtin___clear_cache ()
+has no effect.
+.PP
+.IR Note :
+On some GCC-compatible compilers,
+the prototype for this built-in function uses
+.I char *
+instead of
+.I void *
+for the parameters.
 .SH BUGS
 Linux kernels older than version 2.6.11 ignore the
 .I addr
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Ping: cacheflush.2
  2020-12-14 22:34           ` cacheflush.2 Alejandro Colomar (man-pages)
@ 2020-12-18 10:42             ` Alejandro Colomar (man-pages)
  2020-12-18 16:51               ` Martin Sebor
  0 siblings, 1 reply; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-18 10:42 UTC (permalink / raw)
  To: Martin Sebor, Heinrich Schuchardt, Michael Kerrisk (man-pages),
	gcc, Dave Martin, cfe-users, linux-man

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 *'.
> 
> Where is the actual prototype exposed to the user declared?
> 
> 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
>>>>>>
>>>>>
>>>>
>>>
>>
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Ping: cacheflush.2
  2020-12-18 10:42             ` Ping: cacheflush.2 Alejandro Colomar (man-pages)
@ 2020-12-18 16:51               ` Martin Sebor
  2020-12-19 14:04                 ` Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Sebor @ 2020-12-18 16:51 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages),
	Heinrich Schuchardt, Michael Kerrisk (man-pages),
	gcc, Dave Martin, cfe-users, linux-man

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
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Ping: cacheflush.2
  2020-12-18 16:51               ` Martin Sebor
@ 2020-12-19 14:04                 ` Alejandro Colomar (man-pages)
  0 siblings, 0 replies; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-19 14:04 UTC (permalink / raw)
  To: Martin Sebor
  Cc: Heinrich Schuchardt, gcc, cfe-users, Michael Kerrisk (man-pages),
	linux-man, Dave Martin

Hi Martin,

Thanks!  It's good to learn some GCC internal details :)

Cheers,

Alex

On 12/18/20 5:51 PM, Martin Sebor wrote:
> 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
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Ping: [PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
  2020-12-15 13:30                   ` Alejandro Colomar
@ 2020-12-20 15:35                     ` Alejandro Colomar (man-pages)
  -1 siblings, 0 replies; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-20 15:35 UTC (permalink / raw)
  To: Michael Kerrisk, linux-man
  Cc: Vineet Gupta, Dave Martin, linux-snps-arc, Martin Sebor, Guo Ren,
	linux-csky, Thomas Bogendoerfer, Heinrich Schuchardt, linux-mips,
	Nick Hu, Greentime Hu, Vincent Chen, gcc-patches, cfe-users,
	cfe-dev

Ping

On 12/15/20 2:30 PM, Alejandro Colomar wrote:
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> Cc: Martin Sebor <msebor@redhat.com>
> Cc: Dave Martin <Dave.Martin@arm.com>
> ---
> 
> v6:
> - GCC has always exposed 'void *', as Martin Sebor noted.
>   It's Clang (and maybe others) that (following GCC's docs)
>   exposed 'char *'.
> 
>  man2/cacheflush.2 | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
> index aba625721..7a2eed506 100644
> --- a/man2/cacheflush.2
> +++ b/man2/cacheflush.2
> @@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
>  but nowadays, Linux provides a
>  .BR cacheflush ()
>  system call on some other architectures, but with different arguments.
> +.SH NOTES
> +Unless you need the finer grained control that this system call provides,
> +you probably want to use the GCC built-in function
> +.BR __builtin___clear_cache (),
> +which provides a portable interface
> +across platforms supported by GCC and compatible compilers:
> +.PP
> +.in +4n
> +.EX
> +.BI "void __builtin___clear_cache(void *" begin ", void *" end );
> +.EE
> +.in
> +.PP
> +On platforms that don't require instruction cache flushes,
> +.BR __builtin___clear_cache ()
> +has no effect.
> +.PP
> +.IR Note :
> +On some GCC-compatible compilers,
> +the prototype for this built-in function uses
> +.I char *
> +instead of
> +.I void *
> +for the parameters.
>  .SH BUGS
>  Linux kernels older than version 2.6.11 ignore the
>  .I addr
> 

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Ping: [PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
@ 2020-12-20 15:35                     ` Alejandro Colomar (man-pages)
  0 siblings, 0 replies; 27+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-20 15:35 UTC (permalink / raw)
  To: Michael Kerrisk, linux-man
  Cc: Thomas Bogendoerfer, Vincent Chen, Nick Hu, Vineet Gupta,
	linux-mips, linux-csky, cfe-users, Martin Sebor, Guo Ren,
	Greentime Hu, Heinrich Schuchardt, gcc-patches, linux-snps-arc,
	Dave Martin, cfe-dev

Ping

On 12/15/20 2:30 PM, Alejandro Colomar wrote:
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> Cc: Martin Sebor <msebor@redhat.com>
> Cc: Dave Martin <Dave.Martin@arm.com>
> ---
> 
> v6:
> - GCC has always exposed 'void *', as Martin Sebor noted.
>   It's Clang (and maybe others) that (following GCC's docs)
>   exposed 'char *'.
> 
>  man2/cacheflush.2 | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
> index aba625721..7a2eed506 100644
> --- a/man2/cacheflush.2
> +++ b/man2/cacheflush.2
> @@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
>  but nowadays, Linux provides a
>  .BR cacheflush ()
>  system call on some other architectures, but with different arguments.
> +.SH NOTES
> +Unless you need the finer grained control that this system call provides,
> +you probably want to use the GCC built-in function
> +.BR __builtin___clear_cache (),
> +which provides a portable interface
> +across platforms supported by GCC and compatible compilers:
> +.PP
> +.in +4n
> +.EX
> +.BI "void __builtin___clear_cache(void *" begin ", void *" end );
> +.EE
> +.in
> +.PP
> +On platforms that don't require instruction cache flushes,
> +.BR __builtin___clear_cache ()
> +has no effect.
> +.PP
> +.IR Note :
> +On some GCC-compatible compilers,
> +the prototype for this built-in function uses
> +.I char *
> +instead of
> +.I void *
> +for the parameters.
>  .SH BUGS
>  Linux kernels older than version 2.6.11 ignore the
>  .I addr
> 

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

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
  2020-12-15 13:30                   ` Alejandro Colomar
@ 2020-12-20 20:48                     ` Michael Kerrisk (man-pages)
  -1 siblings, 0 replies; 27+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-12-20 20:48 UTC (permalink / raw)
  To: Alejandro Colomar, Dave Martin, Heinrich Schuchardt, linux-man,
	Martin Sebor
  Cc: mtk.manpages, Vineet Gupta, linux-snps-arc, Guo Ren, linux-csky,
	Thomas Bogendoerfer, linux-mips, Nick Hu, Greentime Hu,
	Vincent Chen, gcc-patches, cfe-users, cfe-dev

On 12/15/20 2:30 PM, Alejandro Colomar wrote:
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> Cc: Martin Sebor <msebor@redhat.com>
> Cc: Dave Martin <Dave.Martin@arm.com>
> ---
> 
> v6:
> - GCC has always exposed 'void *', as Martin Sebor noted.
>   It's Clang (and maybe others) that (following GCC's docs)
>   exposed 'char *'.

Thanks, Alex. Patch applied.

Cheers,

Michael

>  man2/cacheflush.2 | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
> index aba625721..7a2eed506 100644
> --- a/man2/cacheflush.2
> +++ b/man2/cacheflush.2
> @@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
>  but nowadays, Linux provides a
>  .BR cacheflush ()
>  system call on some other architectures, but with different arguments.
> +.SH NOTES
> +Unless you need the finer grained control that this system call provides,
> +you probably want to use the GCC built-in function
> +.BR __builtin___clear_cache (),
> +which provides a portable interface
> +across platforms supported by GCC and compatible compilers:
> +.PP
> +.in +4n
> +.EX
> +.BI "void __builtin___clear_cache(void *" begin ", void *" end );
> +.EE
> +.in
> +.PP
> +On platforms that don't require instruction cache flushes,
> +.BR __builtin___clear_cache ()
> +has no effect.
> +.PP
> +.IR Note :
> +On some GCC-compatible compilers,
> +the prototype for this built-in function uses
> +.I char *
> +instead of
> +.I void *
> +for the parameters.
>  .SH BUGS
>  Linux kernels older than version 2.6.11 ignore the
>  .I addr
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative
@ 2020-12-20 20:48                     ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 27+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-12-20 20:48 UTC (permalink / raw)
  To: Alejandro Colomar, Dave Martin, Heinrich Schuchardt, linux-man,
	Martin Sebor
  Cc: Thomas Bogendoerfer, Vincent Chen, Nick Hu, Vineet Gupta,
	linux-mips, linux-csky, Guo Ren, mtk.manpages, gcc-patches,
	linux-snps-arc, cfe-users, cfe-dev, Greentime Hu

On 12/15/20 2:30 PM, Alejandro Colomar wrote:
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> Cc: Martin Sebor <msebor@redhat.com>
> Cc: Dave Martin <Dave.Martin@arm.com>
> ---
> 
> v6:
> - GCC has always exposed 'void *', as Martin Sebor noted.
>   It's Clang (and maybe others) that (following GCC's docs)
>   exposed 'char *'.

Thanks, Alex. Patch applied.

Cheers,

Michael

>  man2/cacheflush.2 | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
> index aba625721..7a2eed506 100644
> --- a/man2/cacheflush.2
> +++ b/man2/cacheflush.2
> @@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
>  but nowadays, Linux provides a
>  .BR cacheflush ()
>  system call on some other architectures, but with different arguments.
> +.SH NOTES
> +Unless you need the finer grained control that this system call provides,
> +you probably want to use the GCC built-in function
> +.BR __builtin___clear_cache (),
> +which provides a portable interface
> +across platforms supported by GCC and compatible compilers:
> +.PP
> +.in +4n
> +.EX
> +.BI "void __builtin___clear_cache(void *" begin ", void *" end );
> +.EE
> +.in
> +.PP
> +On platforms that don't require instruction cache flushes,
> +.BR __builtin___clear_cache ()
> +has no effect.
> +.PP
> +.IR Note :
> +On some GCC-compatible compilers,
> +the prototype for this built-in function uses
> +.I char *
> +instead of
> +.I void *
> +for the parameters.
>  .SH BUGS
>  Linux kernels older than version 2.6.11 ignore the
>  .I addr
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-12-21  5:16 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 18:04 cacheflush.2 Heinrich Schuchardt
2020-12-09 18:34 ` cacheflush.2 Alejandro Colomar (man-pages)
2020-12-09 18:48   ` cacheflush.2 Heinrich Schuchardt
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
2020-12-19 14:04                 ` Alejandro Colomar (man-pages)
2020-12-10 18:17   ` cacheflush.2 Dave Martin
2020-12-10 19:20     ` cacheflush.2 Heinrich Schuchardt
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)
2020-12-14 11:43                 ` [PATCH v5] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative Alejandro Colomar
2020-12-14 11:43                   ` Alejandro Colomar
2020-12-14 12:00                   ` Heinrich Schuchardt
2020-12-14 12:00                     ` Heinrich Schuchardt
2020-12-15 13:30                 ` [PATCH v6] " Alejandro Colomar
2020-12-15 13:30                   ` Alejandro Colomar
2020-12-20 15:35                   ` Ping: " Alejandro Colomar (man-pages)
2020-12-20 15:35                     ` Alejandro Colomar (man-pages)
2020-12-20 20:48                   ` Michael Kerrisk (man-pages)
2020-12-20 20:48                     ` Michael Kerrisk (man-pages)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.