summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-04-23 23:47:58 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-04-23 23:47:58 +0000
commit72410b5004bf1a674fd4ad9dab6076d99d1ab9a5 (patch)
tree76441f4b179ceff7628ae8d621d07642fc175d41 /tools/regression
parent8710214da3628d020a2de7c10bca22a8b6c94013 (diff)
downloadFreeBSD-src-72410b5004bf1a674fd4ad9dab6076d99d1ab9a5.zip
FreeBSD-src-72410b5004bf1a674fd4ad9dab6076d99d1ab9a5.tar.gz
Add a program to test if tls data is clean.
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/tls/Makefile2
-rw-r--r--tools/regression/tls/ttls4/Makefile8
-rw-r--r--tools/regression/tls/ttls4/ttls4.c43
3 files changed, 52 insertions, 1 deletions
diff --git a/tools/regression/tls/Makefile b/tools/regression/tls/Makefile
index aea3025..76def96 100644
--- a/tools/regression/tls/Makefile
+++ b/tools/regression/tls/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-SUBDIR=libxx libyy ttls1 ttls2
+SUBDIR=libxx libyy ttls1 ttls2 ttls4
.if ${MACHINE_ARCH} == "i386"
SUBDIR+=ttls3
diff --git a/tools/regression/tls/ttls4/Makefile b/tools/regression/tls/ttls4/Makefile
new file mode 100644
index 0000000..5fb37df
--- /dev/null
+++ b/tools/regression/tls/ttls4/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= ttls4
+LDADD+= -lpthread
+NO_MAN=
+DEBUG_FLAGS= -g
+
+.include <bsd.prog.mk>
diff --git a/tools/regression/tls/ttls4/ttls4.c b/tools/regression/tls/ttls4/ttls4.c
new file mode 100644
index 0000000..9a1d43b
--- /dev/null
+++ b/tools/regression/tls/ttls4/ttls4.c
@@ -0,0 +1,43 @@
+/*
+ * This program tests if a new thread's initial tls data
+ * is clean.
+ *
+ * David Xu <davidxu@freebsd.org>
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <pthread.h>
+
+int __thread n;
+
+void *f1(void *arg)
+{
+ n = 1;
+ return (0);
+}
+
+void *f2(void *arg)
+{
+ if (n != 0) {
+ printf("bug, n == %d \n", n);
+ exit(1);
+ }
+ return (0);
+}
+
+int main()
+{
+ pthread_t td;
+ int i;
+
+ pthread_create(&td, NULL, f1, NULL);
+ pthread_join(td, NULL);
+ for (i = 0; i < 1000; ++i) {
+ pthread_create(&td, NULL, f2, NULL);
+ pthread_yield();
+ pthread_join(td, NULL);
+ }
+ return (0);
+}
OpenPOWER on IntegriCloud