diff mbox series

[05/10] nptl: Move nptl-specific types to separate header

Message ID 20200114185255.25813-7-samuel.thibault@ens-lyon.org
State New
Headers show
Series Port C11 threads to GNU/Hurd | expand

Commit Message

Samuel Thibault Jan. 14, 2020, 6:52 p.m. UTC
---
 nptl/call_once.c                        |  2 +-
 sysdeps/nptl/bits/thread-shared-types.h | 10 ++++++++++
 sysdeps/nptl/threads.h                  | 13 +++++--------
 3 files changed, 16 insertions(+), 9 deletions(-)

Comments

Adhemerval Zanella Netto Jan. 20, 2020, 6:31 p.m. UTC | #1
LGTM, thanks.

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

On 14/01/2020 15:52, Samuel Thibault wrote:
> ---
>  nptl/call_once.c                        |  2 +-
>  sysdeps/nptl/bits/thread-shared-types.h | 10 ++++++++++
>  sysdeps/nptl/threads.h                  | 13 +++++--------
>  3 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/nptl/call_once.c b/nptl/call_once.c
> index 3f880a9073..25e2964c76 100644
> --- a/nptl/call_once.c
> +++ b/nptl/call_once.c
> @@ -27,5 +27,5 @@ call_once (once_flag *flag, void (*func)(void))
>  		  "sizeof (once_flag) != sizeof (pthread_once_t)");
>    _Static_assert (alignof (once_flag) == alignof (pthread_once_t),
>  		  "alignof (once_flag) != alignof (pthread_once_t)");
> -  __pthread_once (&flag->__data, func);
> +  __pthread_once ((pthread_once_t *) flag, func);
>  }

Ok.

> diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h
> index fd08b6916a..fbbdd0bb36 100644
> --- a/sysdeps/nptl/bits/thread-shared-types.h
> +++ b/sysdeps/nptl/bits/thread-shared-types.h
> @@ -116,4 +116,14 @@ struct __pthread_cond_s
>    unsigned int __g_signals[2];
>  };
>  
> +typedef unsigned int __tss_t;
> +typedef unsigned long int __thrd_t;
> +
> +typedef struct
> +{
> +  int __data __ONCE_ALIGNMENT;
> +} __once_flag;
> +
> +#define __ONCE_FLAG_INIT { 0 }
> +
>  #endif /* _THREAD_SHARED_TYPES_H  */

Ok.

> diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
> index 6d5e4bfe02..0ac489b4a1 100644
> --- a/sysdeps/nptl/threads.h
> +++ b/sysdeps/nptl/threads.h
> @@ -24,7 +24,7 @@
>  
>  __BEGIN_DECLS
>  
> -#include <bits/pthreadtypes-arch.h>
> +#include <bits/thread-shared-types.h>
>  #include <bits/types/struct_timespec.h>
>  
>  #ifndef __cplusplus

Ok, thread-shared-types.h includes pthreadtypes-arch.h.

> @@ -32,10 +32,10 @@ __BEGIN_DECLS
>  #endif
>  
>  #define TSS_DTOR_ITERATIONS 4
> -typedef unsigned int tss_t;
> +typedef __tss_t tss_t;
>  typedef void (*tss_dtor_t) (void*);
>  
> -typedef unsigned long int thrd_t;
> +typedef __thrd_t thrd_t;
>  typedef int (*thrd_start_t) (void*);
>  
>  /* Exit and error codes.  */
> @@ -56,11 +56,8 @@ enum
>    mtx_timed     = 2
>  };
>  
> -typedef struct
> -{
> -  int __data __ONCE_ALIGNMENT;
> -} once_flag;
> -#define ONCE_FLAG_INIT { 0 }
> +typedef __once_flag once_flag;
> +#define ONCE_FLAG_INIT __ONCE_FLAG_INIT
>  
>  typedef union
>  {
> 

Ok.
diff mbox series

Patch

diff --git a/nptl/call_once.c b/nptl/call_once.c
index 3f880a9073..25e2964c76 100644
--- a/nptl/call_once.c
+++ b/nptl/call_once.c
@@ -27,5 +27,5 @@  call_once (once_flag *flag, void (*func)(void))
 		  "sizeof (once_flag) != sizeof (pthread_once_t)");
   _Static_assert (alignof (once_flag) == alignof (pthread_once_t),
 		  "alignof (once_flag) != alignof (pthread_once_t)");
-  __pthread_once (&flag->__data, func);
+  __pthread_once ((pthread_once_t *) flag, func);
 }
diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h
index fd08b6916a..fbbdd0bb36 100644
--- a/sysdeps/nptl/bits/thread-shared-types.h
+++ b/sysdeps/nptl/bits/thread-shared-types.h
@@ -116,4 +116,14 @@  struct __pthread_cond_s
   unsigned int __g_signals[2];
 };
 
+typedef unsigned int __tss_t;
+typedef unsigned long int __thrd_t;
+
+typedef struct
+{
+  int __data __ONCE_ALIGNMENT;
+} __once_flag;
+
+#define __ONCE_FLAG_INIT { 0 }
+
 #endif /* _THREAD_SHARED_TYPES_H  */
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
index 6d5e4bfe02..0ac489b4a1 100644
--- a/sysdeps/nptl/threads.h
+++ b/sysdeps/nptl/threads.h
@@ -24,7 +24,7 @@ 
 
 __BEGIN_DECLS
 
-#include <bits/pthreadtypes-arch.h>
+#include <bits/thread-shared-types.h>
 #include <bits/types/struct_timespec.h>
 
 #ifndef __cplusplus
@@ -32,10 +32,10 @@  __BEGIN_DECLS
 #endif
 
 #define TSS_DTOR_ITERATIONS 4
-typedef unsigned int tss_t;
+typedef __tss_t tss_t;
 typedef void (*tss_dtor_t) (void*);
 
-typedef unsigned long int thrd_t;
+typedef __thrd_t thrd_t;
 typedef int (*thrd_start_t) (void*);
 
 /* Exit and error codes.  */
@@ -56,11 +56,8 @@  enum
   mtx_timed     = 2
 };
 
-typedef struct
-{
-  int __data __ONCE_ALIGNMENT;
-} once_flag;
-#define ONCE_FLAG_INIT { 0 }
+typedef __once_flag once_flag;
+#define ONCE_FLAG_INIT __ONCE_FLAG_INIT
 
 typedef union
 {