1e04b953eSDavid Xu /* Test stack unwinding for pthread_cond_wait function */ 2e04b953eSDavid Xu 3e04b953eSDavid Xu #include <pthread.h> 4e04b953eSDavid Xu #include <stdio.h> 5e04b953eSDavid Xu #include <semaphore.h> 6e04b953eSDavid Xu #include <unistd.h> 7e04b953eSDavid Xu 8e04b953eSDavid Xu #include "Test.cpp" 9e04b953eSDavid Xu 10*ef135466SEd Maste static pthread_mutex_t mtx; 11*ef135466SEd Maste static pthread_cond_t cv; 12e04b953eSDavid Xu 13*ef135466SEd Maste static void * thr(void * arg __unused)14*ef135466SEd Mastethr(void *arg __unused) 15e04b953eSDavid Xu { 16e04b953eSDavid Xu Test t; 17e04b953eSDavid Xu 18e04b953eSDavid Xu pthread_mutex_lock(&mtx); 19e04b953eSDavid Xu pthread_cond_wait(&cv, &mtx); 20e04b953eSDavid Xu pthread_mutex_unlock(&mtx); 21e04b953eSDavid Xu printf("Bug, thread shouldn't be here.\n"); 22e04b953eSDavid Xu return (0); 23e04b953eSDavid Xu } 24e04b953eSDavid Xu 25e04b953eSDavid Xu int main()26e04b953eSDavid Xumain() 27e04b953eSDavid Xu { 28e04b953eSDavid Xu pthread_t td; 29e04b953eSDavid Xu 30e04b953eSDavid Xu pthread_mutex_init(&mtx, NULL); 31e04b953eSDavid Xu pthread_cond_init(&cv, NULL); 32e04b953eSDavid Xu pthread_create(&td, NULL, thr, NULL); 33e04b953eSDavid Xu sleep(1); 34e04b953eSDavid Xu pthread_cancel(td); 35e04b953eSDavid Xu pthread_join(td, NULL); 36e04b953eSDavid Xu check_destruct(); 37e04b953eSDavid Xu return (0); 38e04b953eSDavid Xu } 39