summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog31
-rw-r--r--Makeconfig14
-rw-r--r--dirent/Makefile4
-rw-r--r--iconv/gconv_builtin.c1
-rw-r--r--iconv/gconv_open.c76
-rw-r--r--intl/Makefile2
-rw-r--r--linuxthreads/ChangeLog7
-rw-r--r--linuxthreads/Examples/ex8.c2
-rw-r--r--linuxthreads/spinlock.c233
-rw-r--r--linuxthreads/spinlock.h15
-rw-r--r--locale/langinfo.h2
-rw-r--r--localedata/Makefile24
-rw-r--r--localedata/gen-locale.sh9
-rw-r--r--localedata/sort-test.sh5
-rwxr-xr-xlocaledata/tst-ctype.sh4
-rwxr-xr-xlocaledata/tst-fmon.sh13
-rwxr-xr-xlocaledata/tst-locale.sh4
-rwxr-xr-xlocaledata/tst-mbswcs.sh16
-rwxr-xr-xlocaledata/tst-rpmatch.sh8
-rwxr-xr-xlocaledata/tst-trans.sh5
-rw-r--r--nss/getent.c2
-rw-r--r--stdlib/Makefile2
22 files changed, 329 insertions, 150 deletions
diff --git a/ChangeLog b/ChangeLog
index 17cdab9a82..d3d9d900ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2000-07-12  Bruno Haible  <haible@clisp.cons.org>
+
+	* iconv/gconv_open.c (__gconv_open): Merge duplicated code.
+
+2000-07-12  Bruno Haible  <haible@clisp.cons.org>
+
+	* iconv/gconv_builtin.c (__gconv_get_builtin_trans): Initialize
+	__modname.
+
+2000-07-12  Bruno Haible  <haible@clisp.cons.org>
+
+	* iconv/gconv_open.c (__gconv_open): Initialize
+	result->__steps[cnt].__data.
+
+2000-07-12  Mark Kettenis  <kettenis@gnu.org>
+
+	* nss/getent.c (services_keys): Pass port number in network byte
+	order in call to getservbyport.
+
+2000-07-11  Andreas Jaeger  <aj@suse.de>
+
+	* stdlib/Makefile (test-canon-ARGS): Fix for building in the
+	source dir.
+	* intl/Makefile (do-gettext-test): Likewise.
+	* dirent/Makefile (opendir-tst1-ARGS): Likewise.
+
+2000-07-11  Andreas Schwab  <schwab@suse.de>
+
+	* Makeconfig (run-program-prefix): New rule.
+	(built-program-cmd): Use run-program-prefix.
+
 2000-07-12  Ulrich Drepper  <drepper@redhat.com>
 
 	* locale/langinfo.h: Make CRNCYSTR, RADIXCHAR, THOUSANDS_SEP, YESEXPR,
diff --git a/Makeconfig b/Makeconfig
index 0395beee56..da3c88f0e0 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -475,20 +475,18 @@ elf-objpfx = $(common-objpfx)elf/
 # How to run a program we just linked with our library.
 # The program binary is assumed to be $(word 2,$^).
 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
-ifneq (yes,$(build-shared))
-built-program-cmd = $(built-program-file)
-else
+ifeq (yes,$(build-shared))
 comma = ,
 sysdep-library-path = \
 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
 				       $(filter -Wl$(comma)-rpath-link=%,\
 						$(sysdep-LDFLAGS)))))
-define built-program-cmd
-$(elf-objpfx)$(rtld-installed-name) \
-	--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-	$(built-program-file)
-endef
+run-program-prefix = $(elf-objpfx)$(rtld-installed-name) \
+		     --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
+else
+run-program-prefix =
 endif
+built-program-cmd = $(run-program-prefix) $(built-program-file)
 
 ifndef LD
 LD := ld -X
diff --git a/dirent/Makefile b/dirent/Makefile
index fcd6dcdcc4..c61f0bf6d2 100644
--- a/dirent/Makefile
+++ b/dirent/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
+# Copyright (C) 1991,92,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -32,4 +32,4 @@ tests	   := list tst-seekdir opendir-tst1
 
 include ../Rules
 
-opendir-tst1-ARGS = --test-dir=${objdir}
+opendir-tst1-ARGS = --test-dir=${common-objpfx}dirent
diff --git a/iconv/gconv_builtin.c b/iconv/gconv_builtin.c
index 46cb0480fa..7a2072d904 100644
--- a/iconv/gconv_builtin.c
+++ b/iconv/gconv_builtin.c
@@ -77,6 +77,7 @@ __gconv_get_builtin_trans (const char *name, struct __gconv_step *step)
   step->__end_fct = map[cnt].end;
   step->__counter = INT_MAX;
   step->__shlib_handle = NULL;
