|
|
|
@@ -1,12 +1,40 @@ |
|
|
|
--- fftw3-static-3.3.5~git20160520.orig/api/apiplan.c |
|
|
|
+++ fftw3-static-3.3.5~git20160520/api/apiplan.c |
|
|
|
@@ -19,8 +19,21 @@ |
|
|
|
*/ |
|
|
|
diff --git a/api/apiplan.c b/api/apiplan.c |
|
|
|
index b8642a9..d63f2e4 100644 |
|
|
|
--- a/api/apiplan.c |
|
|
|
+++ b/api/apiplan.c |
|
|
|
@@ -20,7 +20,48 @@ |
|
|
|
|
|
|
|
#include "api/api.h" |
|
|
|
+#include <pthread.h> |
|
|
|
|
|
|
|
-static planner_hook_t before_planner_hook = 0, after_planner_hook = 0; |
|
|
|
+#if defined(__WIN32__) || defined(_WIN32) || defined(_WINDOWS) |
|
|
|
+/* hack: windef.h defines INT for its own purposes and this causes |
|
|
|
+ a conflict with our own INT in ifftw.h. Divert the windows |
|
|
|
+ definition into another name unlikely to cause a conflict */ |
|
|
|
+#define INT magnus_ab_INTegro_seclorum_nascitur_ordo |
|
|
|
+#include <windows.h> |
|
|
|
+#undef INT |
|
|
|
+ |
|
|
|
+/* windows does not have statically-initialized mutexes---fake a |
|
|
|
+ spinlock */ |
|
|
|
+static volatile LONG planner_mutex = 0; |
|
|
|
+ |
|
|
|
+static void lock_planner_mutex(void) |
|
|
|
+{ |
|
|
|
+ while (InterlockedExchange(&planner_mutex, 1) == 1) { |
|
|
|
+ YieldProcessor(); |
|
|
|
+ Sleep(0); |
|
|
|
+ } |
|
|
|
+} |
|
|
|
+ |
|
|
|
+static void unlock_planner_mutex(void) |
|
|
|
+{ |
|
|
|
+ LONG old = InterlockedExchange(&planner_mutex, 0); |
|
|
|
+ A(old == 1); |
|
|
|
+} |
|
|
|
+#else |
|
|
|
+#include <pthread.h> |
|
|
|
+ |
|
|
|
+static pthread_mutex_t planner_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
|
|
+ |
|
|
|
+static void lock_planner_mutex(void) |
|
|
|
@@ -18,6 +46,7 @@ |
|
|
|
+{ |
|
|
|
+ pthread_mutex_unlock(&planner_mutex); |
|
|
|
+} |
|
|
|
+#endif |
|
|
|
+ |
|
|
|
+static planner_hook_t before_planner_hook = lock_planner_mutex, after_planner_hook = unlock_planner_mutex; |
|
|
|
|
|
|
|
|