about summary refs log tree commit diff
path: root/nptl/pthread_getattr_np.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
commita334319f6530564d22e775935d9c91663623a1b4 (patch)
treeb5877475619e4c938e98757d518bb1e9cbead751 /nptl/pthread_getattr_np.c
parent0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff)
downloadglibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz
glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.xz
glibc-a334319f6530564d22e775935d9c91663623a1b4.zip
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r--nptl/pthread_getattr_np.c84
1 files changed, 38 insertions, 46 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index f6cd8899d8..ba720af6cd 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -83,55 +83,51 @@ pthread_getattr_np (thread_id, attr)
       if (fp == NULL)
 	ret = errno;
       /* We need the limit of the stack in any case.  */
+      else if (getrlimit (RLIMIT_STACK, &rl) != 0)
+	ret = errno;
       else
 	{
-	  if (getrlimit (RLIMIT_STACK, &rl) != 0)
-	    ret = errno;
-	  else
-	    {
-	      /* We need no locking.  */
-	      __fsetlocking (fp, FSETLOCKING_BYCALLER);
+	  /* We need no locking.  */
+	  __fsetlocking (fp, FSETLOCKING_BYCALLER);
 
-	      /* Until we found an entry (which should always be the case)
-		 mark the result as a failure.  */
-	      ret = ENOENT;
+	  /* Until we found an entry (which should always be the case)
+	     mark the result as a failure.  */
+	  ret = ENOENT;
 
-	      char *line = NULL;
-	      size_t linelen = 0;
-	      uintptr_t last_to = 0;
+	  char *line = NULL;
+	  size_t linelen = 0;
+	  uintptr_t last_to = 0;
 
-	      while (! feof_unlocked (fp))
+	  while (! feof_unlocked (fp))
+	    {
+	      if (__getdelim (&line, &linelen, '\n', fp) <= 0)
+		break;
+
+	      uintptr_t from;
+	      uintptr_t to;
+	      if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
+		continue;
+	      if (from <= (uintptr_t) __libc_stack_end
+		  && (uintptr_t) __libc_stack_end < to)
 		{
-		  if (__getdelim (&line, &linelen, '\n', fp) <= 0)
-		    break;
-
-		  uintptr_t from;
-		  uintptr_t to;
-		  if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
-		    continue;
-		  if (from <= (uintptr_t) __libc_stack_end
-		      && (uintptr_t) __libc_stack_end < to)
-		    {
-		      /* Found the entry.  Now we have the info we need.  */
-		      iattr->stacksize = rl.rlim_cur;
-		      iattr->stackaddr = (void *) to;
-
-		      /* The limit might be too high.  */
-		      if ((size_t) iattr->stacksize
-			  > (size_t) iattr->stackaddr - last_to)
-			iattr->stacksize = (size_t) iattr->stackaddr - last_to;
-
-		      /* We succeed and no need to look further.  */
-		      ret = 0;
-		      break;
-		    }
-		  last_to = to;
+		  /* Found the entry.  Now we have the info we need.  */
+		  iattr->stacksize = rl.rlim_cur;
+		  iattr->stackaddr = (void *) to;
+
+		  /* The limit might be too high.  */
+		  if ((size_t) iattr->stacksize
+		      > (size_t) iattr->stackaddr - last_to)
+		    iattr->stacksize = (size_t) iattr->stackaddr - last_to;
+
+		  /* We succeed and no need to look further.  */
+		  ret = 0;
+		  break;
 		}
-
-	      free (line);
+	      last_to = to;
 	    }
 
 	  fclose (fp);
+	  free (line);
 	}
     }
 
@@ -168,12 +164,8 @@ pthread_getattr_np (thread_id, attr)
 	{
 	  free (cpuset);
 	  if (ret == ENOSYS)
-	    {	  
-	      /* There is no such functionality.  */
-	      ret = 0;
-	      iattr->cpuset = NULL;
-	      iattr->cpusetsize = 0;
-	    }
+	    /* There is no such functionality.  */
+	    ret = 0;
 	}
     }