Skip to content
Browse files

Apply build fix for windows (thanks Vitaliy Akimov!)

  • Loading branch information...
1 parent fefa2bb commit 75287a8bef3354b6812897c9cc366251a4040848 @gregorycollins committed Dec 3, 2011
Showing with 23 additions and 13 deletions.
  1. +21 −11 cbits/cfuncs.c
  2. +2 −2 hashtables.cabal
View
32 cbits/cfuncs.c
@@ -1,13 +1,16 @@
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
+#ifdef WIN32
+#include <windows.h>
+#else
#include <unistd.h>
+#endif
#if defined(USE_SSE_4_1)
#include <smmintrin.h>
#endif
-
#if defined(__GNUC__)
#define PREFETCH_READ(x) (__builtin_prefetch(x, 0, 3))
#define PREFETCH_WRITE(x) (__builtin_prefetch(x, 1, 3))
@@ -233,7 +236,7 @@ uint32_t lineMask32_3(uint32_t* array, int start,
case 14: m |= (mask(*p, x1) | mask(*p, x2) | mask(*p, x3)) & 0x4000; ++p;
case 15: m |= (mask(*p, x1) | mask(*p, x2) | mask(*p, x3)) & 0x8000; ++p;
}
-
+
return m >> offset;
}
@@ -289,15 +292,15 @@ inline uint64_t cmp_and_mask_3(__m128i val, __m128i x0, __m128i x1,
uint64_t lineMask64(uint64_t* array, int start0, uint64_t v1) {
int offset = start0 & 0x7;
int start = start0 & ~0x7;
-
+
__m128i* p = (__m128i*) (&array[start]);
__m128i x1 = _mm_cvtsi32_si128(0);
x1 = _mm_insert_epi64(x1, v1, 0);
x1 = _mm_insert_epi64(x1, v1, 1);
uint64_t dest_mask = 0;
// x1 contains two 64-bit copies of the value to look for
-
+
// words 0, 1
__m128i x = _mm_load_si128(p);
dest_mask = cmp_and_mask(x, x1);
@@ -312,7 +315,7 @@ uint64_t lineMask64(uint64_t* array, int start0, uint64_t v1) {
x = _mm_load_si128(p);
dest_mask |= (cmp_and_mask(x, x1) << 4);
p = (__m128i*) (&array[start+6]);
-
+
// words 6, 7
x = _mm_load_si128(p);
dest_mask |= (cmp_and_mask(x, x1) << 6);
@@ -324,7 +327,7 @@ uint64_t lineMask64(uint64_t* array, int start0, uint64_t v1) {
uint64_t lineMask64_2(uint64_t* array, int start0, uint64_t v1, uint64_t v2) {
int offset = start0 & 0x7;
int start = start0 & ~0x7;
-
+
__m128i* p = (__m128i*) (&array[start]);
__m128i x1 = _mm_cvtsi32_si128(0);
x1 = _mm_insert_epi64(x1, v1, 0);
@@ -350,7 +353,7 @@ uint64_t lineMask64_2(uint64_t* array, int start0, uint64_t v1, uint64_t v2) {
x = _mm_load_si128(p);
dest_mask |= (cmp_and_mask_2(x, x1, x2) << 4);
p = (__m128i*) (&array[start+6]);
-
+
// words 6, 7
x = _mm_load_si128(p);
dest_mask |= (cmp_and_mask_2(x, x1, x2) << 6);
@@ -363,7 +366,7 @@ uint64_t lineMask64_3(uint64_t* array, int start0,
uint64_t v1, uint64_t v2, uint64_t v3) {
int offset = start0 & 0x7;
int start = start0 & ~0x7;
-
+
__m128i* p = (__m128i*) (&array[start]);
__m128i x1 = _mm_cvtsi32_si128(0);
x1 = _mm_insert_epi64(x1, v1, 0);
@@ -393,7 +396,7 @@ uint64_t lineMask64_3(uint64_t* array, int start0,
x = _mm_load_si128(p);
dest_mask |= (cmp_and_mask_3(x, x1, x2, x3) << 4);
p = (__m128i*) (&array[start+6]);
-
+
// words 6, 7
x = _mm_load_si128(p);
dest_mask |= (cmp_and_mask_3(x, x1, x2, x3) << 6);
@@ -462,7 +465,7 @@ uint64_t lineMask64_3(uint64_t* array, int start,
case 6: m |= (mask(*p, x1) | mask(*p, x2) | mask(*p, x3)) & 0x40; ++p;
case 7: m |= (mask(*p, x1) | mask(*p, x2) | mask(*p, x3)) & 0x80; ++p;
}
-
+
return m >> offset;
}
@@ -498,10 +501,17 @@ int lineSearch64_3(uint64_t* array, int start,
void suicide(volatile int* check, int t) {
int secs = (3*t + 999999) / 1000000;
if (secs < 1) secs = 1;
-
+#ifdef WIN32
+ Sleep(secs * 1000);
+#else
sleep(secs);
+#endif
if (*check) {
printf("timeout expired, dying!!\n");
+#ifdef WIN32
+ abort();
+#else
raise(SIGKILL);
+#endif
}
}
View
4 hashtables.cabal
@@ -1,5 +1,5 @@
Name: hashtables
-Version: 1.0.1.0
+Version: 1.0.1.1
Synopsis: Mutable hash tables in the ST monad
Homepage: http://github.com/gregorycollins/hashtables
License: BSD3
@@ -46,7 +46,7 @@ Description:
and lookup performance for higher space efficiency and much shorter
delays when expanding the table. In most cases, benchmarks show this
table to be currently slightly faster than @Data.HashTable@ from the
- Haskell base library.
+ Haskell base library.
.
It is recommended to create a concrete type alias in your code when using this
package, i.e.:

0 comments on commit 75287a8

Please sign in to comment.
Something went wrong with that request. Please try again.