ARM build fixes (mostly)

Daniel Jacobowitz drow@false.org
Tue Jul 10 13:36:00 GMT 2007


This patch mostly restores glibc on ARM.  I also needed an NPTL patch
which I'll send to libc-alpha.  Checked in.

-- 
Daniel Jacobowitz
CodeSourcery

2007-07-10  Daniel Jacobowitz  <dan@codesourcery.com>

	* sysdeps/arm/nptl/tls.h (THREAD_GSCOPE_RESET_FLAG): Use
	lll_private_futex_wake.
	* sysdeps/unix/sysv/linux/arm/check_pf.c: Update from generic version.
	* sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
	(pthread_cancel_init): Add noinline and barriers.
	* sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c
	(__lll_timedlock_wait): Update call to lll_futex_timed_wait.
	(__lll_timedwait_tid): Likewise.
	* sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h (LLL_PRIVATE,
	LLL_SHARED): Define.
	(lll_futex_wait): Use lll_futex_timed_wait.
	(lll_futex_timed_wait, lll_futex_wake, lll_futex_wake_unlock): Take a
	PRIVATE argument.
	(lll_private_futex_wait, lll_private_futex_timed_wait,
	lll_private_futex_wake): New.
	(lll_robust_mutex_dead,  __lll_mutex_lock, __lll_mutex_cond_lock,
	__lll_mutex_unlock, __lll_robust_mutex_unlock,
	__lll_mutex_unlock_force, lll_wait_tid): Update calls.
	* sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c (clear_once_control,
	__pthread_once): Use private futexes.
	* sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c
	(pthread_cancel_init): Add noinline and barriers.

	* sysdeps/unix/sysv/aix/bits/fcntl.h,
	sysdeps/unix/sysv/linux/am33/bits/fcntl.h,
	sysdeps/unix/sysv/linux/arm/bits/fcntl.h,
	sysdeps/unix/sysv/linux/cris/bits/fcntl.h,
	sysdeps/unix/sysv/linux/m68k/bits/fcntl.h,
	sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Comment fix.

	* sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h (SEM_VALUE_MAX):
	Delete.
	* sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h (SEM_VALUE_MAX):
	Delete.

Index: sysdeps/arm/nptl/tls.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/arm/nptl/tls.h,v
retrieving revision 1.2
diff -u -p -r1.2 tls.h
--- sysdeps/arm/nptl/tls.h	6 Jun 2007 17:27:04 -0000	1.2
+++ sysdeps/arm/nptl/tls.h	10 Jul 2007 13:19:39 -0000
@@ -142,7 +142,7 @@ typedef struct
 	= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,	     \
 			       THREAD_GSCOPE_FLAG_UNUSED);		     \
       if (__res == THREAD_GSCOPE_FLAG_WAIT)				     \
-	lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1);		     \
+	lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1);	     \
     }									     \
   while (0)
 #define THREAD_GSCOPE_SET_FLAG() \
Index: sysdeps/unix/sysv/aix/bits/fcntl.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/aix/bits/fcntl.h,v
retrieving revision 1.4
diff -u -p -r1.4 fcntl.h
--- sysdeps/unix/sysv/aix/bits/fcntl.h	3 May 2004 21:39:38 -0000	1.4
+++ sysdeps/unix/sysv/aix/bits/fcntl.h	10 Jul 2007 13:19:39 -0000
@@ -79,7 +79,7 @@
 # define F_GETOWN	9	/* Set owner of socket (receiver of SIGIO).  */
 #endif
 
-/* For F_[GET|SET]FL.  */
+/* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
Index: sysdeps/unix/sysv/linux/am33/bits/fcntl.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/am33/bits/fcntl.h,v
retrieving revision 1.1
diff -u -p -r1.1 fcntl.h
--- sysdeps/unix/sysv/linux/am33/bits/fcntl.h	23 Oct 2004 00:33:35 -0000	1.1
+++ sysdeps/unix/sysv/linux/am33/bits/fcntl.h	10 Jul 2007 13:19:39 -0000
@@ -94,7 +94,7 @@
 # define F_NOTIFY	1026	/* Request notfications on a directory.	 */
 #endif
 
