PERFORCE change 95369 for review
John Birrell
jb at FreeBSD.org
Sat Apr 15 23:37:02 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95369
Change 95369 by jb at jb_freebsd2 on 2006/04/15 23:36:32
FreeBSD's semaphores are a bit different.
Affected files ...
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/barrier.c#2 edit
.. //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/barrier.h#2 edit
Differences ...
==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/barrier.c#2 (text) ====
@@ -38,7 +38,9 @@
*/
#include <pthread.h>
+#if defined(sun)
#include <synch.h>
+#endif
#include <stdio.h>
#include "barrier.h"
@@ -47,7 +49,11 @@
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 @@
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 @@
/* 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);
==== //depot/projects/dtrace/src/contrib/opensolaris/tools/ctf/cvt/barrier.h#2 (text) ====
@@ -33,7 +33,12 @@
* APIs for the barrier synchronization primitive.
*/
+#if defined(sun)
#include <synch.h>
+#else
+#include <semaphore.h>
+typedef sem_t sema_t;
+#endif
#ifdef __cplusplus
extern "C" {
More information about the p4-projects
mailing list