diff options
Diffstat (limited to 'tools/regression/tls/ttls2')
-rw-r--r-- | tools/regression/tls/ttls2/Makefile | 14 | ||||
-rw-r--r-- | tools/regression/tls/ttls2/ttls2.c | 36 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tools/regression/tls/ttls2/Makefile b/tools/regression/tls/ttls2/Makefile new file mode 100644 index 0000000..584bf42 --- /dev/null +++ b/tools/regression/tls/ttls2/Makefile @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PROG= ttls2 +LDADD+= -lpthread +LDADD+= -Wl,--rpath=${.CURDIR}/../../../../lib/libpthread +#LDADD+= -lthr +#LDADD+= -Wl,--rpath=${.CURDIR}/../../../../lib/libthr +LDADD+= -L${.CURDIR}/../../../../lib/libc -lc +LDADD+= -Wl,--rpath=${.CURDIR}/../../../../lib/libc +LDADD+= -Wl,--dynamic-linker=${.CURDIR}/../../../../libexec/rtld-elf/ld-elf.so.1 +NOMAN= t +DEBUG_FLAGS= -g + +.include <bsd.prog.mk> 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); +} |