summaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-03-15 21:13:12 +0000
committerUlrich Drepper <drepper@redhat.com>2001-03-15 21:13:12 +0000
commit3bf927cbce1d0829b587f5f0eee744e907921c58 (patch)
treee57df20024262c73f67b6171a94757f25e9e1abf /linuxthreads
parent821a6bb4360ae232140ba230724642fed9db613c (diff)
downloadglibc-3bf927cbce1d0829b587f5f0eee744e907921c58.tar.gz
Update.
2001-03-15 Ulrich Drepper <drepper@redhat.com> * Versions [libpthread] (GLIBC_2.2.3): Add pthread_getattr_np. * attr.c: Implement pthread_getattr_np. * sysdeps/pthread/pthread.h: Add prototype for pthread_getattr_np. * internals.h (struct _pthread_descr_struct): Add p_inheritsched. * manager.c (pthread_handle_create): Initialize p_inheritsched. * sysdeps/unix/sysv/linux/s390/pt-initfini.c: Use 0x07 padding for
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog10
-rw-r--r--linuxthreads/Versions4
-rw-r--r--linuxthreads/attr.c42
-rw-r--r--linuxthreads/internals.h1
-rw-r--r--linuxthreads/manager.c1
-rw-r--r--linuxthreads/sysdeps/pthread/pthread.h5
6 files changed, 62 insertions, 1 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 93a988323c..c9d685e51f 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,6 +1,14 @@
+2001-03-15 Ulrich Drepper <drepper@redhat.com>
+
+ * Versions [libpthread] (GLIBC_2.2.3): Add pthread_getattr_np.
+ * attr.c: Implement pthread_getattr_np.
+ * sysdeps/pthread/pthread.h: Add prototype for pthread_getattr_np.
+ * internals.h (struct _pthread_descr_struct): Add p_inheritsched.
+ * manager.c (pthread_handle_create): Initialize p_inheritsched.
+
2001-03-09 Martin Schwidefsky <schwidefsky@de.ibm.com>
- * sysdeps/unix/sysv/linux/s390/pt-initfini.c: Use 0x07 padding for
+ * sysdeps/unix/sysv/linux/s390/pt-initfini.c: Use 0x07 padding for
code alignment.
2001-02-20 Hans Boehm <hans_boehm@hp.com>
diff --git a/linuxthreads/Versions b/linuxthreads/Versions
index 3541002ad5..2e7c11aff6 100644
--- a/linuxthreads/Versions
+++ b/linuxthreads/Versions
@@ -152,4 +152,8 @@ libpthread {
# Extensions.
pthread_yield;
}
+ GLIBC_2.2.3 {
+ # Extensions.
+ pthread_getattr_np;
+ }
}
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index 580da03b40..8cb0f8f7ef 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -267,3 +267,45 @@ int __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr,
return 0;
}
weak_alias (__pthread_attr_getstack, pthread_attr_getstack)
+
+int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ pthread_handle handle = thread_handle (thread);
+ pthread_descr descr;
+ char *guardaddr;
+
+ if (handle == NULL)
+ return ENOENT;
+
+ descr = handle->h_descr;
+
+ attr->__detachstate = (descr->p_detached
+ ? PTHREAD_CREATE_DETACHED
+ : PTHREAD_CREATE_JOINABLE);
+
+ attr->__schedpolicy = __sched_getscheduler (descr->p_pid);
+ if (attr->__schedpolicy == -1)
+ return errno;
+
+ if (__sched_getparam (descr->p_pid,
+ (struct sched_param *) &attr->__schedparam) != 0)
+ return errno;
+
+ guardaddr = descr->p_guardaddr;
+ attr->__inheritsched = descr->p_inheritsched;
+ attr->__scope = PTHREAD_SCOPE_SYSTEM;
+ attr->__stacksize = (char *)(descr + 1) - guardaddr - descr->p_guardsize;
+ attr->__guardsize = descr->p_guardsize;
+ attr->__stackaddr_set = descr->p_userstack;
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ guardaddr -= attr->__stacksize;
+ attr->__stacksize *= 2;
+ /* XXX This is awkward. The guard pages are in the middle of the
+ two stacks. We must count the guard size in the stack size since
+ otherwise the range of the stack area cannot be computed. */
+ attr->__stacksize += attr->guardsize;
+#endif
+ attr->__stackaddr = guardaddr;
+
+ return 0;
+}
diff --git a/linuxthreads/internals.h b/linuxthreads/internals.h
index 06853323bb..f3f8af2c8e 100644
--- a/linuxthreads/internals.h
+++ b/linuxthreads/internals.h
@@ -178,6 +178,7 @@ struct _pthread_descr_struct {
int p_untracked_readlock_count; /* Readlocks not tracked by list */
struct __res_state *p_resp; /* Pointer to resolver state */
struct __res_state p_res; /* per-thread resolver state */
+ int p_inheritsched; /* copied from the thread attribute */
/* New elements must be added at the end. */
} __attribute__ ((aligned(32))); /* We need to align the structure so that
doubles are aligned properly. This is 8
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index 7f35758d12..567ba658d1 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -512,6 +512,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
new_thread->p_guardsize = guardsize;
new_thread->p_header.data.self = new_thread;
new_thread->p_nr = sseg;
+ new_thread->p_inheritsched = attr ? attr->__inheritsched : 0;
/* Initialize the thread handle */
__pthread_init_lock(&__pthread_handles[sseg].h_lock);
__pthread_handles[sseg].h_descr = new_thread;
diff --git a/linuxthreads/sysdeps/pthread/pthread.h b/linuxthreads/sysdeps/pthread/pthread.h
index 1a190e0cd4..08a338b9a8 100644
--- a/linuxthreads/sysdeps/pthread/pthread.h
+++ b/linuxthreads/sysdeps/pthread/pthread.h
@@ -289,6 +289,11 @@ extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
__THROW;
+#ifdef __USE_GNU
+/* Get thread attributes corresponding to the already running thread TH. */
+extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
+#endif
+
/* Functions for scheduling control. */
/* Set the scheduling parameters for TARGET_THREAD according to POLICY