12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "test.h"
- pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
- static void *
- func(void * arg)
- {
- struct timespec interval =
- {
- 5, 500000000L
- };
- assert(pthread_mutex_lock(&mx) == 0);
- pthread_cleanup_push(pthread_mutex_unlock, &mx);
- assert(pthread_delay_np(&interval) == 0);
- pthread_cleanup_pop(1);
- return (void *) 1;
- }
- int pthread_test_delay2()
- {
- pthread_t t;
- int result = 0;
- mx = PTHREAD_MUTEX_INITIALIZER;
- assert(pthread_mutex_lock(&mx) == 0);
- assert(pthread_create(&t, NULL, func, NULL) == 0);
- assert(pthread_cancel(t) == 0);
- assert(pthread_mutex_unlock(&mx) == 0);
- assert(pthread_join(t, (void **) &result) == 0);
- assert(result == (int) PTHREAD_CANCELED);
- assert(pthread_mutex_destroy(&mx) == 0);
- return 0;
- }
|