+  step->__modname = NULL;
 
   step->__min_needed_from = map[cnt].min_needed_from;
   step->__max_needed_from = map[cnt].max_needed_from;
diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c
index c54054a3e5..7a17b7005a 100644
--- a/iconv/gconv_open.c
+++ b/iconv/gconv_open.c
@@ -184,14 +184,10 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 
 	  /* Call all initialization functions for the transformation
 	     step implementations.  */
-	  for (cnt = 0; cnt < nsteps - 1; ++cnt)
+	  for (cnt = 0; cnt < nsteps; ++cnt)
 	    {
 	      size_t size;
 
-	      /* If this is the last step we must not allocate an
-		 output buffer.  */
-	      result->__data[cnt].__flags = conv_flags;
-
 	      /* Would have to be done if we would not clear the whole
                  array above.  */
 #if 0
@@ -205,16 +201,6 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	      /* We use the `mbstate_t' member in DATA.  */
 	      result->__data[cnt].__statep = &result->__data[cnt].__state;
 
-	      /* Allocate the buffer.  */
-	      size = (GCONV_NCHAR_GOAL * steps[cnt].__max_needed_to);
-
-	      result->__data[cnt].__outbuf = (char *) malloc (size);
-	      if (result->__data[cnt].__outbuf == NULL)
-		goto bail;
-
-	      result->__data[cnt].__outbufend =
-		result->__data[cnt].__outbuf + size;
-
 	      /* Now see whether we can use any of the transliteration
 		 modules for this step.  */
 	      for (runp = trans; runp != NULL; runp = runp->next)
@@ -255,57 +241,33 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 			}
 		      break;
 		    }
-	    }
 
-	  /* Now handle the last entry.  */
-	  result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
-	  /* Would have to be done if we would not clear the whole
-	     array above.  */
-#if 0
-	  result->__data[cnt].__invocation_counter = 0;
-	  result->__data[cnt].__internal_use = 0;
-#endif
-	  result->__data[cnt].__statep = &result->__data[cnt].__state;
+	      result->__steps[cnt].__data = &result->__data[cnt];
 
-	  /* Now see whether we can use the transliteration module
-	     for this step.  */
-	  for (runp = trans; runp != NULL; runp = runp->next)
-	    for (n = 0; n < runp->ncsnames; ++n)
-	      if (__strcasecmp (steps[cnt].__from_name, runp->csnames[n]) == 0)
+	      /* If this is the last step we must not allocate an
+		 output buffer.  */
+	      if (cnt < nsteps - 1)
 		{
-		  void *data = NULL;
-
-		  /* Match!  Now try the initializer.  */
-		  if (runp->trans_init_fct == NULL
-		      || (runp->trans_init_fct (data, steps[cnt].__to_name)
-			  == __GCONV_OK))
-		    {
-		      /* Append at the end of the list.  */
-		      struct __gconv_trans_data *newp;
-		      struct __gconv_trans_data *endp;
-		      struct __gconv_trans_data *lastp;
+		  result->__data[cnt].__flags = conv_flags;
 
-		      newp = (struct __gconv_trans_data *)
-			malloc (sizeof (struct __gconv_trans_data));
-		      if (newp == NULL)
-			goto bail;
+		  /* Allocate the buffer.  */
+		  size = (GCONV_NCHAR_GOAL * steps[cnt].__max_needed_to);
 
-		      newp->__trans_fct = runp->trans_fct;
-		      newp->__trans_context_fct = runp->trans_context_fct;
-		      newp->__trans_end_fct = runp->trans_end_fct;
+		  result->__data[cnt].__outbuf = (char *) malloc (size);
+		  if (result->__data[cnt].__outbuf == NULL)
+		    goto bail;
 
-		      lastp = NULL;
-		      for (endp = result->__data[cnt].__trans;
-			   endp != NULL; endp = endp->__next)
-			lastp = endp;
+		  result->__data[cnt].__outbufend =
+		    result->__data[cnt].__outbuf + size;
+		}
+	      else
+		{
+		  /* Handle the last entry.  */
+		  result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
 
-		      if (lastp == NULL)
-			result->__data[cnt].__trans = newp;
-		      else
-			lastp->__next = newp;
-		    }
 		  break;
 		}
+	    }
 	}
 
       if (res != __GCONV_OK)
diff --git a/intl/Makefile b/intl/Makefile
index 8a5f05c4ca..07108b19de 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -51,7 +51,7 @@ ifneq ($(strip $(MSGFMT)),:)
 .PHONY: do-gettext-test
 tests: do-gettext-test
 do-gettext-test: tst-gettext.sh $(objpfx)tst-gettext
