summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2008-05-17 20:07:56 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2008-05-17 20:07:56 +0000
commit7c6708ed26c318abbf7ca8bacc2eea50c9dcb459 (patch)
treec5cb2ecc436a64c9082827ffb14b2be195f0a9a4
parentbff1b2efeae74afed68b5521d46395b0e29681e3 (diff)
2008-05-17 Samuel Thibault <samuel.thibault@ens-lyon.org>
* include/pthread/pthread.h (pthread_getattr_np): New declaration. * pthread/pt-getattr.c: New file. * Makefile (SRCS): Add pt-getattr.c.
-rw-r--r--ChangeLog12
-rw-r--r--Makefile1
-rw-r--r--include/pthread/pthread.h7
-rw-r--r--pthread/pt-getattr.c49
4 files changed, 66 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 104dc66..c052f03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,20 @@
-2008-03-16 Samuel Thibault <samuel.thibault@ens-lyon.org
+2008-05-17 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * include/pthread/pthread.h (pthread_getattr_np): New declaration.
+ * pthread/pt-getattr.c: New file.
+ * Makefile (SRCS): Add pt-getattr.c.
+
+2008-03-16 Samuel Thibault <samuel.thibault@ens-lyon.org>
* include/libc-symbols.h (HAVE_ASM_PREVIOUS_DIRECTIVE): Define.
-2008-02-29 Samuel Thibault <samuel.thibault@ens-lyon.org
+2008-02-29 Samuel Thibault <samuel.thibault@ens-lyon.org>
* sysdeps/l4/hurd/i386/pt-setup.c (stack_setup): Align stack on 0x10
for MMX operations.
* sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Likewise.
-2008-01-01 Samuel Thibault <samuel.thibault@ens-lyon.org
+2008-01-01 Samuel Thibault <samuel.thibault@ens-lyon.org>
* include/pthread/pthread.h (pthread_spin_destroy, pthread_spin_init,
pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock): Use
diff --git a/Makefile b/Makefile
index 0c1542e..dc41950 100644
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
\
pt-alloc.c \
pt-create.c \
+ pt-getattr.c \
pt-equal.c \
pt-dealloc.c \
pt-detach.c \
diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h
index 9773e68..88fa1dc 100644
--- a/include/pthread/pthread.h
+++ b/include/pthread/pthread.h
@@ -188,6 +188,13 @@ extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict attr,
/* Set the value of the stacksize attribute in *ATTR to STACKSIZE. */
extern int pthread_attr_setstacksize (pthread_attr_t *attr,
size_t stacksize);
+
+#ifdef __USE_GNU
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread THREAD. It shall be called on an uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+extern int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr);
+#endif
/* Create a thread with attributes given by ATTR, executing
diff --git a/pthread/pt-getattr.c b/pthread/pt-getattr.c
new file mode 100644
index 0000000..24599c6
--- /dev/null
+++ b/pthread/pt-getattr.c
@@ -0,0 +1,49 @@
+/* Thread attributes retrieval.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include <pt-internal.h>
+
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread THREAD. It shall be called on an uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+int
+pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ struct __pthread *pthread;
+
+ pthread = __pthread_getid(thread);
+ if (pthread == NULL)
+ return ESRCH;
+
+ /* Some attributes (schedparam, inheritsched, contentionscope and schedpolicy)
+ are not supported yet, so fill them with our default values. */
+ *attr = __pthread_default_attr;
+
+ attr->stackaddr = pthread->stackaddr;
+ attr->stacksize = pthread->stacksize;
+ attr->guardsize = pthread->guardsize;
+ attr->detachstate = (pthread->state == PTHREAD_DETACHED
+ ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
+
+ return 0;
+}