[librime] Fixes arm build

Peng Wu pwu at fedoraproject.org
Mon Jul 15 05:29:58 UTC 2013


commit f5326bd8845b4b09f1450626d6fef04aa57ea194
Author: Peng Wu <alexepico at gmail.com>
Date:   Mon Jul 15 13:05:01 2013 +0800

    Fixes arm build

 librime-fixes-misaligned-address.patch |   57 ++++++++++++++++++++++++++++++++
 librime.spec                           |   11 +++++-
 2 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/librime-fixes-misaligned-address.patch b/librime-fixes-misaligned-address.patch
new file mode 100644
index 0000000..1f2d577
--- /dev/null
+++ b/librime-fixes-misaligned-address.patch
@@ -0,0 +1,57 @@
+Index: librime/include/rime/dict/mapped_file.h
+===================================================================
+--- librime.orig/include/rime/dict/mapped_file.h
++++ librime/include/rime/dict/mapped_file.h
+@@ -138,7 +138,9 @@ template <class T>
+ T* MappedFile::Allocate(size_t count) {
+   if (!IsOpen())
+     return NULL;
+-  size_t used_space = size_;
++
++  /* do the alignment computing for mapped file. */
++  size_t used_space = (size_ + __alignof__(T) - 1) & ~(__alignof__(T) - 1);
+   size_t required_space = sizeof(T) * count;
+   size_t file_size = capacity();
+   if (used_space + required_space > file_size) {
+@@ -146,13 +148,11 @@ T* MappedFile::Allocate(size_t count) {
+     size_t new_size = (std::max)(used_space + required_space, file_size * 2);
+     if(!Resize(new_size) || !OpenReadWrite())
+       return NULL;
+-    // note that size_ has been reset after the file was closed for resizing
+-    // now lets restore it to the saved value
+-    size_ = used_space;
+   }
++
+   T *ptr = reinterpret_cast<T*>(address() + used_space);
+   std::memset(ptr, 0, required_space);
+-  size_ += required_space;
++  size_ = used_space + required_space;
+   return ptr;
+ }
+ 
+Index: librime/include/rime/dict/table.h
+===================================================================
+--- librime.orig/include/rime/dict/table.h
++++ librime/include/rime/dict/table.h
+@@ -29,7 +29,7 @@ typedef List<SyllableId> Code;
+ 
+ struct Entry {
+   String text;
+-  float weight;
++  double weight;
+ };
+ 
+ struct HeadIndexNode {
+Index: librime/src/dict/table.cc
+===================================================================
+--- librime.orig/src/dict/table.cc
++++ librime/src/dict/table.cc
+@@ -412,7 +412,7 @@ bool Table::BuildEntry(const DictEntry &
+     LOG(ERROR) << "Error creating table entry '" << dict_entry.text << "'; file size: " << file_size();
+     return false;
+   }
+-  entry->weight = static_cast<float>(dict_entry.weight);
++  entry->weight = static_cast<double>(dict_entry.weight);
+   return true;
+ }
+ 
diff --git a/librime.spec b/librime.spec
index 7b83992..dd8b31d 100644
--- a/librime.spec
+++ b/librime.spec
@@ -1,6 +1,6 @@
 Name:           librime
 Version:        0.9.8
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Rime Input Method Engine Library
 
 License:        GPLv3
@@ -14,6 +14,8 @@ BuildRequires:  yaml-cpp-devel, kyotocabinet-devel
 
 #Remove zlib-devel depends
 Patch0:         librime-fixes-zlib-cmake.patch
+#Fixes arm build
+Patch1:         librime-fixes-misaligned-address.patch
 
 %description
 Rime Input Method Engine Library
@@ -44,7 +46,9 @@ The %{name}-tools package contains tools for %{name}.
 %prep
 %setup -q -n %{name}
 %patch0 -p1 -b .zlib
-
+%ifarch %{arm}
+%patch1 -p1 -b .arm
+%endif
 
 %build
 %cmake
@@ -80,6 +84,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
 
 
 %changelog
+* Mon Jul 15 2013 Peng Wu <pwu at redhat.com> - 0.9.8-3
+- Fixes arm build
+
 * Thu May 16 2013 Peng Wu <pwu at redhat.com> - 0.9.8-2
 - Improves the spec
 


More information about the scm-commits mailing list