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_setpshared() 9 * 10 * Upon success, it returns 0. 11 * 12 * Steps: 13 * 14 * 1. Initialized a mutexattr object. 15 * 2. Set the attributes object to PTHREAD_PROCESS_PRIVATE. The error return code should be 0. 16 * 17 */ 18 19#include <pthread.h> 20#include <stdio.h> 21#include "posixtest.h" 22 23int main() 24{ 25 26 /* Make sure there is process-shared capability. */ 27 #ifndef PTHREAD_PROCESS_SHARED 28 fprintf(stderr,"process-shared attribute is not available for testing\n"); 29 return PTS_UNRESOLVED; 30 #endif 31 32 pthread_mutexattr_t mta; 33 int ret; 34 35 /* Initialize a mutex attributes object */ 36 if(pthread_mutexattr_init(&mta) != 0) 37 { 38 perror("Error at pthread_mutexattr_init()\n"); 39 return PTS_UNRESOLVED; 40 } 41 42 /* Set the attribute to PTHREAD_PROCESS_PRIVATE. */ 43 ret=pthread_mutexattr_setpshared(&mta, PTHREAD_PROCESS_PRIVATE); 44 if(ret != 0) 45 { 46 printf("Test FAILED: Expected return code 0, got: %d", ret); 47 return PTS_FAIL; 48 } 49 50 printf("Test PASSED\n"); 51 return PTS_PASS; 52} 53