Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162331071
D54018.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54018.diff
View Options
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
@@ -33,12 +33,7 @@
* APIs for the barrier synchronization primitive.
*/
-#ifdef illumos
-#include <synch.h>
-#else
-#include <semaphore.h>
-typedef sem_t sema_t;
-#endif
+#include <pthread.h>
#ifdef __cplusplus
extern "C" {
@@ -48,7 +43,7 @@
pthread_mutex_t bar_lock; /* protects bar_numin */
int bar_numin; /* current number of waiters */
- sema_t bar_sem; /* where everyone waits */
+ pthread_cond_t bar_cv; /* where everyone waits */
int bar_nthr; /* # of waiters to trigger release */
} barrier_t;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
@@ -38,9 +38,6 @@
*/
#include <pthread.h>
-#ifdef illumos
-#include <synch.h>
-#endif
#include <stdio.h>
#include "barrier.h"
@@ -49,12 +46,7 @@
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);
-#ifdef illumos
- sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
-#else
- sem_init(&bar->bar_sem, 0, 0);
-#endif
-
+ pthread_cond_init(&bar->bar_cv, NULL);
bar->bar_numin = 0;
bar->bar_nthr = nthreads;
}
@@ -65,26 +57,14 @@
pthread_mutex_lock(&bar->bar_lock);
if (++bar->bar_numin < bar->bar_nthr) {
+ pthread_cond_wait(&bar->bar_cv, &bar->bar_lock);
pthread_mutex_unlock(&bar->bar_lock);
-#ifdef illumos
- sema_wait(&bar->bar_sem);
-#else
- sem_wait(&bar->bar_sem);
-#endif
return (0);
-
} else {
- int i;
-
/* reset for next use */
bar->bar_numin = 0;
- for (i = 1; i < bar->bar_nthr; i++)
-#ifdef illumos
- sema_post(&bar->bar_sem);
-#else
- sem_post(&bar->bar_sem);
-#endif
+ pthread_cond_broadcast(&bar->bar_cv);
pthread_mutex_unlock(&bar->bar_lock);
return (1);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jul 13, 3:28 AM (10 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35022813
Default Alt Text
D54018.diff (1 KB)
Attached To
Mode
D54018: ctfmerge: fix segfault when building on macOS
Attached
Detach File
Event Timeline
Log In to Comment