This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC][BZ #16549] Add sanity check for condvar alignment.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 11 Feb 2014 10:05:20 -0800 (PST)
- Subject: Re: [RFC][BZ #16549] Add sanity check for condvar alignment.
- Authentication-results: sourceware.org; auth=none
- References: <20140211124346 dot GA31165 at domone dot podge> <20140211172111 dot 5827B74451 at topped-with-meat dot com> <20140211175741 dot GA32451 at domone dot podge>
> On Tue, Feb 11, 2014 at 09:21:11AM -0800, Roland McGrath wrote:
> > > + assert (((uintptr_t) cond) % sizeof (long) == 0);
> >
> > Drop superfluous parens. Use __alignof (pthread_cond_t).
>
> OK now?
>
> * nptl/pthread_cond_init.c (__pthread_cond_init): Add assert that
> input is aligned.
Looks fine.
> diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c
> index 27efc9c..6fa522a 100644
> --- a/nptl/pthread_cond_init.c
> +++ b/nptl/pthread_cond_init.c
> @@ -16,6 +16,7 @@
> License along with the GNU C Library; if not, see
> <http://www.gnu.org/licenses/>. */
>
> +#include <assert.h>
> #include <shlib-compat.h>
> #include "pthreadP.h"
> #include <stap-probe.h>
> @@ -28,6 +29,7 @@ __pthread_cond_init (cond, cond_attr)
> {
> struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
>
> + assert ((uintptr_t) cond % __alignof (pthread_cond_t) == 0);
> cond->__data.__lock = LLL_LOCK_INITIALIZER;
> cond->__data.__futex = 0;
> cond->__data.__nwaiters = (icond_attr != NULL