Path: blob/main/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
39586 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License, Version 1.0 only5* (the "License"). You may not use this file except in compliance6* with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or http://www.opensolaris.org/os/licensing.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*22* Copyright 2002 Sun Microsystems, Inc. All rights reserved.23* Use is subject to license terms.24*/2526#ifndef _BARRIER_H27#define _BARRIER_H2829#pragma ident "%Z%%M% %I% %E% SMI"3031/*32* APIs for the barrier synchronization primitive.33*/3435#ifdef illumos36#include <synch.h>37#else38#include <semaphore.h>39typedef sem_t sema_t;40#endif4142#ifdef __cplusplus43extern "C" {44#endif4546typedef struct barrier {47pthread_mutex_t bar_lock; /* protects bar_numin */48int bar_numin; /* current number of waiters */4950sema_t bar_sem; /* where everyone waits */51int bar_nthr; /* # of waiters to trigger release */52} barrier_t;5354extern void barrier_init(barrier_t *, int);55extern int barrier_wait(barrier_t *);5657#ifdef __cplusplus58}59#endif6061#endif /* _BARRIER_H */626364