This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/5] Clean pthread types namespace for all archs.
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Juan Manuel Torres Palma <j dot m dot torrespalma at gmail dot com>
- Cc: <libc-alpha at sourceware dot org>, Juan Manuel Torres Palma <jmtorrespalma at gmail dot com>
- Date: Thu, 13 Aug 2015 23:40:18 +0000
- Subject: Re: [PATCH 1/5] Clean pthread types namespace for all archs.
- Authentication-results: sourceware.org; auth=none
- References: <1439217470-23427-1-git-send-email-j dot m dot torrespalma at gmail dot com> <1439217470-23427-2-git-send-email-j dot m dot torrespalma at gmail dot com>
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