Revision: 65552
http://sourceforge.net/p/brlcad/code/65552
Author: ejno
Date: 2015-07-10 16:41:30 +0000 (Fri, 10 Jul 2015)
Log Message:
-----------
use libbu and tinycthread time functions
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.h
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmthread.h
brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
2015-07-10 15:40:16 UTC (rev 65551)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.c
2015-07-10 16:41:30 UTC (rev 65552)
@@ -57,7 +57,11 @@
#include <string.h>
+#if defined(MM_LINUX) || defined(MM_UNIX)
+#include <unistd.h>
+#endif
+
#define ADDRESSDIFF(a,b) (((char *)a)-((char *)b))
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.h
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.h
2015-07-10 15:40:16 UTC (rev 65551)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mm.h
2015-07-10 16:41:30 UTC (rev 65552)
@@ -140,12 +140,4 @@
int mmCpuGetNode(int cpuindex);
-static inline uint64_t mmGetMillisecondsTime()
-{
- struct timeval lntime;
- gettimeofday(&lntime, 0);
- return ((uint64_t)lntime.tv_sec * 1000) + ((uint64_t)lntime.tv_usec /
1000);
-}
-
-
#endif
Modified:
brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmthread.h
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmthread.h
2015-07-10 15:40:16 UTC (rev 65551)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/auxiliary/mmthread.h
2015-07-10 16:41:30 UTC (rev 65552)
@@ -43,23 +43,16 @@
#include "tinycthread.h"
-#include <sys/time.h>
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#include <unistd.h>
-#endif
-
-
static inline void mtSignalWaitTimeout(cnd_t *signal, mtx_t *mutex, long
milliseconds)
{
uint64_t microsecs;
struct timespec ts;
- struct timeval tp;
- gettimeofday(&tp, NULL);
- ts.tv_sec = tp.tv_sec + (milliseconds / 1000);
- microsecs = tp.tv_usec + ((milliseconds % 1000) * 1000);
+ timespec_get(&ts, TIME_UTC);
+ ts.tv_sec += (milliseconds / 1000);
+ microsecs = ((ts.tv_nsec + 500) / 1000) + ((milliseconds % 1000) * 1000);
+
if (microsecs >= 1000000) {
ts.tv_sec++;
microsecs -= 1000000;
@@ -105,15 +98,21 @@
}
-#elif _POSIX_SPIN_LOCKS > 0
+#else
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#endif
-typedef struct mtSpin mtSpin;
+#if defined(_POSIX_SPIN_LOCKS) && _POSIX_SPIN_LOCKS > 0
-struct mtSpin {
+typedef struct {
pthread_spinlock_t pspinlock;
-};
+} mtSpin;
static inline void mtSpinInit(mtSpin *spin)
@@ -142,16 +141,37 @@
#else
-typedef struct mtMutex mtSpin;
+typedef mtx_t mtSpin;
-#define mtSpinInit(a) mtMutexInit(a)
-#define mtSpinDestroy(a) mtMutexDestroy(a)
-#define mtSpinLock(a) mtMutexLock(a)
-#define mtSpinUnlock(a) mtMutexUnlock(a)
+static inline void mtSpinInit(mtSpin *spin)
+{
+ if (mtx_init(spin, mtx_plain) == thrd_error)
+ bu_bomb("mtx_init() failed");
+}
+static inline void mtSpinDestroy(mtSpin *spin)
+{
+ mtx_destroy(spin);
+}
+
+static inline void mtSpinLock(mtSpin *spin)
+{
+ if (mtx_lock(spin) == thrd_error)
+ bu_bomb("mtx_lock() failed");
+}
+
+
+static inline void mtSpinUnlock(mtSpin *spin)
+{
+ if (mtx_unlock(spin) == thrd_error)
+ bu_bomb("mtx_unlock() failed");
+}
+
+
#endif
+#endif
#endif
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
2015-07-10 15:40:16 UTC (rev 65551)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshdecimation.c
2015-07-10 16:41:30 UTC (rev 65552)
@@ -47,6 +47,7 @@
#include "bu/log.h"
#include "bu/parallel.h"
+#include "bu/time.h"
#include "vmath.h"
#include <string.h>
@@ -456,7 +457,7 @@
if (mtx_init(&barrier->mutex, mtx_plain) == thrd_error)
bu_bomb("mtx_init() failed");
- if (cnd_init(&barrier->signal) == thrd_error)
+ if (cnd_init(&barrier->signal) != thrd_success)
bu_bomb("mtx_init() failed");
barrier->resetcount = count;
@@ -3952,7 +3953,7 @@
mesh.maxcollapsecost = operation->decimationstrength;
/* Record start time */
- operation->msecs = mmGetMillisecondsTime();
+ operation->msecs = bu_gettime();
mesh.threadcount = threadcount;
mesh.operationflags = flags;
@@ -4141,7 +4142,7 @@
mdBarrierDestroy(&mesh.globalbarrier);
/* Store total processing time */
- operation->msecs = mmGetMillisecondsTime() - operation->msecs;
+ operation->msecs = bu_gettime() - operation->msecs;
return 1;
}
Modified: brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
2015-07-10 15:40:16 UTC (rev 65551)
+++ brlcad/trunk/src/librt/primitives/bot/gct_decimation/meshoptimizer.c
2015-07-10 16:41:30 UTC (rev 65552)
@@ -82,7 +82,7 @@
if (mtx_init(&barrier->mutex, mtx_plain) == thrd_error)
bu_bomb("mtx_init() failed");
- if (cnd_init(&barrier->signal) == thrd_error)
+ if (cnd_init(&barrier->signal) != thrd_success)
bu_bomb("cnd_init() failed");
barrier->resetcount = count;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits