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_barrier_destroy() 8 * 9 * 10 * The pthread_barrier_destroy() function shall destroy the barrier 11 * referenced by barrier and release any resources used by the barrier. 12 * 13 * Steps: 14 * 1. Main initialize barrier with count 2 15 * 2. Main destroy the barrier 16 * 3. Repeat step 1,2 for N times 17 */ 18 #define _XOPEN_SOURCE 600 19 #include <pthread.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <unistd.h> 23 #include <signal.h> 24 #include <string.h> 25 #include "posixtest.h" 26 27 static pthread_barrier_t barrier; 28 #define LOOP_NUM 5 29 30 int main(void) 31 { 32 int cnt; 33 int rc; 34 35 for (cnt = 0; cnt < LOOP_NUM; cnt++) { 36 if (pthread_barrier_init(&barrier, NULL, 2) != 0) { 37 printf 38 ("Test FAILED: Error at pthread_barrier_init()\n"); 39 return PTS_FAIL; 40 } 41 42 rc = pthread_barrier_destroy(&barrier); 43 if (rc != 0) { 44 printf 45 ("Test FAILED: Error at pthread_barrier_destroy() " 46 " return code: %d, %s\n", rc, strerror(rc)); 47 return PTS_FAIL; 48 } 49 } 50 51 printf("Test PASSED\n"); 52 return PTS_PASS; 53 } 54