-	$(SHELL) -e $< $(common-objpfx) $(objpfx)
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
 endif
 endif
 endif
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 9af0269f65..10639f79c4 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,10 @@
+2000-07-12  Ulrich Drepper  <drepper@redhat.com>
+
+	* spinlock.c: Fix code for TEST_FOR_COMPARE_AND_SWAP being defined.
+	Add tests also to new alternative spinlock implementation.
+	* spinlock.h: Likewise.
+	Patch by Kaz Kylheku <kaz@ashi.footprints.net>.
+
 2000-07-06  Ulrich Drepper  <drepper@redhat.com>
 
 	* Version: Export __sigaction.
diff --git a/linuxthreads/Examples/ex8.c b/linuxthreads/Examples/ex8.c
index 89ad8ae5d5..1b9b335579 100644
--- a/linuxthreads/Examples/ex8.c
+++ b/linuxthreads/Examples/ex8.c
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <pthread.h>
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 enum
 {
diff --git a/linuxthreads/spinlock.c b/linuxthreads/spinlock.c
index a63c6535c9..38d6b8ef30 100644
--- a/linuxthreads/spinlock.c
+++ b/linuxthreads/spinlock.c
@@ -24,6 +24,11 @@
 #include "spinlock.h"
 #include "restart.h"
 
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+static void __pthread_acquire(int * spinlock);
+#endif
+
+
 /* The status field of a spinlock is a pointer whose least significant
    bit is a locked flag.
 
@@ -59,10 +64,10 @@ void internal_function __pthread_lock(struct _pthread_fastlock * lock,
 #if defined TEST_FOR_COMPARE_AND_SWAP
   if (!__pthread_has_cas)
 #endif
-#if !defined HAS_COMPARE_AND_SWAP
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
   {
     __pthread_acquire(&lock->__spinlock);
-    return 0;
+    return;
   }
 #endif
 
@@ -147,7 +152,7 @@ int __pthread_unlock(struct _pthread_fastlock * lock)
 #if defined TEST_FOR_COMPARE_AND_SWAP
   if (!__pthread_has_cas)
 #endif
-#if !defined HAS_COMPARE_AND_SWAP
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
   {
     WRITE_MEMORY_BARRIER();
     lock->__spinlock = 0;
@@ -237,7 +242,9 @@ struct wait_node {
 };
 
 static long wait_node_free_list;
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
 static int wait_node_free_list_spinlock;
+#endif
 
 /* Allocate a new node from the head of the free list using an atomic
    operation, or else using malloc if that list is empty.  A fundamental
@@ -247,8 +254,33 @@ static int wait_node_free_list_spinlock;
 
 static struct wait_node *wait_node_alloc(void)
 {
+#if defined HAS_COMPARE_AND_SWAP
   long oldvalue, newvalue;
+#endif
+
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    struct wait_node *new_node = 0;
 
+    __pthread_acquire(&wait_node_free_list_spinlock);
+    if (wait_node_free_list != 0) {
+      new_node = (struct wait_node *) wait_node_free_list;
+      wait_node_free_list = (long) new_node->next;
+    }
+    WRITE_MEMORY_BARRIER();
+    wait_node_free_list_spinlock = 0;
+
+    if (new_node == 0)
+      return malloc(sizeof *wait_node_alloc());
+
+    return new_node;
+  }
+#endif
+
+#if defined HAS_COMPARE_AND_SWAP
   do {
     oldvalue = wait_node_free_list;
 
@@ -257,10 +289,10 @@ static struct wait_node *wait_node_alloc(void)
 
     newvalue = (long) ((struct wait_node *) oldvalue)->next;
     WRITE_MEMORY_BARRIER();
-  } while (! compare_and_swap(&wait_node_free_list, oldvalue, newvalue,
-                              &wait_node_free_list_spinlock));
+  } while (! __compare_and_swap(&wait_node_free_list, oldvalue, newvalue));
 
   return (struct wait_node *) oldvalue;
+#endif
 }
 
 /* Return a node to the head of the free list using an atomic
@@ -268,37 +300,53 @@ static struct wait_node *wait_node_alloc(void)
 
 static void wait_node_free(struct wait_node *wn)
 {
+#if defined HAS_COMPARE_AND_SWAP
   long oldvalue, newvalue;
+#endif
+
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    __pthread_acquire(&wait_node_free_list_spinlock);
+    wn->next = (struct wait_node *) wait_node_free_list;
+    wait_node_free_list = (long) wn;
+    WRITE_MEMORY_BARRIER();
+    wait_node_free_list_spinlock = 0;
+    return;
+  }
+#endif
 
+#if defined HAS_COMPARE_AND_SWAP
   do {
     oldvalue = wait_node_free_list;
     wn->next = (struct wait_node *) oldvalue;
     newvalue = (long) wn;
     WRITE_MEMORY_BARRIER();
-  } while (! compare_and_swap(&wait_node_free_list, oldvalue, newvalue,
-                              &wait_node_free_list_spinlock));
+  } while (! __compare_and_swap(&wait_node_free_list, oldvalue, newvalue));
+#endif
 }
 
+#if defined HAS_COMPARE_AND_SWAP
+
 /* Remove a wait node from the specified queue.  It is assumed
    that the removal takes place concurrently with only atomic insertions at the
    head of the queue. */
 
 static void wait_node_dequeue(struct wait_node **pp_head,
 			      struct wait_node **pp_node,
-			      struct wait_node *p_node,
-			      int *spinlock)
+			      struct wait_node *p_node)
 {
-  long oldvalue, newvalue;
-
   /* If the node is being deleted from the head of the
      list, it must be deleted using atomic compare-and-swap.
      Otherwise it can be deleted in the straightforward way. */
 
   if (pp_node == pp_head) {
-    oldvalue = (long) p_node;
-    newvalue = (long) p_node->next;
-
-    if (compare_and_swap((long *) pp_node, oldvalue, newvalue, spinlock))
+    long oldvalue = (long) p_node;
+    long newvalue = (long) p_node->next;
+       
+    if (__compare_and_swap((long *) pp_node, oldvalue, newvalue))
       return;
 
     /* Oops! Compare and swap failed, which means the node is
@@ -314,12 +362,46 @@ static void wait_node_dequeue(struct wait_node **pp_head,
   return;
 }
 
+#endif
+
 void __pthread_alt_lock(struct _pthread_fastlock * lock,
 		        pthread_descr self)
 {
-  struct wait_node wait_node;
+#if defined HAS_COMPARE_AND_SWAP
   long oldstatus, newstatus;
+#endif
+  struct wait_node wait_node;
+
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    int suspend_needed = 0;
+    __pthread_acquire(&lock->__spinlock);
+
+    if (lock->__status == 0)
+      lock->__status = 1;
+    else {
+      if (self == NULL)
+	self = thread_self();
+
+      wait_node.abandoned = 0;
+      wait_node.next = (struct wait_node *) lock->__status;
+      wait_node.thr = self = thread_self();
+      suspend_needed = 1;
+    }
 
+    WRITE_MEMORY_BARRIER();
+    lock->__spinlock = 0;
+
+    if (suspend_needed)
+      suspend (self);
+    return;
+  }
+#endif
+
+#if defined HAS_COMPARE_AND_SWAP
   do {
     oldstatus = lock->__status;
     if (oldstatus == 0) {
@@ -344,6 +426,7 @@ void __pthread_alt_lock(struct _pthread_fastlock * lock,
 
   if (oldstatus != 0)
     suspend(self);
+#endif
 }
 
 /* Timed-out lock operation; returns 0 to indicate timeout. */
@@ -351,8 +434,11 @@ void __pthread_alt_lock(struct _pthread_fastlock * lock,
 int __pthread_alt_timedlock(struct _pthread_fastlock * lock,
 			    pthread_descr self, const struct timespec *abstime)
 {
+  long oldstatus;
+#if defined HAS_COMPARE_AND_SWAP
+  long newstatus;
+#endif
   struct wait_node *p_wait_node = wait_node_alloc();
-  long oldstatus, newstatus;
 
   /* Out of memory, just give up and do ordinary lock. */
   if (p_wait_node == 0) {
@@ -360,6 +446,32 @@ int __pthread_alt_timedlock(struct _pthread_fastlock * lock,
     return 1;
   }
 
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    __pthread_acquire(&lock->__spinlock);
+
+    if (lock->__status == 0)
+      lock->__status = 1;
+    else {
+      if (self == NULL)
+	self = thread_self();
+
+      p_wait_node->abandoned = 0;
+      p_wait_node->next = (struct wait_node *) lock->__status;
+      p_wait_node->thr = self = thread_self();
+    }
+
+    WRITE_MEMORY_BARRIER();
+    lock->__spinlock = 0;
+    oldstatus = 1; /* force suspend */
+    goto suspend;
+  }
+#endif
+
+#if defined HAS_COMPARE_AND_SWAP
   do {
     oldstatus = lock->__status;
     if (oldstatus == 0) {
@@ -376,6 +488,11 @@ int __pthread_alt_timedlock(struct _pthread_fastlock * lock,
     MEMORY_BARRIER();
   } while(! compare_and_swap(&lock->__status, oldstatus, newstatus,
                              &lock->__spinlock));
+#endif
+
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  suspend:
+#endif
 
   /* If we did not get the lock, do a timed suspend. If we wake up due
      to a timeout, then there is a race; the old lock owner may try
@@ -402,24 +519,50 @@ int __pthread_alt_timedlock(struct _pthread_fastlock * lock,
 
 void __pthread_alt_unlock(struct _pthread_fastlock *lock)
 {
-  long oldstatus;
   struct wait_node *p_node, **pp_node, *p_max_prio, **pp_max_prio;
   struct wait_node ** const pp_head = (struct wait_node **) &lock->__status;
   int maxprio;
 
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    __pthread_acquire(&lock->__spinlock);
+  }
+#endif
+
   while (1) {
 
   /* If no threads are waiting for this lock, try to just
      atomically release it. */
+#if defined TEST_FOR_COMPARE_AND_SWAP
+    if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+    {
+      if (lock->__status == 0 || lock->__status == 1) {
+	lock->__status = 0;
+	break;
+      }
+    }
+#endif
 
-    oldstatus = lock->__status;
-    if (oldstatus == 0 || oldstatus == 1) {
-      if (compare_and_swap_with_release_semantics (&lock->__status, oldstatus,
-						   0, &lock->__spinlock))
-	return;
-      else
-	continue;
+#if defined TEST_FOR_COMPARE_AND_SWAP
+    else
+#endif
+
+#if defined HAS_COMPARE_AND_SWAP
+    {
+      long oldstatus = lock->__status;
+      if (oldstatus == 0 || oldstatus == 1) {
+	if (__compare_and_swap_with_release_semantics (&lock->__status, oldstatus, 0))
+	  break;
+	else
+	  continue;
+      }
     }
+#endif
 
     /* Process the entire queue of wait nodes. Remove all abandoned
        wait nodes and put them into the global free queue, and
@@ -435,7 +578,18 @@ void __pthread_alt_unlock(struct _pthread_fastlock *lock)
 
       if (p_node->abandoned) {
 	/* Remove abandoned node. */
-	wait_node_dequeue(pp_head, pp_node, p_node, &lock->__spinlock);
+#if defined TEST_FOR_COMPARE_AND_SWAP
+	if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+	  *pp_node = p_node->next;
+#endif
+#if defined TEST_FOR_COMPARE_AND_SWAP
+	else
+#endif
+#if defined HAS_COMPARE_AND_SWAP
+	  wait_node_dequeue(pp_head, pp_node, p_node);
+#endif
 	wait_node_free(p_node);
 	READ_MEMORY_BARRIER();
 	p_node = *pp_node;
@@ -469,12 +623,33 @@ void __pthread_alt_unlock(struct _pthread_fastlock *lock)
        whole unlock operation. */
 
     if (!testandset(&p_max_prio->abandoned)) {
-      wait_node_dequeue(pp_head, pp_max_prio, p_max_prio, &lock->__spinlock);
+#if defined TEST_FOR_COMPARE_AND_SWAP
+      if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+	*pp_max_prio = p_max_prio->next;
+#endif
+#if defined TEST_FOR_COMPARE_AND_SWAP
+      else
+#endif
+#if defined HAS_COMPARE_AND_SWAP
+	wait_node_dequeue(pp_head, pp_max_prio, p_max_prio);
+#endif
       WRITE_MEMORY_BARRIER();
       restart(p_max_prio->thr);
-      return;
+      break;
     }
   }
+
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    WRITE_MEMORY_BARRIER();
+    lock->__spinlock = 0;
+  }
+#endif
 }
 
 
@@ -486,8 +661,6 @@ int __pthread_has_cas = 0;
 
 #if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
 
-static void __pthread_acquire(int * spinlock);
-
 int __pthread_compare_and_swap(long * ptr, long oldval, long newval,
                                int * spinlock)
 {
diff --git a/linuxthreads/spinlock.h b/linuxthreads/spinlock.h
index 6609ef71c9..435271d812 100644
--- a/linuxthreads/spinlock.h
+++ b/linuxthreads/spinlock.h
@@ -105,7 +105,7 @@ static inline int __pthread_trylock (struct _pthread_fastlock * lock)
 #if defined TEST_FOR_COMPARE_AND_SWAP
   if (!__pthread_has_cas)
 #endif
-#if !defined HAS_COMPARE_AND_SWAP
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
   {
     return (testandset(&lock->__spinlock) ? EBUSY : 0);
   }
@@ -140,13 +140,26 @@ static inline void __pthread_alt_init_lock(struct _pthread_fastlock * lock)
 
 static inline int __pthread_alt_trylock (struct _pthread_fastlock * lock)
 {
+#if defined HAS_COMPARE_AND_SWAP
   long oldstatus;
+#endif
+
+#if defined TEST_FOR_COMPARE_AND_SWAP
+  if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+  {
+    return (testandset(&lock->__spinlock) ? EBUSY : 0);
+  }
+#endif
 
+#if defined HAS_COMPARE_AND_SWAP
   do {
     oldstatus = lock->__status;
     if (oldstatus != 0) return EBUSY;
   } while(! compare_and_swap(&lock->__status, 0, 1, &lock->__spinlock));
   return 0;
+#endif
 }
 
 /* Initializers for both lock variants */
diff --git a/locale/langinfo.h b/locale/langinfo.h
index 2b777091bc..6425dec592 100644
--- a/locale/langinfo.h
+++ b/locale/langinfo.h
@@ -389,7 +389,7 @@ enum
 # define N_SIGN_POSN		__N_SIGN_POSN
 #endif
   _NL_MONETARY_CRNCYSTR,
-#define CRNCYSTR		__CRNCYSTR
+#define CRNCYSTR		_NL_MONETARY_CRNCYSTR
   __INT_P_CS_PRECEDES,
 #ifdef __USE_GNU
 # define INT_P_CS_PRECEDES	__INT_P_CS_PRECEDES
diff --git a/localedata/Makefile b/localedata/Makefile
index c9905a5e1a..cd6e39da9b 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -76,7 +76,6 @@ distribute := CHECKSUMS README SUPPORTED ChangeLog			\
 include ../Makeconfig
 
 ifeq (no,$(cross-compiling))
-ifeq (yes,$(build-shared))
 locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
 		     tst_iswctype tst_iswdigit tst_iswgraph            \
 		     tst_iswlower tst_iswprint tst_iswpunct            \
@@ -94,7 +93,6 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
 
 tests = $(locale_test_suite)
 endif
-endif
 
 # Files to install.
 install-others := $(addprefix $(inst_i18ndir)/, $(charmaps) $(locales) \
@@ -117,7 +115,6 @@ CFLAGS-tst-trans.c = -Wno-format
 
 
 ifeq (no,$(cross-compiling))
-ifeq (yes,$(build-shared))
 # We have to generate locales
 LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 \
 	   en_US.ISO-8859-1 ja_JP.EUC-JP
@@ -130,9 +127,9 @@ generated-dirs += $(LOCALES)
 # Dependency for the locale files.  We actually make it depend only on
 # one of the files.
 $(addprefix $(objpfx),$(CTYPE_FILES)): %: \
-  gen-locale.sh Makefile $(common-objpfx)locale/localedef \
+  gen-locale.sh $(common-objpfx)locale/localedef Makefile \
   $(addprefix charmaps/,$(CHARMAPS)) $(addprefix locales/,$(LOCALE_SRCS))
-	@$(SHELL) -e gen-locale.sh $(common-objpfx) $@
+	@$(SHELL) -e gen-locale.sh $(common-objpfx) '$(built-program-cmd)' $@
 
 $(addsuffix .out,$(addprefix $(objpfx),$(locale_test_suite))): %: \
   $(addprefix $(objpfx),$(CTYPE_FILES))
@@ -143,27 +140,26 @@ tests: do-collate-test do-tst-fmon do-tst-locale do-tst-rpmatch do-tst-trans \
        do-tst-mbswcs do-tst-ctype
 do-collate-test: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
 		 $(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx) $(test-input)
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(test-input)
 do-tst-fmon: tst-fmon.sh $(objpfx)tst-fmon tst-fmon.data do-collate-test \
 	     $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx) tst-fmon.data
-do-tst-locale: tst-locale.sh $(ld-test-srcs) \
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-fmon.data
+do-tst-locale: tst-locale.sh $(common-objpfx)locale/localedef $(ld-test-srcs) \
 	       $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx)
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
 do-tst-rpmatch: tst-rpmatch.sh $(objpfx)tst-rpmatch do-tst-fmon \
 		$(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx)
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
 do-tst-trans: tst-trans.sh $(objpfx)tst-trans \
 	      $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx)
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'
 do-tst-mbswcs: tst-mbswcs.sh $(objpfx)tst-mbswcs1 $(objpfx)tst-mbswcs2 \
 	       $(objpfx)tst-mbswcs3 $(objpfx)tst-mbswcs4 $(objpfx)tst-mbswcs5 \
 	       $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx)
+	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'
 do-tst-ctype: tst-ctype.sh $(objpfx)tst-ctype do-collate-test \
 	      $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) -e $< $(common-objpfx)
-endif
+	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
 endif
 
 # Sometimes the whole collection of locale files should be installed.
diff --git a/localedata/gen-locale.sh b/localedata/gen-locale.sh
index b68e364a1e..386665ca02 100644
--- a/localedata/gen-locale.sh
+++ b/localedata/gen-locale.sh
@@ -19,6 +19,7 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 common_objpfx="$1"; shift
+localedef="$1"; shift
 locfile="$1"; shift
 
 generate_locale ()
@@ -27,8 +28,7 @@ generate_locale ()
     input=$2
     out=$3
     I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
-    ${common_objpfx}elf/ld.so --library-path $common_objpfx \
-    ${common_objpfx}locale/localedef --quiet -c -f $charmap -i $input \
+    ${localedef} --quiet -c -f $charmap -i $input \
       ${common_objpfx}localedata/$out
 
     if [ $? -ne 0 ]; then
@@ -38,8 +38,9 @@ generate_locale ()
     fi
 }
 
