1 /* Copyright (C) 2002 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
38 if (pthread_getattr_np (pthread_self (), &attr
) != 0)
40 puts ("getattr_np failed");
46 if (pthread_attr_getstack (&attr
, &test_stack
, &test_size
) != 0)
48 puts ("attr_getstack failed");
52 if (test_size
!= size
)
54 printf ("child: reported size differs: is %zu, expected %zu\n",
59 if (test_stack
!= stack
)
61 printf ("child: reported stack address differs: is %p, expected %p\n",
68 return result
? (void *) 1l : NULL
;
77 size
= 4 * getpagesize ();
78 if (posix_memalign (&stack
, getpagesize (), size
) != 0)
80 puts ("out of memory while allocating the stack memory");
85 if (pthread_attr_init (&attr
) != 0)
87 puts ("attr_init failed");
91 puts ("attr_setstack");
92 if (pthread_attr_setstack (&attr
, stack
, size
) != 0)
94 puts ("attr_setstack failed");
100 puts ("attr_getstack");
101 if (pthread_attr_getstack (&attr
, &test_stack
, &test_size
) != 0)
103 puts ("attr_getstack failed");
107 if (test_size
!= size
)
109 printf ("reported size differs: is %zu, expected %zu\n",
114 if (test_stack
!= stack
)
116 printf ("reported stack address differs: is %p, expected %p\n",
124 if (pthread_create (&th
, &attr
, tf
, NULL
) != 0)
126 puts ("failed to create thread");
131 if (pthread_join (th
, &status
) != 0)
133 puts ("join failed");
137 result
|= status
!= NULL
;
143 #define TEST_FUNCTION do_test ()
144 #include "../test-skeleton.c"