Module Name:    src
Committed By:   hans
Date:           Thu Jul 29 12:56:16 UTC 2010

Modified Files:
        src/tests/lib/libpthread: t_join.c

Log Message:
Revert to 1.1 and fix the casts by using uintptr_t.  Ok jruoho.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_join.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libpthread/t_join.c
diff -u src/tests/lib/libpthread/t_join.c:1.3 src/tests/lib/libpthread/t_join.c:1.4
--- src/tests/lib/libpthread/t_join.c:1.3	Thu Jul 29 12:17:31 2010
+++ src/tests/lib/libpthread/t_join.c	Thu Jul 29 12:56:16 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: t_join.c,v 1.3 2010/07/29 12:17:31 jruoho Exp $ */
+/* $NetBSD: t_join.c,v 1.4 2010/07/29 12:56:16 hans Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_join.c,v 1.3 2010/07/29 12:17:31 jruoho Exp $");
+__RCSID("$NetBSD: t_join.c,v 1.4 2010/07/29 12:56:16 hans Exp $");
 
 #include <errno.h>
 #include <pthread.h>
@@ -64,8 +64,8 @@
 {
 	pthread_t thread[25];
 	pthread_t caller;
-	void *val;
-	size_t i;
+	void *val = NULL;
+	uintptr_t i;
 	int rv;
 
 	caller = pthread_self();
@@ -86,7 +86,7 @@
 
 		error = true;
 
-		rv = pthread_create(&thread[i], NULL, threadfunc2, NULL);
+		rv = pthread_create(&thread[i], NULL, threadfunc2, (void *)i);
 
 		ATF_REQUIRE_EQ(rv, 0);
 
@@ -102,9 +102,11 @@
 		 */
 		PTHREAD_REQUIRE(pthread_join(thread[i], &val));
 
-		ATF_REQUIRE(val == NULL);
 		ATF_REQUIRE_EQ(error, false);
 
+		ATF_REQUIRE(val != NULL);
+		ATF_REQUIRE(val == (void *)(i + 1));
+
 		/*
 		 * Once the thread has returned, ESRCH should
 		 * again follow if we try to join it again.
@@ -129,15 +131,15 @@
 static void *
 threadfunc2(void *arg)
 {
-	static int i = 0;
-	int j;
+	static uintptr_t i = 0;
+	uintptr_t j;
 
-	j = (int)arg;
+	j = (uintptr_t)arg;
 
 	if (i++ == j)
 		error = false;
 
-	pthread_exit(NULL);
+	pthread_exit((void *)i);
 
 	return NULL;
 }

Reply via email to