1 /* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * Created by: bing.wei.liu REMOVE-THIS AT intel DOT com 4 * This file is licensed under the GPL license. For the full content 5 * of this license, see the COPYING file at the top level of this 6 * source tree. 7 8 * Test pthread_mutex_destroy() that 9 * a destroyed mutex object can be reinitialized using pthread_mutex_init() 10 * 11 */ 12 13 #include <pthread.h> 14 #include <stdio.h> 15 #include "posixtest.h" 16 17 int main(void) 18 { 19 pthread_mutex_t mutex; 20 21 /* Initialize a mutex attributes object */ 22 if (pthread_mutex_init(&mutex, NULL) != 0) { 23 fprintf(stderr, "Cannot initialize mutex object\n"); 24 return PTS_UNRESOLVED; 25 } 26 27 /* Destroy the mutex attributes object */ 28 if (pthread_mutex_destroy(&mutex) != 0) { 29 fprintf(stderr, "Cannot destroy the mutex object\n"); 30 return PTS_UNRESOLVED; 31 } 32 33 /* Initialize the mutex attributes object again. This shouldn't result in an error. */ 34 if (pthread_mutex_init(&mutex, NULL) != 0) { 35 printf("Test FAILED\n"); 36 return PTS_FAIL; 37 } else { 38 printf("Test PASSED\n"); 39 return PTS_PASS; 40 } 41 } 42