diff options
-rw-r--r-- | linuxthreads/ChangeLog | 8 | ||||
-rw-r--r-- | linuxthreads/Versions | 1 | ||||
-rw-r--r-- | linuxthreads/attr.c | 37 | ||||
-rw-r--r-- | linuxthreads/sysdeps/pthread/pthread.h | 13 |
4 files changed, 59 insertions, 0 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 1f44e4c70d..2804dea180 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,11 @@ +2000-09-11 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/pthread/pthread.h: Declare pthread_attr_getstack and + pthread_attr_setstack. + * Versions [libpthread] (GLIBC_2.2): Export pthread_attr_getstack and + pthread_attr_setstack. + * attr.c (pthread_attr_getstack, pthread_attr_setstack): New functions. + 2000-09-05 Ulrich Drepper <drepper@redhat.com> * Examples/ex14.c: New file. diff --git a/linuxthreads/Versions b/linuxthreads/Versions index c52d88f4e1..8f38b9b604 100644 --- a/linuxthreads/Versions +++ b/linuxthreads/Versions @@ -139,6 +139,7 @@ libpthread { # New functions from IEEE Std. 1003.1-200x. sem_timedwait; + pthread_attr_getstack; pthread_attr_setstack; pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; pthread_spin_trylock; pthread_spin_unlock; pthread_getcpuclockid; diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c index ac3776a010..fc1ab59674 100644 --- a/linuxthreads/attr.c +++ b/linuxthreads/attr.c @@ -22,6 +22,7 @@ #include "pthread.h" #include "internals.h" #include <shlib-compat.h> +#include <stackinfo.h> int __pthread_attr_init_2_1(pthread_attr_t *attr) { @@ -224,3 +225,39 @@ int __pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) return 0; } weak_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize) + +int __pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, + size_t stacksize) +{ + int err; + + if ((((uintptr_t) stackaddr) + & ~__alignof__ (struct _pthread_descr_struct)) != 0) + err = EINVAL; + else + err = __pthread_attr_setstacksize (attr, stacksize); + if (err == 0) + { +#ifdef _STACK_GROWS_UP + attr->__stackaddr = (char *) stackaddr + stacksize; +#else + attr->__stackaddr = stackaddr; +#endif + attr->__stackaddr_set = 1; + } + + return err; +} +weak_alias (__pthread_attr_setstack, pthread_attr_setstack) + +int __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr, + size_t *stacksize) +{ + /* XXX This function has a stupid definition. The standard specifies + no error value but what is if no stack address was set? We simply + return the value we have in the member. */ + *stackaddr = attr->__stackaddr; + *stacksize = attr->__stacksize; + return 0; +} +weak_alias (__pthread_attr_getstack, pthread_attr_getstack) diff --git a/linuxthreads/sysdeps/pthread/pthread.h b/linuxthreads/sysdeps/pthread/pthread.h index 459eca6241..f2a742e57e 100644 --- a/linuxthreads/sysdeps/pthread/pthread.h +++ b/linuxthreads/sysdeps/pthread/pthread.h @@ -264,6 +264,19 @@ extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr) __THROW; +#ifdef __USE_XOPEN2K +/* The following two interfaces are intended to replace the last two. They + require setting the address as well as the size since only setting the + address will make the implementation on some architectures impossible. */ +extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, + size_t __stacksize) __THROW; + +/* Return the previously set address for the stack. */ +extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr, + void **__restrict __stackaddr, + size_t *__restrict __stacksize) __THROW; +#endif + /* Add information about the minimum stack size needed for the thread to be started. This size must never be less than PTHREAD_STACK_SIZE and must also not exceed the system limits. */ |