diff options
author | jb <jb@FreeBSD.org> | 2008-04-26 04:01:35 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 2008-04-26 04:01:35 +0000 |
commit | 17d482cf8c4ccc069ec0b163071ae7dc7d416184 (patch) | |
tree | 991b48bb736dc250125471b73aecbbb8c3354328 /cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c | |
parent | 134952ed1b96b079762297c69603a272fc0f4a00 (diff) | |
download | FreeBSD-src-17d482cf8c4ccc069ec0b163071ae7dc7d416184.zip FreeBSD-src-17d482cf8c4ccc069ec0b163071ae7dc7d416184.tar.gz |
A lot of changes to make this code compile cleanly on FreeBSD.
Diffstat (limited to 'cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c')
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c index d91fbf4..bc278b0 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c @@ -38,7 +38,9 @@ */ #include <pthread.h> +#if defined(sun) #include <synch.h> +#endif #include <stdio.h> #include "barrier.h" @@ -47,7 +49,11 @@ void barrier_init(barrier_t *bar, int nthreads) { pthread_mutex_init(&bar->bar_lock, NULL); +#if defined(sun) sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL); +#else + sem_init(&bar->bar_sem, 0, 0); +#endif bar->bar_numin = 0; bar->bar_nthr = nthreads; @@ -60,7 +66,11 @@ barrier_wait(barrier_t *bar) if (++bar->bar_numin < bar->bar_nthr) { pthread_mutex_unlock(&bar->bar_lock); +#if defined(sun) sema_wait(&bar->bar_sem); +#else + sem_wait(&bar->bar_sem); +#endif return (0); @@ -70,7 +80,11 @@ barrier_wait(barrier_t *bar) /* reset for next use */ bar->bar_numin = 0; for (i = 1; i < bar->bar_nthr; i++) +#if defined(sun) sema_post(&bar->bar_sem); +#else + sem_post(&bar->bar_sem); +#endif pthread_mutex_unlock(&bar->bar_lock); return (1); |