[07/10] C11 threads: Fix thrd_t / pthread_t compatibility assertion

Message ID 20200114185255.25813-9-samuel.thibault@ens-lyon.org
State Committed, archived
Headers

Commit Message

Samuel Thibault Jan. 14, 2020, 6:52 p.m. UTC
  ---
 nptl/thrd_create.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Adhemerval Zanella Netto Jan. 20, 2020, 6:52 p.m. UTC | #1
LGTM with a small nit below.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

On 14/01/2020 15:52, Samuel Thibault wrote:
> ---
>  nptl/thrd_create.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/nptl/thrd_create.c b/nptl/thrd_create.c
> index 8474e234c9..fe08e22973 100644
> --- a/nptl/thrd_create.c
> +++ b/nptl/thrd_create.c
> @@ -21,8 +21,8 @@
>  int
>  thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
>  {
> -  _Static_assert (sizeof (thr) == sizeof (pthread_t),
> -		  "sizeof (thr) != sizeof (pthread_t)");
> +  _Static_assert (sizeof (*thr) == sizeof (pthread_t),
> +		  "sizeof (*thr) != sizeof (pthread_t)");
>  
>    int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD,
>  				       (void* (*) (void*))func, arg);
> 

I think it is better to use the type direct as other C11 implementation,
_Static_assert (sizeof (thrd_t) == sizeof (pthread_t), ...).
  

Patch

diff --git a/nptl/thrd_create.c b/nptl/thrd_create.c
index 8474e234c9..fe08e22973 100644
--- a/nptl/thrd_create.c
+++ b/nptl/thrd_create.c
@@ -21,8 +21,8 @@ 
 int
 thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
 {
-  _Static_assert (sizeof (thr) == sizeof (pthread_t),
-		  "sizeof (thr) != sizeof (pthread_t)");
+  _Static_assert (sizeof (*thr) == sizeof (pthread_t),
+		  "sizeof (*thr) != sizeof (pthread_t)");
 
   int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD,
 				       (void* (*) (void*))func, arg);