[PATCH v3 01/11] devtools: warn when adding some pthread calls

Thomas Monjalon thomas at monjalon.net
Wed Sep 13 13:28:14 CEST 2023


All pthread functions below have an equivalent in rte_thread API:
	- pthread_create
	- pthread_join
	- pthread_detach
	- pthread_setname_np
	- pthread_set_name_np
	- pthread_setaffinity_np
	- pthread_attr_setinheritsched
	- pthread_attr_setschedpolicy
Usage of these functions will be raised to encourage rte_thread adoption.

The pthread functions for locks and cancel are still allowed.

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
Acked-by: Tyler Retzlaff <roretzla at linux.microsoft.com>

---
v2: replace (|_) with _?
---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 55fabc5458..ec9d232393 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 some pthread functions
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS="pthread_(create|join|detach|set(_?name_np|affinity_np)|attr_set(inheritsched|schedpolicy))\\\(" \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using pthread functions, prefer rte_thread' \
+		-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\\>' \
-- 
2.42.0



More information about the dev mailing list