[PATCH v3.4] New functions pthread_[sg]etattr_default_np for default thread attributes
Roland McGrath
roland@hack.frob.com
Fri Jun 14 21:03:00 GMT 2013
> --- 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
More information about the Libc-alpha
mailing list