-/* For F_[GET|SET]FL.  */
+/* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
Index: sysdeps/unix/sysv/linux/arm/check_pf.c
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/check_pf.c,v
retrieving revision 1.1
diff -u -p -r1.1 check_pf.c
--- sysdeps/unix/sysv/linux/arm/check_pf.c	8 Jan 2007 15:06:00 -0000	1.1
+++ sysdeps/unix/sysv/linux/arm/check_pf.c	10 Jul 2007 13:19:39 -0000
@@ -1,5 +1,5 @@
-/* Determine protocol families for which interfaces exist.  ARM Linux version.
-   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+/* Determine protocol families for which interfaces exist.  Linux version.
+   Copyright (C) 2003, 2006, 2007 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
@@ -69,17 +69,38 @@ make_request (int fd, pid_t pid, bool *s
   memset (&nladdr, '\0', sizeof (nladdr));
   nladdr.nl_family = AF_NETLINK;
 
+#ifdef PAGE_SIZE
+  /* Help the compiler optimize out the malloc call if PAGE_SIZE
+     is constant and smaller or equal to PTHREAD_STACK_MIN/4.  */
+  const size_t buf_size = PAGE_SIZE;
+#else
+  const size_t buf_size = __getpagesize ();
+#endif
+  bool use_malloc = false;
+  char *buf;
+
+  if (__libc_use_alloca (buf_size))
+    buf = alloca (buf_size);
+  else
+    {
+      buf = malloc (buf_size);
+      if (buf != NULL)
+	use_malloc = true;
+      else
+	goto out_fail;
+    }
+
+  struct iovec iov = { buf, buf_size };
+
   if (TEMP_FAILURE_RETRY (__sendto (fd, (void *) &req, sizeof (req), 0,
 				    (struct sockaddr *) &nladdr,
 				    sizeof (nladdr))) < 0)
-    return -1;
+    goto out_fail;
 
   *seen_ipv4 = false;
   *seen_ipv6 = false;
 
   bool done = false;
