Module Name: src
Committed By: snj
Date: Fri Apr 3 17:47:43 UTC 2009
Modified Files:
src/lib/libpthread [netbsd-5]: pthread.c
Log Message:
Pull up following revision(s) (requested by drochner in ticket #648):
lib/libpthread/pthread.c: revision 1.109
Fix the comparision function used by the red-black tree global thread list
implementation:
-don't return a difference, this can overflow
-don't try to substract typed pointers which don't belong to the
same object, this gives undefined results
This fixes instabilities of programs which use more than a handful
of threads, eg spuriously failing pthread_join().
To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.106.2.1 src/lib/libpthread/pthread.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.106 src/lib/libpthread/pthread.c:1.106.2.1
--- src/lib/libpthread/pthread.c:1.106 Wed Oct 8 10:03:28 2008
+++ src/lib/libpthread/pthread.c Fri Apr 3 17:47:43 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread.c,v 1.106 2008/10/08 10:03:28 ad Exp $ */
+/* $NetBSD: pthread.c,v 1.106.2.1 2009/04/03 17:47:43 snj Exp $ */
/*-
* Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.106 2008/10/08 10:03:28 ad Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.106.2.1 2009/04/03 17:47:43 snj Exp $");
#define __EXPOSE_STACK 1
@@ -1281,7 +1281,13 @@
static int
pthread__cmp(struct __pthread_st *a, struct __pthread_st *b)
{
- return b - a;
+
+ if ((uintptr_t)a < (uintptr_t)b)
+ return (-1);
+ else if (a == b)
+ return 0;
+ else
+ return 1;
}
RB_GENERATE_STATIC(__pthread__alltree, __pthread_st, pt_alltree, pthread__cmp)
#endif