diff mbox series

[09/10] htl: Add C11 threads types definitions

Message ID 20200114185255.25813-11-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
---
 sysdeps/htl/bits/thread-shared-types.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Adhemerval Zanella Netto Jan. 20, 2020, 7:08 p.m. UTC | #1
On 14/01/2020 15:52, Samuel Thibault wrote:
> ---
>  sysdeps/htl/bits/thread-shared-types.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/sysdeps/htl/bits/thread-shared-types.h b/sysdeps/htl/bits/thread-shared-types.h
> index c280f2e182..819682a07b 100644
> --- a/sysdeps/htl/bits/thread-shared-types.h
> +++ b/sysdeps/htl/bits/thread-shared-types.h
> @@ -20,5 +20,18 @@
>  #define _THREAD_SHARED_TYPES_H 1
>  
>  #include <bits/pthreadtypes-arch.h>
> +#include <bits/types/struct___pthread_once.h>
> +
> +typedef int __tss_t;
> +typedef int __thrd_t;
> +
> +typedef union
> +{
> +  struct __pthread_once __data;
> +  int __align __ONCE_ALIGNMENT;
> +  char __size[__SIZEOF_PTHREAD_ONCE_T];
> +} __once_flag;
> +
> +#define __ONCE_FLAG_INIT { { __PTHREAD_ONCE_INIT } }
>  
>  #endif /* _THREAD_SHARED_TYPES_H  */
> 

Does Hurd really need both __align and __size flag? Its 
__pthread_once definition does not seem to require any
alignment constraint.

Rest looks good.
Samuel Thibault Jan. 20, 2020, 8:58 p.m. UTC | #2
Adhemerval Zanella, le lun. 20 janv. 2020 16:08:03 -0300, a ecrit:
> On 14/01/2020 15:52, Samuel Thibault wrote:
> > diff --git a/sysdeps/htl/bits/thread-shared-types.h b/sysdeps/htl/bits/thread-shared-types.h
> > index c280f2e182..819682a07b 100644
> > --- a/sysdeps/htl/bits/thread-shared-types.h
> > +++ b/sysdeps/htl/bits/thread-shared-types.h
> > @@ -20,5 +20,18 @@
> > +typedef union
> > +{
> > +  struct __pthread_once __data;
> > +  int __align __ONCE_ALIGNMENT;
> > +  char __size[__SIZEOF_PTHREAD_ONCE_T];
> > +} __once_flag;
> > +
> > +#define __ONCE_FLAG_INIT { { __PTHREAD_ONCE_INIT } }
> >  
> >  #endif /* _THREAD_SHARED_TYPES_H  */
> 
> Does Hurd really need both __align and __size flag?

I am here reproducing what we have for mtx_t and cnd_t. I agree that the
current structure does not need more than int alignment, but we could
need more than this in the future for some archs.

Samuel
Adhemerval Zanella Netto Jan. 21, 2020, 11:35 a.m. UTC | #3
On 20/01/2020 17:58, Samuel Thibault wrote:
> Adhemerval Zanella, le lun. 20 janv. 2020 16:08:03 -0300, a ecrit:
>> On 14/01/2020 15:52, Samuel Thibault wrote:
>>> diff --git a/sysdeps/htl/bits/thread-shared-types.h b/sysdeps/htl/bits/thread-shared-types.h
>>> index c280f2e182..819682a07b 100644
>>> --- a/sysdeps/htl/bits/thread-shared-types.h
>>> +++ b/sysdeps/htl/bits/thread-shared-types.h
>>> @@ -20,5 +20,18 @@
>>> +typedef union
>>> +{
>>> +  struct __pthread_once __data;
>>> +  int __align __ONCE_ALIGNMENT;
>>> +  char __size[__SIZEOF_PTHREAD_ONCE_T];
>>> +} __once_flag;
>>> +
>>> +#define __ONCE_FLAG_INIT { { __PTHREAD_ONCE_INIT } }
>>>  
>>>  #endif /* _THREAD_SHARED_TYPES_H  */
>>
>> Does Hurd really need both __align and __size flag?
> 
> I am here reproducing what we have for mtx_t and cnd_t. I agree that the
> current structure does not need more than int alignment, but we could
> need more than this in the future for some archs.
> 

But you can redefine for possible new architecture on Hurd when
you really need it. Also I would expect that C11 thread functions
to provide simple API than POSIX ones, which most likely require
less possible extensions over time.
diff mbox series

Patch

diff --git a/sysdeps/htl/bits/thread-shared-types.h b/sysdeps/htl/bits/thread-shared-types.h
index c280f2e182..819682a07b 100644
--- a/sysdeps/htl/bits/thread-shared-types.h
+++ b/sysdeps/htl/bits/thread-shared-types.h
@@ -20,5 +20,18 @@ 
 #define _THREAD_SHARED_TYPES_H 1
 
 #include <bits/pthreadtypes-arch.h>
+#include <bits/types/struct___pthread_once.h>
+
+typedef int __tss_t;
+typedef int __thrd_t;
+
+typedef union
+{
+  struct __pthread_once __data;
+  int __align __ONCE_ALIGNMENT;
+  char __size[__SIZEOF_PTHREAD_ONCE_T];
+} __once_flag;
+
+#define __ONCE_FLAG_INIT { { __PTHREAD_ONCE_INIT } }
 
 #endif /* _THREAD_SHARED_TYPES_H  */