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_init() 8 * 9 * The pthread_barrierattr_init() function shall initialize a barrier attributes 10 * object attr with the default value for all of the attributes defined 11 * by the implementation. 12 * 13 */ 14 15 #define _XOPEN_SOURCE 600 16 #include <pthread.h> 17 #include <stdio.h> 18 #include <stdlib.h> 19 #include <unistd.h> 20 #include <signal.h> 21 #include <errno.h> 22 #include <string.h> 23 #include "posixtest.h" 24 25 int main(void) 26 { 27 int rc; 28 pthread_barrierattr_t ba; 29 int pshared; 30 31 /* Initialize the barrier attribute object */ 32 rc = pthread_barrierattr_init(&ba); 33 if (rc != 0) { 34 printf 35 ("Test FAILED: Error while initialize attribute object\n"); 36 return PTS_FAIL; 37 } 38 39 /* Get the pshared value of the initialized barrierattr object */ 40 if (pthread_barrierattr_getpshared(&ba, &pshared) != 0) { 41 printf("Error at pthread_barrierattr_getpshared()\n"); 42 return PTS_UNRESOLVED; 43 } 44 45 /* The default should be PTHREAD_PROCESS_PRIVATE */ 46 if (pshared != PTHREAD_PROCESS_PRIVATE) { 47 printf 48 ("Test FAILED: The process shared attribute was not set to " 49 "default value\n"); 50 return PTS_FAIL; 51 } 52 53 /* Cleanup */ 54 rc = pthread_barrierattr_destroy(&ba); 55 if (rc != 0) { 56 printf("Error at pthread_barrierattr_destroy() " 57 "return code: %d, %s", rc, strerror(rc)); 58 return PTS_UNRESOLVED; 59 } 60 61 printf("Test PASSED\n"); 62 return PTS_PASS; 63 } 64