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 that pthread_mutexattr_gettype() 9 * 10 * Gets the mutex 'type' attribute. This attribute is set in the 'type' parameter to 11 * these functions. The default value is PTHREAD_MUTEX_DEFAULT. 12 * 13 * Testing the default 'type' value. 14 * 15 * Steps: 16 * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init() 17 * 2. Call pthread_mutexattr_gettype() to check if type 18 * attribute is set as the default value PTHREAD_MUTEX_DEFAULT. 19 * 20 */ 21 22 #define _XOPEN_SOURCE 600 23 24 #include <pthread.h> 25 #include <stdio.h> 26 #include "posixtest.h" 27 28 int main(void) 29 { 30 pthread_mutexattr_t mta; 31 int type; 32 33 /* Initialize a mutex attributes object */ 34 if (pthread_mutexattr_init(&mta) != 0) { 35 perror("Error at pthread_mutexattr_init()\n"); 36 return PTS_UNRESOLVED; 37 } 38 39 /* The default 'type' attribute should be PTHREAD_MUTEX_DEFAULT */ 40 if (pthread_mutexattr_gettype(&mta, &type) != 0) { 41 fprintf(stderr, 42 "pthread_mutexattr_gettype(): Error obtaining the attribute 'type'\n"); 43 return PTS_UNRESOLVED; 44 } 45 46 if (type != PTHREAD_MUTEX_DEFAULT) { 47 printf 48 ("Test FAILED: Incorrect default mutexattr 'type' value: %d\n", 49 type); 50 return PTS_FAIL; 51 } 52 53 printf("Test PASSED\n"); 54 return PTS_PASS; 55 } 56