-locale=`echo $locfile|sed 's|.*/\([^/.]*\)[.].*/LC_CTYPE|\1|'`
-charmap=`echo $locfile|sed 's|.*/[^/.]*[.]\(.*\)/LC_CTYPE|\1|'`
+locfile=`echo $locfile|sed 's|.*/\([^/]*/LC_CTYPE\)|\1|'`
+locale=`echo $locfile|sed 's|\([^.]*\)[.].*/LC_CTYPE|\1|'`
+charmap=`echo $locfile|sed 's|[^.]*[.]\(.*\)/LC_CTYPE|\1|'`
 
 echo "Generating locale $locale.$charmap: this might take a while..."
 generate_locale $charmap $locale $locale.$charmap
diff --git a/localedata/sort-test.sh b/localedata/sort-test.sh
index 18dbcd5362..6c22524612 100644
--- a/localedata/sort-test.sh
+++ b/localedata/sort-test.sh
@@ -1,6 +1,7 @@
 #! /bin/sh
 
 common_objpfx=$1; shift
+run_program_prefix=$1; shift
 lang=$*
 
 id=${PPID:-100}
@@ -11,13 +12,13 @@ status=0
 for l in $lang; do
   cns=`echo $l | sed 's/\(.*\)[.][^.]*/\1/'`
   LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}/iconvdata \
