This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3.4] New functions pthread_[sg]etattr_default_np for default thread attributes
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: Richard Henderson <rth at twiddle dot net>, libc-alpha at sourceware dot org
- Date: Fri, 14 Jun 2013 14:03:27 -0700 (PDT)
- Subject: Re: [PATCH v3.4] New functions pthread_[sg]etattr_default_np for default thread attributes
- References: <CAAHN_R13bRF0UY_XZ7Rj6tSeSgq8c_0j4bbEH6m9BbGD32EycQ at mail dot gmail dot com> <20130528220730 dot 33C262C06F at topped-with-meat dot com> <20130529065138 dot GF2145 at spoyarek dot pnq dot redhat dot com> <20130529224222 dot 8A87F2C07E at topped-with-meat dot com> <20130606131212 dot GZ13968 at spoyarek dot pnq dot redhat dot com> <20130612000601 dot 54C9F2C06E at topped-with-meat dot com> <20130612101128 dot GB19582 at spoyarek dot pnq dot redhat dot com> <20130612231757 dot CCC752C07F at topped-with-meat dot com> <20130613035538 dot GL19582 at spoyarek dot pnq dot redhat dot com> <51B9F6ED dot 4000107 at twiddle dot net> <20130613182113 dot GA19582 at spoyarek dot pnq dot redhat dot com>
> --- a/nptl/pthread_create.c
> +++ b/nptl/pthread_create.c
> @@ -448,19 +448,48 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
> {
> STACK_VARIABLES;
>
> - const struct pthread_attr *iattr = (struct pthread_attr *) attr;
> + struct pthread_attr *iattr = (struct pthread_attr *) attr;
Don't drop the const.
> + if (__glibc_unlikely (free_cpuset))
> + free (iattr->cpuset);
Make it default_attr.cpuset.
> +thr (void *unused __attribute__((unused)))
Space before (double) paren.
> +{
> + pthread_attr_t attr;
> + int ret;
> +
> + /* To verify that the pthread_setattr_default_np worked. */
> + if ((ret = pthread_getattr_default_np (&attr)) != 0)
> + {
> + printf ("pthread_getattr_default_np failed: %s\n", strerror (ret));
> + goto out;
> + }
> +
> + if ((ret = (*verify_result) (&attr)) != 0)
> + goto out;
> +
> + /* To verify that the attributes actually got applied. */
> + if ((ret = pthread_getattr_np (pthread_self (), &attr)) != 0)
> + {
> + printf ("pthread_getattr_default_np failed: %s\n", strerror (ret));
> + goto out;
> + }
> +
> + ret = (*verify_result) (&attr);
Hmm. This would pass if pthread_getattr_default_np worked but
pthread_getattr_np were a no-op. Perhaps put:
memset (&attr, 0xab, sizeof attr);
before the pthread_getattr_default_np call and before the
pthread_getattr_np call just for paranoia.
Approved with those changes.
Thanks,
Roland