Update.
authorUlrich Drepper <drepper@redhat.com>
Mon, 11 Sep 2000 19:13:06 +0000 (19:13 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 11 Sep 2000 19:13:06 +0000 (19:13 +0000)
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.

linuxthreads/ChangeLog
linuxthreads/Versions
linuxthreads/attr.c
linuxthreads/sysdeps/pthread/pthread.h

index 1f44e4c..2804dea 100644 (file)
@@ -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.
index c52d88f..8f38b9b 100644 (file)
@@ -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;
index ac3776a..fc1ab59 100644 (file)
@@ -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)
index 459eca6..f2a742e 100644 (file)
@@ -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.  */