diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-03-21 18:50:57 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-03-21 18:50:57 +0000 |
commit | df4cada7cf22a1dce173351b29c8b183e6846acb (patch) | |
tree | 1a824668199538068a505d3de86c73dd4cbeca73 /linuxthreads | |
parent | 1fb7dc3c42eb70cd7015a75b020c32cfb53c0206 (diff) | |
download | glibc-df4cada7cf22a1dce173351b29c8b183e6846acb.zip glibc-df4cada7cf22a1dce173351b29c8b183e6846acb.tar.gz glibc-df4cada7cf22a1dce173351b29c8b183e6846acb.tar.bz2 |
Update.
2001-03-20 Jakub Jelinek <jakub@redhat.com>
* sysdeps/sparc/stackinfo.h: New file.
Diffstat (limited to 'linuxthreads')
-rw-r--r-- | linuxthreads/Examples/ex17.c | 95 | ||||
-rw-r--r-- | linuxthreads/Makefile | 3 |
2 files changed, 97 insertions, 1 deletions
diff --git a/linuxthreads/Examples/ex17.c b/linuxthreads/Examples/ex17.c new file mode 100644 index 0000000..bedf868 --- /dev/null +++ b/linuxthreads/Examples/ex17.c @@ -0,0 +1,95 @@ +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <pthread.h> +#include <unistd.h> +#include <limits.h> +#include <sys/mman.h> + +static void * +test_thread (void *v_param) +{ + return NULL; +} + +#define STACKSIZE 0x100000 + +int +main (void) +{ + pthread_t thread; + pthread_attr_t attr; + int status; + void *stack, *stack2; + size_t stacksize; + + pthread_attr_init (&attr); + stack = mmap (NULL, STACKSIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + + if (stack == (void *)-1) + { + perror ("mmap failed"); + return 1; + } + + status = pthread_attr_setstack (&attr, stack, STACKSIZE); + if (status != 0) + { + printf ("pthread_attr_setstack failed: %s\n", strerror (status)); + return 1; + } + + status = pthread_attr_getstack (&attr, &stack2, &stacksize); + if (status != 0) + { + printf ("pthread_attr_getstack failed: %s\n", strerror (status)); + return 1; + } + + if (stack2 != stack || stacksize != STACKSIZE) + { + printf ("first pthread_attr_getstack returned different stack (%p,%x)\n" + "than was set by setstack (%p,%x)\n", + stack2, stacksize, stack, STACKSIZE); + return 2; + } + + status = pthread_create (&thread, &attr, test_thread, NULL); + if (status != 0) + { + printf ("pthread_create failed: %s\n", strerror (status)); + return 1; + } + + status = pthread_getattr_np (thread, &attr); + if (status != 0) + { + printf ("pthread_getattr_np failed: %s\n", strerror (status)); + return 1; + } + + status = pthread_attr_getstack (&attr, &stack2, &stacksize); + if (status != 0) + { + printf ("pthread_attr_getstack failed: %s\n", strerror (status)); + return 1; + } + + if (stack2 != stack || stacksize != STACKSIZE) + { + printf ("second pthread_attr_getstack returned different stack (%p,%x)\n" + "than was set by setstack (%p,%x)\n", + stack2, stacksize, stack, STACKSIZE); + return 3; + } + + /* pthread_detach (thread); */ + if (pthread_join (thread, NULL) != 0) + { + printf ("join failed\n"); + return 1; + } + return 0; +} diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile index 99bdb73..8ecbd22 100644 --- a/linuxthreads/Makefile +++ b/linuxthreads/Makefile @@ -55,7 +55,8 @@ endif librt-tests = ex10 ex11 tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \ - tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 + tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \ + ex17 ifeq (yes,$(build-shared)) tests-nodelete-yes = unload |