-   LC_ALL=$l ${common_objpfx}elf/ld.so --library-path $common_objpfx \
+   LC_ALL=$l ${run_program_prefix} \
    ${common_objpfx}localedata/collate-test $id < $cns.in \
    > ${common_objpfx}localedata/$cns.out || status=1
   cmp -s $cns.in ${common_objpfx}localedata/$cns.out || status=1
 
   LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}/iconvdata \
-   LC_ALL=$l ${common_objpfx}elf/ld.so --library-path $common_objpfx \
+   LC_ALL=$l ${run_program_prefix} \
    ${common_objpfx}localedata/xfrm-test $id < $cns.in \
    > ${common_objpfx}localedata/$cns.xout || status=1
   cmp -s $cns.in ${common_objpfx}localedata/$cns.xout || status=1
diff --git a/localedata/tst-ctype.sh b/localedata/tst-ctype.sh
index a0d51dccbc..5b906a2188 100755
--- a/localedata/tst-ctype.sh
+++ b/localedata/tst-ctype.sh
@@ -19,6 +19,7 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 common_objpfx=$1; shift
+tst_ctype=$1; shift
 status=0
 
 # Run the test programs.
@@ -30,8 +31,7 @@ for loc in de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 ja_JP.EUC-JP; do
     input=/dev/null
   fi
   LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-  LC_ALL=$loc ${common_objpfx}elf/ld.so --library-path $common_objpfx \
