diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-03-19 00:14:42 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-03-19 00:14:42 +0000 |
commit | 439ff07be06e9354151f984c7d0d2fb05917e8be (patch) | |
tree | 2c3471a5c7e73d1f6a043b082266e7248b992c02 /nptl/pthread_getattr_np.c | |
parent | 701a7b234eab5615adb472b5dc5b0a9199d69f9b (diff) | |
download | glibc-439ff07be06e9354151f984c7d0d2fb05917e8be.tar.gz glibc-439ff07be06e9354151f984c7d0d2fb05917e8be.tar.xz glibc-439ff07be06e9354151f984c7d0d2fb05917e8be.zip |
Update.
2004-03-18 Ulrich Drepper <drepper@redhat.com> * posix/sched.h: Change sched_getaffinity and sched_setaffinity interfaces: add new second parameter. * sysdeps/generic/sched_getaffinity.c: Implement interface change. * sysdeps/generic/sched_setaffinity.c: Likewise. * sysdeps/unix/sysv/linux/sched_getaffinity.c: Likewise. Add compatibility interface. * sysdeps/unix/sysv/linux/sched_setaffinity.c: Likewise. * sysdeps/unix/sysv/linux/Versions: Add versions for changed interfaces.
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r-- | nptl/pthread_getattr_np.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c index 0925ced37f..df11b1ff1d 100644 --- a/nptl/pthread_getattr_np.c +++ b/nptl/pthread_getattr_np.c @@ -135,18 +135,35 @@ pthread_getattr_np (thread_id, attr) if (ret == 0) { - iattr->cpuset = (cpu_set_t *) malloc (sizeof (cpu_set_t)); - if (iattr->cpuset == NULL) - ret = ENOMEM; - else + size_t size = 32; + cpu_set_t *cpuset = NULL; + + do { - ret = pthread_getaffinity_np (thread_id, iattr->cpuset); - if (ret == ENOSYS) + void *newp = realloc (cpuset, size); + if (newp == NULL) { - free (iattr->cpuset); - iattr->cpuset = NULL; - ret = 0; + free (cpuset); + ret = ENOMEM; } + cpuset = (cpu_set_t *) newp; + + ret = __pthread_getaffinity_np (thread_id, size, cpuset); + } + /* Pick some ridiculous upper limit. Is 8 million CPUs enough? */ + while (ret == EINVAL && size < 1024 * 1024); + + if (ret == 0) + { + iattr->cpuset = cpuset; + iattr->cpusetsize = size; + } + else + { + free (cpuset); + if (ret == ENOSYS) + /* There is no such functionality. */ + ret = 0; } } |