Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet/dist/tools/ctf/cvt reduce ifdefs



details:   https://anonhg.NetBSD.org/src/rev/c97cc46619eb
branches:  trunk
changeset: 343546:c97cc46619eb
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Feb 13 21:37:12 2016 +0000

description:
reduce ifdefs

diffstat:

 external/cddl/osnet/dist/tools/ctf/cvt/barrier.c |  19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diffs (53 lines):

diff -r b83c957bf585 -r c97cc46619eb external/cddl/osnet/dist/tools/ctf/cvt/barrier.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c  Sat Feb 13 19:53:23 2016 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/barrier.c  Sat Feb 13 21:37:12 2016 +0000
@@ -40,6 +40,11 @@
 #include <pthread.h>
 #if defined(sun)
 #include <synch.h>
+#else
+#define USYNC_THREAD 1
+#define sema_init(a, b, c, d)  sem_init((a), (c) != USYNC_THREAD, (b))
+#define sema_wait(a)           sem_wait(a)
+#define sema_post(a)           sem_post(a)
 #endif
 #include <stdio.h>
 
@@ -49,12 +54,7 @@
 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;
 }
@@ -66,12 +66,7 @@
 
        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);
 
        } else {
@@ -80,11 +75,7 @@
                /* 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);



Home | Main Index | Thread Index | Old Index