10 test_thread (void *v_param
)
15 #define STACKSIZE 0x100000
26 pthread_attr_init (&attr
);
27 stack
= mmap (NULL
, STACKSIZE
,
28 PROT_READ
| PROT_WRITE
| PROT_EXEC
,
29 MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0);
31 if (stack
== (void *)-1)
33 perror ("mmap failed");
37 status
= pthread_attr_setstack (&attr
, stack
, STACKSIZE
);
40 printf ("pthread_attr_setstack failed: %s\n", strerror (status
));
44 status
= pthread_attr_getstack (&attr
, &stack2
, &stacksize
);
47 printf ("pthread_attr_getstack failed: %s\n", strerror (status
));
51 if (stack2
!= stack
|| stacksize
!= STACKSIZE
)
53 printf ("first pthread_attr_getstack returned different stack (%p,%x)\n"
54 "than was set by setstack (%p,%x)\n",
55 stack2
, stacksize
, stack
, STACKSIZE
);
59 status
= pthread_create (&thread
, &attr
, test_thread
, NULL
);
62 printf ("pthread_create failed: %s\n", strerror (status
));
66 status
= pthread_getattr_np (thread
, &attr
);
69 printf ("pthread_getattr_np failed: %s\n", strerror (status
));
73 status
= pthread_attr_getstack (&attr
, &stack2
, &stacksize
);
76 printf ("pthread_attr_getstack failed: %s\n", strerror (status
));
80 if (stack2
!= stack
|| stacksize
!= STACKSIZE
)
82 printf ("second pthread_attr_getstack returned different stack (%p,%x)\n"
83 "than was set by setstack (%p,%x)\n",
84 stack2
, stacksize
, stack
, STACKSIZE
);
88 /* pthread_detach (thread); */
89 if (pthread_join (thread
, NULL
) != 0)
91 printf ("join failed\n");