This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/5] Clean pthread types namespace for all archs.


On Mon, 10 Aug 2015, Juan Manuel Torres Palma wrote:

> diff --git a/bits/thread-shared-types.h b/bits/thread-shared-types.h
> new file mode 100644
> index 0000000..0e26952
> --- /dev/null
> +++ b/bits/thread-shared-types.h
> @@ -0,0 +1 @@
> +/* No thread support.  */

It would be more useful if the default header had comments explaining the 
interface - that is, what macros this header should define and what the 
semantics of their definitions are.

>  /* Data structures for mutex handling.  The structure of the attribute
>     type is not exposed on purpose.  */
> -typedef union
> -{
> -  struct __pthread_mutex_s
> -  {
> -    int __lock;
> -    unsigned int __count;
> -    int __owner;
> -    unsigned int __nusers;
> -    int __kind;
> -    int __spins;
> -    __pthread_list_t __list;
> -#define __PTHREAD_MUTEX_HAVE_PREV	1
> -  } __data;
> -  char __size[__SIZEOF_PTHREAD_MUTEX_T];
> -  long int __align;
> -} pthread_mutex_t;

__PTHREAD_MUTEX_HAVE_PREV is describing the presence of absence of a field 
in (a substructure of) pthread_mutex_t.  I think it would be better for 
the definitions of this macro to go in thread-shared-types.h, so that it 
goes close to where the structure contents in question are defined and 
it's easier to see whether the definition or its absence is correct.  As 
is, the patch leaves it in pthreadtypes.h, having moved the containing 
structure definition.

Arguably the same applies to __PTHREAD_SPINS: it most clearly goes 
alongside the structure definition.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]