Home | History | Annotate | Download | only in pthread_rwlockattr_destroy
      1 /*
      2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
      3  * This file is licensed under the GPL license.  For the full content
      4  * of this license, see the COPYING file at the top level of this
      5  * source tree.
      6 
      7  * Test pthread_rwlockattr_destroy()
      8  *   A destroyed 'attr' attributes object can be reinitialized using
      9  *   pthread_rwlockattr_init()
     10  *
     11  * Steps:
     12  * 1.  Initialize a pthread_rwlockattr_t object using pthread_rwlockattr_init()
     13  * 2.  Destroy that initialized attribute using pthread_rwlockattr_destroy()
     14  * 3.  Initialize the pthread_rwlockattr_t object again. This should not result
     15  *     in any error.
     16  *
     17  */
     18 
     19 #define _XOPEN_SOURCE 600
     20 #include <pthread.h>
     21 #include <stdio.h>
     22 #include <errno.h>
     23 #include "posixtest.h"
     24 
     25 int main(void)
     26 {
     27 	pthread_rwlockattr_t rwla;
     28 	int rc = 0;
     29 
     30 	/* Initialize a rwlock attributes object */
     31 	rc = pthread_rwlockattr_init(&rwla);
     32 	if (rc != 0) {
     33 		printf("Cannot initialize rwlock attributes object\n");
     34 		return PTS_UNRESOLVED;
     35 	}
     36 
     37 	/* Destroy the rwlock attributes object */
     38 	rc = pthread_rwlockattr_destroy(&rwla);
     39 	if (rc != 0) {
     40 		printf
     41 		    ("Cannot destroy the rwlock attributes object, error code: %d\n",
     42 		     rc);
     43 		return PTS_UNRESOLVED;
     44 	}
     45 
     46 	/* Initialize the rwlock attributes object again.  This shouldn't result in an error. */
     47 	rc = pthread_rwlockattr_init(&rwla);
     48 
     49 	if (rc != 0) {
     50 		printf("Test FAILED, with error: %d\n", rc);
     51 		return PTS_FAIL;
     52 	} else {
     53 		printf("Test PASSED\n");
     54 		return PTS_PASS;
     55 	}
     56 }
     57