Module Name:    src
Committed By:   joerg
Date:           Mon Mar 12 20:17:16 UTC 2012

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

Log Message:
Also exercise pthread_attr_setstacksize.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 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.7 src/tests/lib/libpthread/t_join.c:1.8
--- src/tests/lib/libpthread/t_join.c:1.7	Mon Dec 12 23:54:18 2011
+++ src/tests/lib/libpthread/t_join.c	Mon Mar 12 20:17:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_join.c,v 1.7 2011/12/12 23:54:18 joerg Exp $ */
+/* $NetBSD: t_join.c,v 1.8 2012/03/12 20:17:16 joerg 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.7 2011/12/12 23:54:18 joerg Exp $");
+__RCSID("$NetBSD: t_join.c,v 1.8 2012/03/12 20:17:16 joerg Exp $");
 
 #include <errno.h>
 #include <pthread.h>
@@ -43,6 +43,8 @@ __RCSID("$NetBSD: t_join.c,v 1.7 2011/12
 extern int check_stack_alignment(void);
 #endif
 
+#define STACKSIZE	65536
+
 static bool error;
 
 static void *threadfunc1(void *);
@@ -72,6 +74,7 @@ threadfunc1(void *arg)
 	void *val = NULL;
 	uintptr_t i;
 	int rv;
+	pthread_attr_t attr;
 
 	caller = pthread_self();
 
@@ -94,11 +97,15 @@ threadfunc1(void *arg)
 	ATF_REQUIRE(rv != 0);
 	ATF_REQUIRE_EQ(rv, EDEADLK);
 
+	ATF_REQUIRE(pthread_attr_init(&attr) == 0);
+
 	for (i = 0; i < __arraycount(thread); i++) {
 
 		error = true;
 
-		rv = pthread_create(&thread[i], NULL, threadfunc2, (void *)i);
+		ATF_REQUIRE(pthread_attr_setstacksize(&attr, STACKSIZE * (i + 1)) == 0);
+
+		rv = pthread_create(&thread[i], &attr, threadfunc2, (void *)i);
 
 		ATF_REQUIRE_EQ(rv, 0);
 
@@ -128,6 +135,8 @@ threadfunc1(void *arg)
 		ATF_REQUIRE(rv != 0);
 	}
 
+	ATF_REQUIRE(pthread_attr_destroy(&attr) == 0);
+
 	pthread_exit(NULL);
 
 	return NULL;
@@ -138,9 +147,16 @@ threadfunc2(void *arg)
 {
 	static uintptr_t i = 0;
 	uintptr_t j;
+	pthread_attr_t attr;
+	size_t stacksize;
 
 	j = (uintptr_t)arg;
 
+	ATF_REQUIRE(pthread_attr_get_np(pthread_self(), &attr) == 0);
+	ATF_REQUIRE(pthread_attr_getstacksize(&attr, &stacksize) == 0);
+	ATF_REQUIRE(stacksize == STACKSIZE * (j + 1));
+	ATF_REQUIRE(pthread_attr_destroy(&attr) == 0);
+
 	if (i++ == j)
 		error = false;
 

Reply via email to