-    ${common_objpfx}localedata/tst-ctype < $input \
+  LC_ALL=$loc ${tst_ctype} < $input \
     >> ${common_objpfx}localedata/tst-ctype.out || status=1
 done
 
diff --git a/localedata/tst-fmon.sh b/localedata/tst-fmon.sh
index 469d227afb..99c5cc6801 100755
--- a/localedata/tst-fmon.sh
+++ b/localedata/tst-fmon.sh
@@ -25,7 +25,8 @@ case $1 in
 esac
 
 common_objpfx=$1
-datafile=$2
+run_program_prefix=$2
+datafile=$3
 
 here=`pwd`
 
@@ -37,19 +38,17 @@ for cns in `cd ./tst-fmon-locales && ls tstfmon_*`; do
     fn=charmaps/ISO-8859-1
     I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
     LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
-    ${common_objpfx}elf/ld.so --library-path $common_objpfx \
-    ${common_objpfx}locale/localedef \
+    ${run_program_prefix} ${common_objpfx}locale/localedef \
     --quiet -i $cn -f $fn ${common_objpfx}localedata/$cns
 done
 
 # Run the tests.
-IFS="	"                # This is a TAB
-while read locale format value expect; do
+# There's a TAB for IFS
+while IFS="	" read locale format value expect; do
     if [ -n "$format" ]; then
 	LOCPATH=${common_objpfx}localedata \
 	GCONV_PATH=${common_objpfx}/iconvdata \
