1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

nptl: Make pthread_attr_t dynamically extensible

This introduces the function __pthread_attr_extension to allocate the
extension space, which is freed by pthread_attr_destroy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer
2020-06-02 10:33:30 +02:00
parent 6993670b52
commit 7538d46113
10 changed files with 98 additions and 33 deletions

View File

@ -33,22 +33,22 @@ __pthread_attr_getaffinity_new (const pthread_attr_t *attr, size_t cpusetsize,
iattr = (const struct pthread_attr *) attr;
if (iattr->cpuset != NULL)
if (iattr->extension != NULL && iattr->extension->cpuset != NULL)
{
/* Check whether there are any bits set beyond the limits
the user requested. */
for (size_t cnt = cpusetsize; cnt < iattr->cpusetsize; ++cnt)
if (((char *) iattr->cpuset)[cnt] != 0)
for (size_t cnt = cpusetsize; cnt < iattr->extension->cpusetsize; ++cnt)
if (((char *) iattr->extension->cpuset)[cnt] != 0)
return EINVAL;
/* Copy over the cpuset from the thread attribute object. Limit the copy
to the minimum of the source and destination sizes to prevent a buffer
overrun. If the destination is larger, fill the remaining space with
zeroes. */
void *p = mempcpy (cpuset, iattr->cpuset,
MIN (iattr->cpusetsize, cpusetsize));
if (cpusetsize > iattr->cpusetsize)
memset (p, '\0', cpusetsize - iattr->cpusetsize);
void *p = mempcpy (cpuset, iattr->extension->cpuset,
MIN (iattr->extension->cpusetsize, cpusetsize));
if (cpusetsize > iattr->extension->cpusetsize)
memset (p, '\0', cpusetsize - iattr->extension->cpusetsize);
}
else
/* We have no information. */