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 that pthread_rwlockattr_getpshared() 8 * 9 * It shall obtain the value of the process-shared attribute from 'attr'. 10 * 11 * Steps: 12 * 1. Initialize a pthread_rwlockattr_t object with pthread_rwlockattr_init() 13 * 2. Call pthread_rwlockattr_getpshared() to check if the process-shared 14 * attribute is set as the default value PTHREAD_PROCESS_PRIVATE. 15 * 16 */ 17#define _XOPEN_SOURCE 600 18#include <pthread.h> 19#include <stdio.h> 20#include "posixtest.h" 21 22int main(void) 23{ 24 pthread_rwlockattr_t rwla; 25 int pshared; 26 int rc = 0; 27 28#ifndef PTHREAD_PROCESS_SHARED 29 printf("process-shared attribute is not available for testing\n"); 30 return PTS_UNSUPPORTED; 31#endif 32 33 /* Initialize a rwlock attributes object */ 34 if (pthread_rwlockattr_init(&rwla) != 0) { 35 printf("Error at pthread_rwlockattr_init()\n"); 36 return PTS_UNRESOLVED; 37 } 38 39 /* The default 'pshared' attribute should be PTHREAD_PROCESS_PRIVATE */ 40 rc = pthread_rwlockattr_getpshared(&rwla, &pshared); 41 if (rc != 0) { 42 printf 43 ("Test FAILED: Error at pthread_rwlockattr_getpshared(): %d\n", 44 rc); 45 return PTS_FAIL; 46 } 47 48 if (pshared != PTHREAD_PROCESS_PRIVATE) { 49 printf("Test FAILED: Incorrect default pshared value: %d\n", 50 pshared); 51 return PTS_FAIL; 52 } 53 54 printf("Test PASSED\n"); 55 return PTS_PASS; 56} 57