devtools: stop compiler atomics with no C11 equivalent

Message ID 1679329321-26073-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series devtools: stop compiler atomics with no C11 equivalent |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Tyler Retzlaff March 20, 2023, 4:22 p.m. UTC
  Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
to ease future adoption of C11 standard atomics.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Tyler Retzlaff March 22, 2023, 6:08 p.m. UTC | #1
adding a few more people to cc for attention

On Mon, Mar 20, 2023 at 09:22:01AM -0700, Tyler Retzlaff wrote:
> Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
> to ease future adoption of C11 standard atomics.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  devtools/checkpatches.sh | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> index 1dee094..1ed6d51 100755
> --- a/devtools/checkpatches.sh
> +++ b/devtools/checkpatches.sh
> @@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
>  		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
>  		"$1" || res=1
>  
> +	# refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
> +	awk -v FOLDERS="lib drivers app examples" \
> +		-v EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \
> +		-v RET_ON_FAIL=1 \
> +		-v MESSAGE='Using __atomic_{add,and,nand,or,sub,xor}_fetch' \
> +		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
> +		"$1" || res=1
> +
>  	# forbid use of __reserved which is a reserved keyword in Windows system headers
>  	awk -v FOLDERS="lib drivers app examples" \
>  		-v EXPRESSIONS='\\<__reserved\\>' \
> -- 
> 1.8.3.1
  
Morten Brørup March 22, 2023, 6:25 p.m. UTC | #2
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Wednesday, 22 March 2023 19.08
> 
> adding a few more people to cc for attention
> 
> On Mon, Mar 20, 2023 at 09:22:01AM -0700, Tyler Retzlaff wrote:
> > Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
> > to ease future adoption of C11 standard atomics.
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> >  devtools/checkpatches.sh | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> > index 1dee094..1ed6d51 100755
> > --- a/devtools/checkpatches.sh
> > +++ b/devtools/checkpatches.sh
> > @@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
> >  		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk
> \
> >  		"$1" || res=1
> >
> > +	# refrain from using compiler
> __atomic_{add,and,nand,or,sub,xor}_fetch()
> > +	awk -v FOLDERS="lib drivers app examples" \
> > +		-v
> EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \
> > +		-v RET_ON_FAIL=1 \
> > +		-v MESSAGE='Using __atomic_{add,and,nand,or,sub,xor}_fetch'
> \

Suggest that you expand the error message with a solution for the developer: "... use __atomic_fetch_op() instead of __atomic_op_fetch()"

> > +		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk
> \
> > +		"$1" || res=1
> > +
> >  	# forbid use of __reserved which is a reserved keyword in Windows
> system headers
> >  	awk -v FOLDERS="lib drivers app examples" \
> >  		-v EXPRESSIONS='\\<__reserved\\>' \
> > --
> > 1.8.3.1
  
Tyler Retzlaff March 22, 2023, 9 p.m. UTC | #3
On Wed, Mar 22, 2023 at 07:25:09PM +0100, Morten Brørup wrote:
> > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> > Sent: Wednesday, 22 March 2023 19.08
> > 
> > adding a few more people to cc for attention
> > 
> > On Mon, Mar 20, 2023 at 09:22:01AM -0700, Tyler Retzlaff wrote:
> > > Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
> > > to ease future adoption of C11 standard atomics.
> > >
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > > ---
> > >  devtools/checkpatches.sh | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > >
> > > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> > > index 1dee094..1ed6d51 100755
> > > --- a/devtools/checkpatches.sh
> > > +++ b/devtools/checkpatches.sh
> > > @@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
> > >  		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk
> > \
> > >  		"$1" || res=1
> > >
> > > +	# refrain from using compiler
> > __atomic_{add,and,nand,or,sub,xor}_fetch()
> > > +	awk -v FOLDERS="lib drivers app examples" \
> > > +		-v
> > EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \
> > > +		-v RET_ON_FAIL=1 \
> > > +		-v MESSAGE='Using __atomic_{add,and,nand,or,sub,xor}_fetch'
> > \
> 
> Suggest that you expand the error message with a solution for the developer: "... use __atomic_fetch_op() instead of __atomic_op_fetch()"

if awk could expand captures i would do that but it can't.

or do you mean literally use 'op' instead of {add,and,nand,or,sub,xor}
in the message?

> 
> > > +		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk
> > \
> > > +		"$1" || res=1
> > > +
> > >  	# forbid use of __reserved which is a reserved keyword in Windows
> > system headers
> > >  	awk -v FOLDERS="lib drivers app examples" \
> > >  		-v EXPRESSIONS='\\<__reserved\\>' \
> > > --
> > > 1.8.3.1
  
Morten Brørup March 22, 2023, 9:48 p.m. UTC | #4
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Wednesday, 22 March 2023 22.00
> 
> On Wed, Mar 22, 2023 at 07:25:09PM +0100, Morten Brørup wrote:
> > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> > > Sent: Wednesday, 22 March 2023 19.08
> > >
> > > adding a few more people to cc for attention
> > >
> > > On Mon, Mar 20, 2023 at 09:22:01AM -0700, Tyler Retzlaff wrote:
> > > > Refrain from using compiler
> __atomic_{add,and,nand,or,sub,xor}_fetch()
> > > > to ease future adoption of C11 standard atomics.
> > > >
> > > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > > > ---
> > > >  devtools/checkpatches.sh | 8 ++++++++
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> > > > index 1dee094..1ed6d51 100755
> > > > --- a/devtools/checkpatches.sh
> > > > +++ b/devtools/checkpatches.sh
> > > > @@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
> > > >  		-f $(dirname $(readlink -f $0))/check-forbidden-
> tokens.awk
> > > \
> > > >  		"$1" || res=1
> > > >
> > > > +	# refrain from using compiler
> > > __atomic_{add,and,nand,or,sub,xor}_fetch()
> > > > +	awk -v FOLDERS="lib drivers app examples" \
> > > > +		-v
> > > EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \
> > > > +		-v RET_ON_FAIL=1 \
> > > > +		-v MESSAGE='Using
> __atomic_{add,and,nand,or,sub,xor}_fetch'
> > > \
> >
> > Suggest that you expand the error message with a solution for the
> developer: "... use __atomic_fetch_op() instead of __atomic_op_fetch()"
> 
> if awk could expand captures i would do that but it can't.
> 
> or do you mean literally use 'op' instead of {add,and,nand,or,sub,xor}
> in the message?

I didn't think about expansion, so literally using "op" in the solution part of the message is exactly what I meant. But please keep the existing part of the message as is.

Alternatively, you can also use "{add,and,nand,or,sub,xor}" instead of "op" in the solution part of the message. Whatever you prefer.

The message could be even more verbose by also adding the reason why __atomic_op_fetch() is prohibited, such as: "... in order to prepare for conversion to C11 stdatomics, where atomic_{add,and,nand,or,sub,xor}_fetch() is unavailable."

> 
> >
> > > > +		-f $(dirname $(readlink -f $0))/check-forbidden-
> tokens.awk
> > > \
> > > > +		"$1" || res=1
> > > > +
> > > >  	# forbid use of __reserved which is a reserved keyword in
> Windows
> > > system headers
> > > >  	awk -v FOLDERS="lib drivers app examples" \
> > > >  		-v EXPRESSIONS='\\<__reserved\\>' \
> > > > --
> > > > 1.8.3.1
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 1dee094..1ed6d51 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -119,6 +119,14 @@  check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using __atomic_{add,and,nand,or,sub,xor}_fetch' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# forbid use of __reserved which is a reserved keyword in Windows system headers
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__reserved\\>' \