| 31 | event_t main_event; |
| 32 | |
| 33 | static void *test_thread(void *ms_param) { |
| 34 | int status = 0; |
| 35 | event_t foo; |
| 36 | struct timespec time; |
| 37 | struct timeval now; |
| 38 | long ms = (long) ms_param; |
| 39 | |
| 40 | /* initialize cond var */ |
| 41 | pthread_cond_init(&foo.cond, NULL); |
| 42 | pthread_mutex_init(&foo.mutex, NULL); |
| 43 | foo.flag = 0; |
| 44 | |
| 45 | /* set the time out value */ |
| 46 | printf("waiting %ld ms ...\n", ms); |
| 47 | gettimeofday(&now, NULL); |
| 48 | time.tv_sec = now.tv_sec + ms / 1000 + (now.tv_usec + (ms % 1000) * 1000) |
| 49 | / 1000000; |
| 50 | time.tv_nsec = ((now.tv_usec + (ms % 1000) * 1000) % 1000000) * 1000; |
| 51 | |
| 52 | /* Just use this to test the time out. The cond var is never signaled. */ |
| 53 | pthread_mutex_lock(&foo.mutex); |
| 54 | while (foo.flag == 0 && status != ETIMEDOUT) { |
| 55 | status = pthread_cond_timedwait(&foo.cond, &foo.mutex, &time); |
| 56 | } |
| 57 | pthread_mutex_unlock(&foo.mutex); |
| 58 | |
| 59 | /* post the main event */ |
| 60 | pthread_mutex_lock(&main_event.mutex); |
| 61 | main_event.flag = 1; |
| 62 | pthread_cond_signal(&main_event.cond); |
| 63 | pthread_mutex_unlock(&main_event.mutex); |
| 64 | |
| 65 | /* that's it, bye */ |
| 66 | return (void*) status; |
| 67 | } |
| 68 | |
| 69 | int libc_ex7(void) { |
| 70 | unsigned long count; |
nothing calls this directly
no test coverage detected