summaryrefslogtreecommitdiffstats
path: root/tools/regression/tls/ttls2/ttls2.c
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>2004-08-03 09:04:01 +0000
committerdfr <dfr@FreeBSD.org>2004-08-03 09:04:01 +0000
commitc5d9c3618efa06abd292cabeea45abf2d8f73b14 (patch)
tree799306d40d41245260af360416589ca5c07e375f /tools/regression/tls/ttls2/ttls2.c
parentaedc433cf36288de98437f3d9a41b9380f81a498 (diff)
downloadFreeBSD-src-c5d9c3618efa06abd292cabeea45abf2d8f73b14.zip
FreeBSD-src-c5d9c3618efa06abd292cabeea45abf2d8f73b14.tar.gz
Add regression tests for TLS.
Diffstat (limited to 'tools/regression/tls/ttls2/ttls2.c')
-rw-r--r--tools/regression/tls/ttls2/ttls2.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/regression/tls/ttls2/ttls2.c b/tools/regression/tls/ttls2/ttls2.c
new file mode 100644
index 0000000..f528e3d
--- /dev/null
+++ b/tools/regression/tls/ttls2/ttls2.c
@@ -0,0 +1,36 @@
+/* $FreeBSD$ */
+
+#include <stdio.h>
+#include <pthread.h>
+
+int __thread i;
+
+void *
+foo1(void *arg)
+{
+ printf("thread %p, &i = %p\n", pthread_self(), &i);
+ for (i = 0; i < 10; i++) {
+ printf("thread %p, i = %d\n", pthread_self(), i);
+ sleep(1);
+ }
+}
+
+void *
+foo2(void *arg)
+{
+ printf("thread %p, &i = %p\n", pthread_self(), &i);
+ for (i = 10; i > 0; i--) {
+ printf("thread %p, i = %d\n", pthread_self(), i);
+ sleep(1);
+ }
+}
+
+int main(int argc, char** argv)
+{
+ pthread_t t1, t2;
+
+ pthread_create(&t1, 0, foo1, 0);
+ pthread_create(&t2, 0, foo2, 0);
+ pthread_join(t1, 0);
+ pthread_join(t2, 0);
+}
OpenPOWER on IntegriCloud