summaryrefslogtreecommitdiff
path: root/inputmethod/tegaki-wagomu/patches/patch-aa
blob: e2fde27e99044a4eccd138fbe0dceb20c987b7ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$NetBSD: patch-aa,v 1.2 2014/05/01 10:28:30 obache Exp $

* use memalign(3) if possible.
  https://github.com/tegaki/tegaki/pull/8

--- wagomu.cpp.orig	2010-02-27 04:51:50.000000000 +0000
+++ wagomu.cpp
@@ -78,7 +78,11 @@ Character::Character(unsigned int n_vec,
         ptr += diff;
         ((char*)ptr)[-1]= diff;
         */
+#ifdef HAVE_POSIX_MEMALIGN
+        posix_memalign((void**)&points, 16, n_vec * VEC_DIM_MAX *
+#else
         points = (float *) memalign(16, n_vec * VEC_DIM_MAX *
+#endif
                                         sizeof(float));
 }
 
@@ -198,16 +202,32 @@ bool Recognizer::open(char *path) {
     max_n_vectors = get_max_n_vectors();
 
 #ifdef __SSE__
+#ifdef HAVE_POSIX_MEMALIGN
+    posix_memalign((void**)&dtw1v, 16, max_n_vectors * VEC_DIM_MAX *
+#else
     dtw1v = (wg_v4sf *) memalign(16, max_n_vectors * VEC_DIM_MAX *
+#endif
                                      sizeof(wg_v4sf));
+#ifdef HAVE_POSIX_MEMALIGN
+    posix_memalign((void**)&dtw2v, 16, max_n_vectors * VEC_DIM_MAX *
+#else
     dtw2v = (wg_v4sf *) memalign(16, max_n_vectors * VEC_DIM_MAX *
+#endif
                                      sizeof(wg_v4sf));
     dtw1 = (float *) dtw1v;
     dtw2 = (float *) dtw2v;
 #else
+#ifdef HAVE_POSIX_MEMALIGN
+    posix_memalign((void**)&dtw1, 16, max_n_vectors * VEC_DIM_MAX *
+#else
     dtw1 = (float *) memalign(16, max_n_vectors * VEC_DIM_MAX *
+#endif
                                   sizeof(float));
+#ifdef HAVE_POSIX_MEMALIGN
+    posix_memalign((void**)&dtw2, 16, max_n_vectors * VEC_DIM_MAX *
+#else
     dtw2 = (float *) memalign(16, max_n_vectors * VEC_DIM_MAX *
+#endif
                                   sizeof(float));
 #endif