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 * pthread_barrierattr_setpshared() 8 * 9 * The pthread_barrierattr_setpshared( ) function may fail if: 10 * [EINVAL] The new value specified for the process-shared attribute is not one of 11 * the legal values PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE. 12 * This case will always pass 13 */ 14 15 16#define _XOPEN_SOURCE 600 17#include <pthread.h> 18#include <stdio.h> 19#include <stdlib.h> 20#include <unistd.h> 21#include <errno.h> 22#include <string.h> 23#include "posixtest.h" 24 25int main() 26{ 27 28 /* Make sure there is process-shared capability. */ 29 #ifndef PTHREAD_PROCESS_SHARED 30 fprintf(stderr,"process-shared attribute is not available for testing\n"); 31 return PTS_UNSUPPORTED; 32 #endif 33 34 pthread_barrierattr_t ba; 35 int pshared = PTHREAD_PROCESS_PRIVATE + 1; 36 int rc; 37 38 /* Set pshared to an invalid value */ 39 if(pshared == PTHREAD_PROCESS_SHARED) 40 { 41 pshared += 1; 42 } 43 44 /* Initialize a barrier attributes object */ 45 if(pthread_barrierattr_init(&ba) != 0) 46 { 47 printf("Error at pthread_barrierattr_init()\n"); 48 return PTS_UNRESOLVED; 49 } 50 51 /* Set process-shared attribute to an invalid value */ 52 rc = pthread_barrierattr_setpshared(&ba, pshared); 53 if(rc == EINVAL) 54 printf("Test PASSED\n"); 55 else 56 { 57 printf("Get return code: %d, %s\n", rc, strerror(rc)); 58 printf("Test PASSED: Note*: Expected EINVAL, but standard says 'may' fail.\n"); 59 } 60 61 return PTS_PASS; 62 63} 64