Back to index

glibc  2.9
pthread_attr_getaffinity.c File Reference
#include <assert.h>
#include <errno.h>
#include <pthreadP.h>
#include <string.h>
#include <sysdep.h>
#include <sys/types.h>
#include <shlib-compat.h>

Go to the source code of this file.


int __pthread_attr_getaffinity_new (const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset)
 versioned_symbol (libpthread, __pthread_attr_getaffinity_new, pthread_attr_getaffinity_np, GLIBC_2_3_4)

Function Documentation

int __pthread_attr_getaffinity_new ( const pthread_attr_t attr,
size_t  cpusetsize,
cpu_set_t *  cpuset 

Definition at line 30 of file pthread_attr_getaffinity.c.

  const struct pthread_attr *iattr;

  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
  iattr = (const struct pthread_attr *) attr;

  if (iattr->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)
         return EINVAL;

      void *p = mempcpy (cpuset, iattr->cpuset, iattr->cpusetsize);
      if (cpusetsize > iattr->cpusetsize)
       memset (p, '\0', cpusetsize - iattr->cpusetsize);
    /* We have no information.  */
    memset (cpuset, -1, cpusetsize);

  return 0;
versioned_symbol ( libpthread  ,
__pthread_attr_getaffinity_new  ,
pthread_attr_getaffinity_np  ,