-  char buf[4096];
-  struct iovec iov = { buf, sizeof (buf) };
   struct in6ailist
   {
     struct in6addrinfo info;
@@ -99,10 +120,10 @@ make_request (int fd, pid_t pid, bool *s
 
       ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
       if (read_len < 0)
-	return -1;
+	goto out_fail;
 
       if (msg.msg_flags & MSG_TRUNC)
-	return -1;
+	goto out_fail;
 
       struct nlmsghdr *nlmh;
       for (nlmh = (struct nlmsghdr *) buf;
@@ -116,40 +137,72 @@ make_request (int fd, pid_t pid, bool *s
 	  if (nlmh->nlmsg_type == RTM_NEWADDR)
 	    {
 	      struct ifaddrmsg *ifam = (struct ifaddrmsg *) NLMSG_DATA (nlmh);
+	      struct rtattr *rta = IFA_RTA (ifam);
+	      size_t len = nlmh->nlmsg_len - NLMSG_LENGTH (sizeof (*ifam));
 
 	      switch (ifam->ifa_family)
 		{
+		  const void *local;
+		  const void *address;
+
 		case AF_INET:
-		  *seen_ipv4 = true;
+		  local = NULL;
+		  address = NULL;
+		  while (RTA_OK (rta, len))
+		    {
+		      switch (rta->rta_type)
+			{
+			case IFA_LOCAL:
+			  local = RTA_DATA (rta);
+			  break;
+
+			case IFA_ADDRESS:
+			  address = RTA_DATA (rta);
+			  goto out_v4;
+			}
+
+		      rta = RTA_NEXT (rta, len);
+		    }
+
+		  if (local != NULL)
+		    {
+		    out_v4:
+		      if (*(const in_addr_t *) (address ?: local)
+			  != htonl (INADDR_LOOPBACK))
+			*seen_ipv4 = true;
+		    }
 		  break;
+
 		case AF_INET6:
-		  *seen_ipv6 = true;
+		  local = NULL;
+		  address = NULL;
+		  while (RTA_OK (rta, len))
+		    {
+		      switch (rta->rta_type)
+			{
+			case IFA_LOCAL:
+			  local = RTA_DATA (rta);
+			  break;
+
+			case IFA_ADDRESS:
+			  address = RTA_DATA (rta);
+			  goto out_v6;
+			}
+
+		      rta = RTA_NEXT (rta, len);
+		    }
+
+		  if (local != NULL)
+		    {
+		    out_v6:
+		      if (!IN6_IS_ADDR_LOOPBACK (address ?: local))
+			*seen_ipv6 = true;
+		    }
 
 		  if (ifam->ifa_flags & (IFA_F_DEPRECATED
 					 | IFA_F_TEMPORARY
 					 | IFA_F_HOMEADDRESS))
 		    {
-		      struct rtattr *rta = IFA_RTA (ifam);
-		      size_t len = (nlmh->nlmsg_len
-				    - NLMSG_LENGTH (sizeof (*ifam)));
-		      void *local = NULL;
-		      void *address = NULL;
-		      while (RTA_OK (rta, len))
-			{
-			  switch (rta->rta_type)
-			    {
-			    case IFA_LOCAL:
-			      local = RTA_DATA (rta);
-			      break;
-
-			    case IFA_ADDRESS:
-			      address = RTA_DATA (rta);
-			      break;
-			    }
-
-			  rta = RTA_NEXT (rta, len);
-			}
-
 		      struct in6ailist *newp = alloca (sizeof (*newp));
 		      newp->info.flags = (((ifam->ifa_flags & IFA_F_DEPRECATED)
 					   ? in6ai_deprecated : 0)
@@ -180,11 +233,11 @@ make_request (int fd, pid_t pid, bool *s
 
   close_not_cancel_no_status (fd);
 
-  if (in6ailist != NULL)
+  if (*seen_ipv6 && in6ailist != NULL)
     {
       *in6ai = malloc (in6ailistlen * sizeof (**in6ai));
       if (*in6ai == NULL)
-	return -1;
+	goto out_fail;
 
       *in6ailen = in6ailistlen;
 
@@ -196,7 +249,14 @@ make_request (int fd, pid_t pid, bool *s
       while (in6ailist != NULL);
     }
 
+  if (use_malloc)
+    free (buf);
   return 0;
+
+out_fail:
+  if (use_malloc)
+    free (buf);
+  return -1;
 }
 
 
Index: sysdeps/unix/sysv/linux/arm/bits/fcntl.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/bits/fcntl.h,v
retrieving revision 1.12
diff -u -p -r1.12 fcntl.h
--- sysdeps/unix/sysv/linux/arm/bits/fcntl.h	31 Oct 2006 17:18:09 -0000	1.12
+++ sysdeps/unix/sysv/linux/arm/bits/fcntl.h	10 Jul 2007 13:19:39 -0000
@@ -98,7 +98,7 @@
 # define F_NOTIFY	1026	/* Request notfications on a directory.	 */
 #endif
 
-/* For F_[GET|SET]FL.  */
+/* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
Index: sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c,v
retrieving revision 1.1
diff -u -p -r1.1 unwind-forcedunwind.c
--- sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c	16 Nov 2005 19:03:42 -0000	1.1
+++ sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c	10 Jul 2007 13:19:39 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>.
 
@@ -30,13 +30,18 @@ static _Unwind_Reason_Code (*libgcc_s_fo
 static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
 
 void
+__attribute_noinline__
 pthread_cancel_init (void)
 {
   void *resume, *personality, *forcedunwind, *getcfa;
   void *handle;
 
   if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
-    return;
+    {
+      /* Force gcc to reload all values.  */
+      asm volatile ("" ::: "memory");
+      return;
+    }
 
   handle = __libc_dlopen ("libgcc_s.so.1");
 
@@ -55,6 +60,10 @@ pthread_cancel_init (void)
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
   libgcc_s_forcedunwind = forcedunwind;
+  /* Make sure libgcc_s_getcfa is written last.  Otherwise,
+     pthread_cancel_init might return early even when the pointer the
+     caller is interested in is not initialized yet.  */
+  atomic_write_barrier ();
   libgcc_s_getcfa = getcfa;
 }
 
@@ -92,6 +101,7 @@ __gcc_personality_v0 (_Unwind_State stat
 {
   if (__builtin_expect (libgcc_s_personality == NULL, 0))
     pthread_cancel_init ();
+
   return libgcc_s_personality (state, ue_header, context);
 }
 
@@ -101,6 +111,7 @@ _Unwind_ForcedUnwind (struct _Unwind_Exc
 {
   if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
     pthread_cancel_init ();
+
   return libgcc_s_forcedunwind (exc, stop, stop_argument);
 }
 
@@ -109,5 +120,6 @@ _Unwind_GetCFA (struct _Unwind_Context *
 {
   if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
     pthread_cancel_init ();
+
   return libgcc_s_getcfa (context);
 }
Index: sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c,v
retrieving revision 1.2
diff -u -p -r1.2 lowlevellock.c
--- sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c	6 Jun 2007 17:27:04 -0000	1.2
+++ sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c	10 Jul 2007 13:19:39 -0000
@@ -55,7 +55,8 @@ __lll_timedlock_wait (int *futex, const 
       if (rt.tv_sec < 0)
 	return ETIMEDOUT;
 
-      lll_futex_timed_wait (futex, 2, &rt);
+      // XYZ: Lost the lock to check whether it was private.
+      lll_futex_timed_wait (futex, 2, &rt, LLL_SHARED);
     }
   while (atomic_exchange_acq (futex, 2) != 0);
 
@@ -96,7 +97,8 @@ __lll_timedwait_tid (int *tidp, const st
 	return ETIMEDOUT;
 
       /* Wait until thread terminates.  */
-      if (lll_futex_timed_wait (tidp, tid, &rt) == -ETIMEDOUT)
+      // XYZ: Lost the lock to check whether it was private.
+      if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
 	return ETIMEDOUT;
     }
 
Index: sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h,v
retrieving revision 1.4
diff -u -p -r1.4 lowlevellock.h
--- sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h	6 Jun 2007 17:27:04 -0000	1.4
+++ sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h	10 Jul 2007 13:19:39 -0000
@@ -12,7 +12,7 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Libr	\ary; if not, write to the Free
+   License along with the GNU C Library; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
@@ -36,42 +36,87 @@
 #define FUTEX_TRYLOCK_PI	8
 #define FUTEX_PRIVATE_FLAG	128
 
+/* Values for 'private' parameter of locking macros.  Yes, the
+   definition seems to be backwards.  But it is not.  The bit will be
+   reversed before passing to the system call.  */
+#define LLL_PRIVATE	0
+#define LLL_SHARED	FUTEX_PRIVATE_FLAG
+
 /* Initializer for compatibility lock.	*/
 #define LLL_MUTEX_LOCK_INITIALIZER (0)
 
-#define lll_futex_wait(futexp, val) \
+#define lll_futex_wait(futexp, val, private) \
+  lll_futex_timed_wait(futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
   ({									      \
     INTERNAL_SYSCALL_DECL (__err);					      \
     long int __ret;							      \
     __ret = INTERNAL_SYSCALL (futex, __err, 4,				      \
-			      (futexp), FUTEX_WAIT, (val), 0);		      \
+			      (futexp), FUTEX_WAIT, (val), (timespec));	      \
     __ret;								      \
   })
 
-#define lll_futex_timed_wait(futexp, val, timespec) \
+#define lll_futex_wake(futexp, nr, private) \
   ({									      \
     INTERNAL_SYSCALL_DECL (__err);					      \
     long int __ret;							      \
     __ret = INTERNAL_SYSCALL (futex, __err, 4,				      \
-			      (futexp), FUTEX_WAIT, (val), (timespec));	      \
+			      (futexp), FUTEX_WAKE, (nr), 0);		      \
     __ret;								      \
   })
 
-#define lll_futex_wake(futexp, nr) \
+#define lll_private_futex_wait(futexp, val) \
+  lll_private_futex_timed_wait(futexp, val, NULL)
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+#define lll_private_futex_timed_wait(futexp, val, timespec) \
   ({									      \
     INTERNAL_SYSCALL_DECL (__err);					      \
     long int __ret;							      \
     __ret = INTERNAL_SYSCALL (futex, __err, 4,				      \
-			      (futexp), FUTEX_WAKE, (nr), 0);		      \
+			      (futexp), FUTEX_WAIT | FUTEX_PRIVATE_FLAG,      \
+			      (val), (timespec));			      \
+    __ret;								      \
+  })
+
+#define lll_private_futex_wake(futexp, nr) \
+  ({									      \
+    INTERNAL_SYSCALL_DECL (__err);					      \
+    long int __ret;							      \
+    __ret = INTERNAL_SYSCALL (futex, __err, 4,				      \
+			      (futexp), FUTEX_WAKE | FUTEX_PRIVATE_FLAG,      \
+			      (nr), (0));				      \
+    __ret;								      \
+  })
+#else
+#define lll_private_futex_timed_wait(futexp, val, timespec) \
+  ({									      \
+    INTERNAL_SYSCALL_DECL (__err);					      \
+    long int __ret, __op;						      \
+    __op = FUTEX_WAIT | THREAD_GETMEM (THREAD_SELF, header.private_futex);    \
+    __ret = INTERNAL_SYSCALL (futex, __err, 4,				      \
+			      (futexp), __op, (val), (timespec));	      \
+    __ret;								      \
+  })
+
+#define lll_private_futex_wake(futexp, nr) \
+  ({									      \
+    INTERNAL_SYSCALL_DECL (__err);					      \
+    long int __ret, __op;						      \
+    __op = FUTEX_WAKE | THREAD_GETMEM (THREAD_SELF, header.private_futex);    \
+    __ret = INTERNAL_SYSCALL (futex, __err, 4,				      \
+			      (futexp), __op, (nr), 0);			      \
     __ret;								      \
   })
+#endif
 
 #define lll_robust_mutex_dead(futexv) \
   do									      \
     {									      \
       int *__futexp = &(futexv);					      \
       atomic_or (__futexp, FUTEX_OWNER_DIED);				      \
-      lll_futex_wake (__futexp, 1);					      \
+      lll_futex_wake (__futexp, 1, 0);					      \
     }									      \
   while (0)
 
@@ -88,7 +133,7 @@
 
 
 /* Returns non-zero if error happened, zero if success.  */
-#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
   ({									      \
     INTERNAL_SYSCALL_DECL (__err);					      \
     long int __ret;							      \
@@ -156,7 +201,7 @@ __lll_mutex_lock (int *futex)
   if (__builtin_expect (val != 0, 0))
     {
       while (atomic_exchange_acq (futex, 2) != 0)
-	lll_futex_wait (futex, 2);
+	lll_futex_wait (futex, 2, 0);
     }
 }
 #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
@@ -182,7 +227,7 @@ __lll_mutex_cond_lock (int *futex)
   if (__builtin_expect (val != 0, 0))
     {
       while (atomic_exchange_acq (futex, 2) != 0)
-	lll_futex_wait (futex, 2);
+	lll_futex_wait (futex, 2, 0);
     }
 }
 #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
@@ -229,7 +274,7 @@ __lll_mutex_unlock (int *futex)
 {
   int val = atomic_exchange_rel (futex, 0);
   if (__builtin_expect (val > 1, 0))
-    lll_futex_wake (futex, 1);
+    lll_futex_wake (futex, 1, 0);
 }
 #define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
 
@@ -239,7 +284,7 @@ __lll_robust_mutex_unlock (int *futex, i
 {
   int val = atomic_exchange_rel (futex, 0);
   if (__builtin_expect (val & mask, 0))
-    lll_futex_wake (futex, 1);
+    lll_futex_wake (futex, 1, 0);
 }
 #define lll_robust_mutex_unlock(futex) \
   __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
@@ -249,7 +294,7 @@ static inline void __attribute__ ((alway
 __lll_mutex_unlock_force (int *futex)
 {
   (void) atomic_exchange_rel (futex, 0);
-  lll_futex_wake (futex, 1);
+  lll_futex_wake (futex, 1, 0);
 }
 #define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
 
@@ -286,7 +331,7 @@ typedef int lll_lock_t;
   do {					\
     __typeof (tid) __tid;		\
     while ((__tid = (tid)) != 0)	\
-      lll_futex_wait (&(tid), __tid);	\
+      lll_futex_wait (&(tid), __tid, 0);\
   } while (0)
 
 extern int __lll_timedwait_tid (int *, const struct timespec *)
Index: sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c,v
retrieving revision 1.1
diff -u -p -r1.1 pthread_once.c
--- sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c	16 Nov 2005 19:03:42 -0000	1.1
+++ sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c	10 Jul 2007 13:19:39 -0000
@@ -27,7 +27,7 @@ clear_once_control (void *arg)
   pthread_once_t *once_control = (pthread_once_t *) arg;
 
   *once_control = 0;
-  lll_futex_wake (once_control, INT_MAX);
+  lll_private_futex_wake (once_control, INT_MAX);
 }
 
 int
@@ -66,7 +66,7 @@ __pthread_once (pthread_once_t *once_con
 	break;
 
       /* Same generation, some other thread was faster. Wait.  */
-      lll_futex_wait (once_control, oldval);
+      lll_private_futex_wait (once_control, oldval);
     }
 
   /* This thread is the first here.  Do the initialization.
@@ -82,7 +82,7 @@ __pthread_once (pthread_once_t *once_con
   *once_control = __fork_generation | 2;
 
   /* Wake up all other threads.  */
-  lll_futex_wake (once_control, INT_MAX);
+  lll_private_futex_wake (once_control, INT_MAX);
 
   return 0;
 }
Index: sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c,v
retrieving revision 1.1
diff -u -p -r1.1 unwind-forcedunwind.c
--- sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c	16 Nov 2005 19:22:59 -0000	1.1
+++ sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c	10 Jul 2007 13:19:39 -0000
@@ -33,6 +33,7 @@ static void (*libgcc_s_sjlj_register) (s
 static void (*libgcc_s_sjlj_unregister) (struct SjLj_Function_Context *);
 
 void
+__attribute_noinline__
 pthread_cancel_init (void)
 {
   void *resume, *personality, *forcedunwind, *getcfa;
@@ -40,7 +41,11 @@ pthread_cancel_init (void)
   void *sjlj_register, *sjlj_unregister;
 
   if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
-    return;
+    {
+      /* Force gcc to reload all values.  */
+      asm volatile ("" ::: "memory");
+      return;
+    }
 
   handle = __libc_dlopen ("libgcc_s.so.1");
 
@@ -58,9 +63,13 @@ pthread_cancel_init (void)
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
   libgcc_s_forcedunwind = forcedunwind;
-  libgcc_s_getcfa = getcfa;
   libgcc_s_sjlj_register = sjlj_register;
   libgcc_s_sjlj_unregister = sjlj_unregister;
+  /* Make sure libgcc_s_getcfa is written last.  Otherwise,
+     pthread_cancel_init might return early even when the pointer the
+     caller is interested in is not initialized yet.  */
+  atomic_write_barrier ();
+  libgcc_s_getcfa = getcfa;
 }
 
 void
@@ -68,6 +77,7 @@ _Unwind_Resume (struct _Unwind_Exception
 {
   if (__builtin_expect (libgcc_s_resume == NULL, 0))
     pthread_cancel_init ();
+
   libgcc_s_resume (exc);
 }
 
@@ -79,6 +89,7 @@ __gcc_personality_v0 (int version, _Unwi
 {
   if (__builtin_expect (libgcc_s_personality == NULL, 0))
     pthread_cancel_init ();
+
   return libgcc_s_personality (version, actions, exception_class,
 			       ue_header, context);
 }
@@ -89,6 +100,7 @@ _Unwind_ForcedUnwind (struct _Unwind_Exc
 {
   if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
     pthread_cancel_init ();
+
   return libgcc_s_forcedunwind (exc, stop, stop_argument);
 }
 
@@ -97,6 +109,7 @@ _Unwind_GetCFA (struct _Unwind_Context *
 {
   if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
     pthread_cancel_init ();
+
   return libgcc_s_getcfa (context);
 }
 
@@ -105,6 +118,7 @@ _Unwind_SjLj_Register (struct SjLj_Funct
 {
   if (__builtin_expect (libgcc_s_sjlj_register == NULL, 0))
     pthread_cancel_init ();
+
   libgcc_s_sjlj_register (fc);
 }
 
@@ -113,5 +127,6 @@ _Unwind_SjLj_Unregister (struct SjLj_Fun
 {
   if (__builtin_expect (libgcc_s_sjlj_unregister == NULL, 0))
     pthread_cancel_init ();
+
   libgcc_s_sjlj_unregister (fc);
 }
Index: sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h,v
retrieving revision 1.1
diff -u -p -r1.1 semaphore.h
--- sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h	16 Nov 2005 19:03:42 -0000	1.1
+++ sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h	10 Jul 2007 13:19:39 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005, 2007 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
@@ -27,9 +27,6 @@
 /* Value returned if `sem_open' failed.  */
 #define SEM_FAILED      ((sem_t *) 0)
 
-/* Maximum value the semaphore can have.  */
-#define SEM_VALUE_MAX   ((int) ((~0u) >> 1))
-
 
 typedef union
 {
Index: sysdeps/unix/sysv/linux/cris/bits/fcntl.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/cris/bits/fcntl.h,v
retrieving revision 1.5
diff -u -p -r1.5 fcntl.h
--- sysdeps/unix/sysv/linux/cris/bits/fcntl.h	23 Aug 2004 07:28:44 -0000	1.5
+++ sysdeps/unix/sysv/linux/cris/bits/fcntl.h	10 Jul 2007 13:19:39 -0000
@@ -96,7 +96,7 @@
 # define F_NOTIFY	1026	/* Request notfications on a directory.	 */
 #endif
 
-/* For F_[GET|SET]FL.  */
+/* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
Index: sysdeps/unix/sysv/linux/m68k/bits/fcntl.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/m68k/bits/fcntl.h,v
retrieving revision 1.7
diff -u -p -r1.7 fcntl.h
--- sysdeps/unix/sysv/linux/m68k/bits/fcntl.h	23 Aug 2004 07:28:45 -0000	1.7
+++ sysdeps/unix/sysv/linux/m68k/bits/fcntl.h	10 Jul 2007 13:19:40 -0000
@@ -95,7 +95,7 @@
 # define F_NOTIFY	1026	/* Request notfications on a directory.	 */
 #endif
 
-/* For F_[GET|SET]FL.  */
+/* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
Index: sysdeps/unix/sysv/linux/mips/bits/fcntl.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/mips/bits/fcntl.h,v
retrieving revision 1.25
diff -u -p -r1.25 fcntl.h
--- sysdeps/unix/sysv/linux/mips/bits/fcntl.h	31 Oct 2006 17:17:46 -0000	1.25
+++ sysdeps/unix/sysv/linux/mips/bits/fcntl.h	10 Jul 2007 13:19:40 -0000
@@ -101,7 +101,7 @@
 # define F_NOTIFY	1026	/* Request notfications on a directory.	 */
 #endif
 
-/* For F_[GET|SET]FL.  */
+/* For F_[GET|SET]FD.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
Index: sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h,v
retrieving revision 1.1
diff -u -p -r1.1 semaphore.h
--- sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h	28 Mar 2005 09:21:52 -0000	1.1
+++ sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h	10 Jul 2007 13:19:40 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005, 2007 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
@@ -29,9 +29,6 @@
 /* Value returned if `sem_open' failed.  */
 #define SEM_FAILED      ((sem_t *) 0)
 
-/* Maximum value the semaphore can have.  */
-#define SEM_VALUE_MAX   (2147483647)
-
 
 typedef union
 {



More information about the Libc-ports mailing list