about summary refs log tree commit diff
path: root/nptl/pthread_attr_getaffinity.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-06-02 10:33:30 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-06-02 11:54:58 +0200
commit7538d461134bf306e31b40e4032f0c225bb40d51 (patch)
tree34c4ceb7c6565864dfc62d8e23dd8f37e24944af /nptl/pthread_attr_getaffinity.c
parent6993670b52daa413717e840dfb17b5322e7f4a88 (diff)
downloadglibc-7538d461134bf306e31b40e4032f0c225bb40d51.tar.gz
glibc-7538d461134bf306e31b40e4032f0c225bb40d51.tar.xz
glibc-7538d461134bf306e31b40e4032f0c225bb40d51.zip
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>
Diffstat (limited to 'nptl/pthread_attr_getaffinity.c')
-rw-r--r--nptl/pthread_attr_getaffinity.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/nptl/pthread_attr_getaffinity.c b/nptl/pthread_attr_getaffinity.c
index 212c1f7c0a..9483f69ddc 100644
--- a/nptl/pthread_attr_getaffinity.c
+++ b/nptl/pthread_attr_getaffinity.c
@@ -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.  */