1 /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #include <sys/param.h>
40 if (pthread_getattr_np (pthread_self (), &attr) != 0)
42 puts ("getattr_np failed");
48 if (pthread_attr_getstack (&attr, &test_stack, &test_size) != 0)
50 puts ("attr_getstack failed");
54 if (test_size != size)
56 printf ("child: reported size differs: is %zu, expected %zu\n",
61 if (test_stack != stack)
63 printf ("child: reported stack address differs: is %p, expected %p\n",
70 return result ? (void *) 1l : NULL;
79 size = MAX (4 * getpagesize (), PTHREAD_STACK_MIN);
80 if (posix_memalign (&stack, getpagesize (), size) != 0)
82 puts ("out of memory while allocating the stack memory");
87 if (pthread_attr_init (&attr) != 0)
89 puts ("attr_init failed");
93 puts ("attr_setstack");
94 if (pthread_attr_setstack (&attr, stack, size) != 0)
96 puts ("attr_setstack failed");
102 puts ("attr_getstack");
103 if (pthread_attr_getstack (&attr, &test_stack, &test_size) != 0)
105 puts ("attr_getstack failed");
109 if (test_size != size)
111 printf ("reported size differs: is %zu, expected %zu\n",
116 if (test_stack != stack)
118 printf ("reported stack address differs: is %p, expected %p\n",
126 if (pthread_create (&th, &attr, tf, NULL) != 0)
128 puts ("failed to create thread");
133 if (pthread_join (th, &status) != 0)
135 puts ("join failed");
139 result |= status != NULL;
145 #define TEST_FUNCTION do_test ()
146 #include "../test-skeleton.c"