-	${common_objpfx}elf/ld.so --library-path $common_objpfx \
-        ${common_objpfx}localedata/tst-fmon \
+	${run_program_prefix} ${common_objpfx}localedata/tst-fmon \
 	    "$locale" "$format" "$value" "$expect"
 	if [ $? -eq 0 ]; then
 	    if [ $DEBUG -eq 1 ]; then
diff --git a/localedata/tst-locale.sh b/localedata/tst-locale.sh
index 79e5410958..4d503114ee 100755
--- a/localedata/tst-locale.sh
+++ b/localedata/tst-locale.sh
@@ -20,6 +20,7 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 common_objpfx=$1; shift
+localedef=$1; shift
 
 test_locale ()
 {
@@ -32,8 +33,7 @@ test_locale ()
     fi
     I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
     LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
-    ${common_objpfx}elf/ld.so --library-path $common_objpfx \
-    ${common_objpfx}locale/localedef --quiet -c -f $charmap -i $input \
+    ${localedef} --quiet -c -f $charmap -i $input \
       ${rep} ${common_objpfx}localedata/$out
 
     if [ $? -ne 0 ]; then
diff --git a/localedata/tst-mbswcs.sh b/localedata/tst-mbswcs.sh
index 267ab48da2..575ba1a579 100755
--- a/localedata/tst-mbswcs.sh
+++ b/localedata/tst-mbswcs.sh
@@ -19,33 +19,29 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 common_objpfx=$1; shift
+run_program_prefix=$1; shift
 
 status=0
 
 # Run the test programs.
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
-  ${common_objpfx}localedata/tst-mbswcs1 \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs1 \
   > ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
-  ${common_objpfx}localedata/tst-mbswcs2 \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs2 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
-  ${common_objpfx}localedata/tst-mbswcs3 \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs3 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
-  ${common_objpfx}localedata/tst-mbswcs4 \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs4 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
-  ${common_objpfx}localedata/tst-mbswcs5 \
+${run_program_prefix} ${common_objpfx}localedata/tst-mbswcs5 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
 exit $status
diff --git a/localedata/tst-rpmatch.sh b/localedata/tst-rpmatch.sh
index dd6b8a135e..d3eb593c71 100755
--- a/localedata/tst-rpmatch.sh
+++ b/localedata/tst-rpmatch.sh
@@ -20,14 +20,14 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 common_objpfx=$1
-IFS="&"
+tst_rpmatch=$2
+
 rc=0
-while read locale string result dummy; do
+while IFS=\& read locale string result dummy; do
     if [ "$locale" != "#" ]; then
 	LOCPATH=${common_objpfx}localedata \
 	GCONV_PATH=${common_objpfx}/iconvdata \
-	${common_objpfx}elf/ld.so --library-path $common_objpfx \
-	${common_objpfx}localedata/tst-rpmatch $locale $string $result \
+	${tst_rpmatch} $locale $string $result \
 	|| exit 1
     fi
 done <<EOF
diff --git a/localedata/tst-trans.sh b/localedata/tst-trans.sh
index 83079f533a..85bb1b1db3 100755
--- a/localedata/tst-trans.sh
+++ b/localedata/tst-trans.sh
@@ -19,10 +19,11 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 common_objpfx=$1
+run_program_prefix=$2
 
 # Generate the necessary locale data.
 I18NPATH=. GCONV_PATH=${common_objpfx}/iconvdata \
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${run_program_prefix} \
 ${common_objpfx}locale/localedef --quiet \
 -i tests/trans.def -f charmaps/ISO-8859-1 \
 ${common_objpfx}localedata/tt_TT ||
@@ -30,7 +31,7 @@ exit 1
 
 # Run the test program.
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-LC_ALL=tt_TT ${common_objpfx}elf/ld.so --library-path $common_objpfx \
+LC_ALL=tt_TT ${run_program_prefix} \
 ${common_objpfx}localedata/tst-trans > ${common_objpfx}localedata/tst-trans.out
 
 exit $?
diff --git a/nss/getent.c b/nss/getent.c
index 02f2034efb..d3a9fde1e1 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -366,7 +366,7 @@ services_keys (int number, char *key[])
 	  *proto++ = '\0';
 
 	  if (isdigit (key[i][0]))
-	    serv = getservbyport (atol (key[i]), proto);
+	    serv = getservbyport (htons (atol (key[i])), proto);
 	  else
 	    serv = getservbyname (key[i], proto);
 
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 2427e617fc..9eededd095 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -127,7 +127,7 @@ clean-mpn:
 endif
 
 # Testdir has to be named stdlib and needs to be writable
-test-canon-ARGS = --test-dir=${objdir}/stdlib
+test-canon-ARGS = --test-dir=${common-objpfx}stdlib
 
 # Run a test on the header files we use.
 tests: $(objpfx)isomac