This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] pthread_getattr_np


Hi!

As pointed by Hui Huang, __stackaddr is stack top on machines where stack
grows down, so pthread_getattr_np should match that.
I'll try to write a testcase as soon.

2001-03-20  Jakub Jelinek  <jakub@redhat.com>

	* attr.c (pthread_getattr_np): __stackaddr is topmost address.

--- libc/linuxthreads/attr.c.jj	Tue Mar 20 13:36:32 2001
+++ libc/linuxthreads/attr.c	Tue Mar 20 16:26:43 2001
@@ -263,7 +263,6 @@ int pthread_getattr_np (pthread_t thread
 {
   pthread_handle handle = thread_handle (thread);
   pthread_descr descr;
-  char *guardaddr;
 
   if (handle == NULL)
     return ENOENT;
@@ -282,21 +281,24 @@ int pthread_getattr_np (pthread_t thread
 			(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->__stacksize = (char *)(descr + 1) - descr->p_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;
+#ifndef _STACK_GROWS_UP
+  attr->__stackaddr = (char *)(descr + 1);
+#else
+#error __stackaddr not handled
+#endif
 
   return 0;
 }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]