about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--elf/dl-load.c2
-rw-r--r--grp/initgroups.c15
-rw-r--r--linuxthreads/ChangeLog5
-rw-r--r--linuxthreads/manager.c27
-rw-r--r--nss/nss_files/files-XXX.c11
-rw-r--r--sysdeps/generic/glob.c8
6 files changed, 42 insertions, 26 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index e67ade2d59..ad981bc238 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -563,7 +563,7 @@ _dl_map_object_from_fd (char *name, int fd, char *realname,
   /* Read the header directly.  */
   readbuf = alloca (_dl_pagesize);
   readlength = __libc_read (fd, readbuf, _dl_pagesize);
-  if (readlength < sizeof(*header))
+  if (readlength < (ssize_t) sizeof(*header))
     lose (errno, "cannot read file data");
   header = (void *) readbuf;
 
diff --git a/grp/initgroups.c b/grp/initgroups.c
index 2150fa968c..f42c92db9a 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -60,7 +60,7 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
   end_function endgrent_fct;
 
   setgrent_fct = __nss_lookup_function (nip, "setgrent");
-  status = (*setgrent_fct) ();
+  status = _CALL_DL_FCT (setgrent_fct, ());
   if (status != NSS_STATUS_SUCCESS)
     return status;
 
@@ -71,9 +71,10 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
 
   do
     {
-      while ((status =
-	      (*getgrent_fct) (&grpbuf, tmpbuf, buflen, errnop)) ==
-	     NSS_STATUS_TRYAGAIN && *errnop == ERANGE)
+      while ((status = _CALL_DL_FCT (getgrent_fct,
+				     (&grpbuf, tmpbuf, buflen, errnop)),
+	      status == NSS_STATUS_TRYAGAIN)
+	     && *errnop == ERANGE)
         {
           buflen *= 2;
           tmpbuf = __alloca (buflen);
@@ -114,7 +115,7 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
   while (status == NSS_STATUS_SUCCESS);
 
  done:
-  (*endgrent_fct) ();
+  _CALL_DL_FCT (endgrent_fct, ());
 
   return NSS_STATUS_SUCCESS;
 }
@@ -177,8 +178,8 @@ initgroups (user, group)
 	status = compat_call (nip, user, group, &start, &size, groups,
 			      limit, &errno);
       else
-	status = (*fct) (user, group, &start, &size, groups, limit,
-			 &errno);
+	status = _CALL_DL_FCT (fct, (user, group, &start, &size, groups, limit,
+				     &errno));
 
       if (nip->next == NULL)
 	no_more = -1;
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 1daf1bc31c..69426bfb7c 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,8 @@
+1998-06-24  Ulrich Drepper  <drepper@cygnus.com>
+
+	* manager.c (pthread_free): Undo patch from 980430.
+	Reported by David Wragg <dpw@doc.ic.ac.uk>.
+
 1998-06-09 15:07  Ulrich Drepper  <drepper@cygnus.com>
 
 	* manager.c: Define __pthread_manager_adjust_prio and use it to
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index c9625327c1..ac78d6e4ce 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -35,7 +35,11 @@
 /* Array of active threads. Entry 0 is reserved for the initial thread. */
 
 struct pthread_handle_struct __pthread_handles[PTHREAD_THREADS_MAX] =
-{ { 0, &__pthread_initial_thread}, /* All NULLs */ };
+{ { 0, &__pthread_initial_thread, 0}, /* All NULLs */ };
+
+/* Indicate whether at least one thread has a user-defined stack (if 1),
+   or if all threads have stacks supplied by LinuxThreads (if 0). */
+int __pthread_nonstandard_stacks;
 
 /* Mapping from stack segment to thread descriptor. */
 /* Stack segment numbers are also indices into the __pthread_handles array. */
@@ -181,6 +185,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
   size_t sseg;
   int pid;
   pthread_descr new_thread;
+  char * new_thread_bottom;
   pthread_t new_thread_id;
   void *guardaddr = NULL;
 
@@ -195,6 +200,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
       if (attr == NULL || !attr->stackaddr_set)
 	{
 	  new_thread = thread_segment(sseg);
+	  new_thread_bottom = (char *) new_thread - STACK_SIZE;
 	  /* Allocate space for stack and thread descriptor. */
 	  if (mmap((caddr_t)((char *)(new_thread+1) - INITIAL_STACK_SIZE),
 		   INITIAL_STACK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
@@ -219,7 +225,9 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
 	}
       else
 	{
-	  new_thread = (pthread_descr) attr->stackaddr - 1;
+	  new_thread = (pthread_descr) ((long) attr->stackaddr
+					& -sizeof(void *)) - 1;
+	  new_thread_bottom = (char *) attr->stackaddr - attr->stacksize;
 	  break;
 	}
     }
@@ -258,6 +266,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
   /* Initialize the thread handle */
   __pthread_handles[sseg].h_spinlock = 0; /* should already be 0 */
   __pthread_handles[sseg].h_descr = new_thread;
+  __pthread_handles[sseg].h_bottom = new_thread_bottom;
   /* Determine scheduling parameters for the thread */
   new_thread->p_start_args.schedpolicy = -1;
   if (attr != NULL) {
@@ -318,22 +327,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
 static void pthread_free(pthread_descr th)
 {
   pthread_handle handle;
-  pthread_descr t;
-
-  /* Check that the thread th is still there -- pthread_reap_children
-     might have deallocated it already */
-  t = __pthread_main_thread;
-  do {
-    if (t == th) break;
-    t = t->p_nextlive;
-  } while (t != __pthread_main_thread);
-  if (t != th) return;
-
   ASSERT(th->p_exited);
   /* Make the handle invalid */
   handle =  thread_handle(th->p_tid);
   acquire(&handle->h_spinlock);
   handle->h_descr = NULL;
+  handle->h_bottom = (char *)(-1L);
   release(&handle->h_spinlock);
   /* If initial thread, nothing to free */
   if (th == &__pthread_initial_thread) return;
@@ -481,7 +480,7 @@ void __pthread_manager_adjust_prio(int thread_prio)
 
   if (thread_prio <= __pthread_manager_thread.p_priority) return;
   param.sched_priority =
-    thread_prio < __sched_get_priority_max(SCHED_FIFO) 
+    thread_prio < __sched_get_priority_max(SCHED_FIFO)
     ? thread_prio + 1 : thread_prio;
   __sched_setscheduler(__pthread_manager_thread.p_pid, SCHED_FIFO, &param);
   __pthread_manager_thread.p_priority = thread_prio;
diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index 6933986026..d6a7911b66 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -224,7 +224,16 @@ CONCAT(_nss_files_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
 
   /* Be prepared that the set*ent function was not called before.  */
   if (stream == NULL)
-    status = internal_setent (0);
+    {
+      status = internal_setent (0);
+
+      if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0)
+	{
+	  fclose (stream);
+	  stream = NULL;
+	  status = NSS_STATUS_UNAVAIL;
+	}
+    }
 
   if (status == NSS_STATUS_SUCCESS)
     {
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index c26b2a6115..bc32d99359 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -246,9 +246,11 @@ extern char *alloca ();
 
 /* Some system header files erroneously define these.
    We want our own definitions from <fnmatch.h> to take precedence.  */
-#undef	FNM_PATHNAME
-#undef	FNM_NOESCAPE
-#undef	FNM_PERIOD
+#ifndef __GNU_LIBRARY__
+# undef	FNM_PATHNAME
+# undef	FNM_NOESCAPE
+# undef	FNM_PERIOD
+#endif
 #include <fnmatch.h>
 
 /* Some system header files erroneously define these.