Skip to contentSkip to conversation

devtools: stop compiler atomics with no C11 equivalent

PATCH Superseded Tyler Retzlaff 3 participants 8 messages Mar 20, 2023 – Apr 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtools: stop compiler atomics with no C11 equivalent

Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch() to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +8 -0
index 1dee094..1ed6d51 100755
@@ -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\\>' \
Signature · 1 line
1.8.3.1
#1 lore raw

adding a few more people to cc for attention

Quoted 29 lines · Tyler Retzlaff

Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch() to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +8 -0
index 1dee094..1ed6d51 100755
@@ -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\\>' \
Signature · 1 line
1.8.3.1
#2 lore raw
Quoted 23 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 22 March 2023 19.08

adding a few more people to cc for attention

Quoted 13 lines · Tyler Retzlaff

Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch() to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +0 -0
index 1dee094..1ed6d51 100755

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 119

Quoted 1 line
devtools/checkpatches.sh +0 -0
@@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk

\

Quoted 2 lines
devtools/checkpatches.sh +0 -0
 		"$1" || res=1
 
Quoted 8 lines

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 122

Quoted 1 line
devtools/checkpatches.sh +1 -0
+	# refrain from using compiler

__atomic_{add,and,nand,or,sub,xor}_fetch()

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 124

Quoted 2 lines
devtools/checkpatches.sh +2 -0
+	awk -v FOLDERS="lib drivers app examples" \
+		-v

EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 126

Quoted 2 lines
devtools/checkpatches.sh +2 -0
+		-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()"

Quoted 10 lines

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 127

Quoted 1 line
devtools/checkpatches.sh +1 -0
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk

\

devtools/checkpatches.sh check_forbidden_additions() { # <patch>

Quoted 3 lines
devtools/checkpatches.sh +2 -0
+		"$1" || res=1
+
 	# forbid use of __reserved which is a reserved keyword in Windows

system headers

Quoted 4 lines
devtools/checkpatches.sh +0 -1
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__reserved\\>' \
--

1.8.3.1

#3 lore raw
Quoted 25 lines · Morten Brørup
Quoted 25 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 22 March 2023 19.08

adding a few more people to cc for attention

Quoted 13 lines · Tyler Retzlaff

Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch() to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +0 -0
index 1dee094..1ed6d51 100755

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 119

Quoted 1 line
devtools/checkpatches.sh +0 -0
@@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk

\

devtools/checkpatches.sh check_forbidden_additions() { # <patch>

Quoted 3 lines
devtools/checkpatches.sh +1 -0
 		"$1" || res=1
 
+	# refrain from using compiler

__atomic_{add,and,nand,or,sub,xor}_fetch()

Quoted 8 lines
Quoted 6 lines

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 124

Quoted 2 lines
devtools/checkpatches.sh +2 -0
+	awk -v FOLDERS="lib drivers app examples" \
+		-v

EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 126

Quoted 2 lines
devtools/checkpatches.sh +2 -0
+		-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?

Quoted 11 lines
Quoted 11 lines

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 127

Quoted 2 lines
devtools/checkpatches.sh +1 -0
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk

\

devtools/checkpatches.sh check_forbidden_additions() { # <patch>

Quoted 3 lines
devtools/checkpatches.sh +2 -0
+		"$1" || res=1
+
 	# forbid use of __reserved which is a reserved keyword in Windows

system headers

Quoted 4 lines
devtools/checkpatches.sh +0 -1
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__reserved\\>' \
--

1.8.3.1

#4 lore raw
Quoted 39 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 22 March 2023 22.00

Quoted 7 lines · Morten Brørup
Quoted 7 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Wednesday, 22 March 2023 19.08

adding a few more people to cc for attention

Quoted 1 line · Tyler Retzlaff

Refrain from using compiler

__atomic_{add,and,nand,or,sub,xor}_fetch()

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
Quoted 6 lines
Quoted 6 lines

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 119

Quoted 6 lines
devtools/checkpatches.sh +0 -0
index 1dee094..1ed6d51 100755
@@ -119,6 +119,14 @@ check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-

tokens.awk

Quoted 10 lines
Quoted 10 lines

\

devtools/checkpatches.sh check_forbidden_additions() { # <patch>

Quoted 3 lines
devtools/checkpatches.sh +1 -0
 		"$1" || res=1
 
+	# refrain from using compiler

__atomic_{add,and,nand,or,sub,xor}_fetch()

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 124

Quoted 2 lines
devtools/checkpatches.sh +2 -0
+	awk -v FOLDERS="lib drivers app examples" \
+		-v

EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 126

Quoted 2 lines
devtools/checkpatches.sh +2 -0
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using

__atomic_{add,and,nand,or,sub,xor}_fetch'

Quoted 2 lines
Quoted 1 line

\

Quoted 7 lines
Quoted 1 line

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

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

devtools/checkpatches.sh check_forbidden_additions() { # <patch> · line 127

Quoted 3 lines
devtools/checkpatches.sh +1 -0
+		-f $(dirname $(readlink -f $0))/check-forbidden-

tokens.awk

Quoted 4 lines
Quoted 4 lines

\

devtools/checkpatches.sh check_forbidden_additions() { # <patch>

Quoted 3 lines
devtools/checkpatches.sh +2 -0
+		"$1" || res=1
+
 	# forbid use of __reserved which is a reserved keyword in

Windows

Quoted 5 lines
Quoted 5 lines

system headers

Quoted 4 lines
devtools/checkpatches.sh +0 -1
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__reserved\\>' \
--

1.8.3.1

#5 lore raw

PATCH v2 1/1 devtools: stop compiler atomics with no C11 equivalent

In reply to Tyler Retzlaff

Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch() to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +8 -0
index a07bbc8..1b6841b 100755
@@ -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_op_fetch use __atomic_fetch_op instead' \
+		-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\\>' \
Signature · 1 line
1.8.3.1
#7 lore raw
In reply to Tyler Retzlaff
Quoted 29 lines · Tyler Retzlaff

Refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch() to ease future adoption of C11 standard atomics.

---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +8 -1
index a07bbc8..1b6841b 100755
@@ -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_op_fetch use __atomic_fetch_op instead' \
+               -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\\>' \
--
Quoted 1 line

1.8.3.1

I tweaked the warning message a bit, and applied.
Thanks.

Signature · 1 line
David Marchand