Revision: 54500
http://brlcad.svn.sourceforge.net/brlcad/?rev=54500&view=rev
Author: d_rossberg
Date: 2013-02-27 16:28:35 +0000 (Wed, 27 Feb 2013)
Log Message:
-----------
apply patch from Arjun Govindjee
(http://www.google-melange.com/gci/task/view/google/gci2012/7999206) implement
mutex locking for windows
Modified Paths:
--------------
brlcad/trunk/AUTHORS
brlcad/trunk/src/libbu/semaphore.c
Modified: brlcad/trunk/AUTHORS
===================================================================
--- brlcad/trunk/AUTHORS 2013-02-27 15:48:59 UTC (rev 54499)
+++ brlcad/trunk/AUTHORS 2013-02-27 16:28:35 UTC (rev 54500)
@@ -644,7 +644,11 @@
2012 December
Open Source (GCI)
+Govindjee, Arjun
+2012 December
+Open Source (GCI)
+
SPECIAL THANKS
--------------
Modified: brlcad/trunk/src/libbu/semaphore.c
===================================================================
--- brlcad/trunk/src/libbu/semaphore.c 2013-02-27 15:48:59 UTC (rev 54499)
+++ brlcad/trunk/src/libbu/semaphore.c 2013-02-27 16:28:35 UTC (rev 54500)
@@ -24,8 +24,18 @@
#include <stdio.h>
#include <ctype.h>
#include <math.h>
+
+#include "bio.h"
#include "bu.h"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+struct bu_semaphores {
+ uint32_t magic;
+ HANDLE m;
+};
+# define DEFINED_BU_SEMAPHORES 1
+#endif
+
#ifdef CRAY
# include <sys/category.h>
# include <sys/resource.h>
@@ -309,6 +319,17 @@
}
# endif
+# if defined(_WIN32) && !defined(__CYGWIN__)
+ for (i=0; i < nsemaphores; i++) {
+ bu_semaphores[i].magic = BU_SEMAPHORE_MAGIC;
+ bu_semaphores[i].m = CreateMutex(NULL, FALSE, NULL);
+ if (bu_semaphores[i].m == NULL) {
+ fprintf(stderr, "bu_semaphore_init(): CreateMutex() failed on
[%d]\n", i);
+ bu_bomb("fatal semaphore acquisition failure");
+ }
+ }
+# endif
+
/*
* This should be last thing done before returning, so that
* any subroutines called (e.g. bu_calloc()) won't think that
@@ -405,6 +426,12 @@
bu_bomb("fatal semaphore acquisition failure");
}
# endif
+# if defined(_WIN32) && !defined(__CYGWIN__)
+ if (WaitForSingleObject(bu_semaphores[i].m, INFINITE)) {
+ fprintf(stderr, "bu_semaphore_acquire(): WaitForSingleObject() failed
on [%d]\n", i);
+ bu_bomb("fatal semaphore acquisition failure");
+ }
+# endif
#endif
}
@@ -472,6 +499,13 @@
bu_bomb("fatal semaphore acquisition failure");
}
# endif
+
+# if defined(_WIN32) && !defined(__CYGWIN__)
+ if (!ReleaseMutex(bu_semaphores[i].m)) {
+ fprintf(stderr, "bu_semaphore_acquire(): ReleaseMutex() failed on
[%d]\n", i);
+ bu_bomb("fatal semaphore acquisition failure");
+ }
+# endif
#endif
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits