[01/11] devtools: warn when adding some pthread calls
Checks
Commit Message
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@monjalon.net>
---
devtools/checkpatches.sh | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
Hello Thomas,
On Wed, Sep 6, 2023 at 6:22 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 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@monjalon.net>
> ---
> devtools/checkpatches.sh | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> index 55fabc5458..131ffbcebe 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))\\\(" \
I remember some awk (was it Alpine Linux? or FreeBSD ?..) does not
like empty pattern like (|plop).
For this case here, it is better (and kind of more readable) to use _?
> + -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
>
@@ -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\\>' \