diff --git a/src/base/base.gyp b/src/base/base.gyp index df4be68..dd53fe6 100644 --- a/src/base/base.gyp +++ b/src/base/base.gyp @@ -451,6 +451,9 @@ 'sources': [ 'serialized_string_array.cc', ], + 'dependencies': [ + 'base_core', + ], }, ], 'conditions': [ diff --git a/src/base/serialized_string_array.cc b/src/base/serialized_string_array.cc index 5b7283c..76c7a06 100644 --- a/src/base/serialized_string_array.cc +++ b/src/base/serialized_string_array.cc @@ -34,7 +34,7 @@ #include "base/file_stream.h" #include "base/logging.h" #include "base/port.h" -#include "base/system_util.h" +#include "base/util.h" namespace mozc { namespace { @@ -44,7 +44,7 @@ } // namespace SerializedStringArray::SerializedStringArray() { - DCHECK(SystemUtil::IsLittleEndian()) << "Little endian is assumed"; + DCHECK(Util::IsLittleEndian()) << "Little endian is assumed"; clear(); } diff --git a/src/base/system_util.cc b/src/base/system_util.cc index 91a4e79..71a2d16 100644 --- a/src/base/system_util.cc +++ b/src/base/system_util.cc @@ -865,21 +865,4 @@ #endif // OS_WIN, OS_MACOSX, OS_LINUX } -bool SystemUtil::IsLittleEndian() { -#ifndef OS_WIN - union { - unsigned char c[4]; - unsigned int i; - } u; - static_assert(sizeof(u.c) == sizeof(u.i), - "Expecting (unsigned) int is 32-bit integer."); - static_assert(sizeof(u) == sizeof(u.i), - "Checking alignment."); - u.i = 0x12345678U; - return u.c[0] == 0x78U; -#else // OS_WIN - return true; -#endif // OS_WIN -} - } // namespace mozc diff --git a/src/base/system_util.h b/src/base/system_util.h index a45d6ad..e104294 100644 --- a/src/base/system_util.h +++ b/src/base/system_util.h @@ -167,9 +167,6 @@ // retrieve total physical memory. returns 0 if any error occurs. static uint64 GetTotalPhysicalMemory(); - // check endian-ness at runtime. - static bool IsLittleEndian(); - private: DISALLOW_IMPLICIT_CONSTRUCTORS(SystemUtil); }; diff --git a/src/base/util.cc b/src/base/util.cc index 0a5439a..23eb7c4 100644 --- a/src/base/util.cc +++ b/src/base/util.cc @@ -1771,4 +1771,21 @@ return true; } +bool Util::IsLittleEndian() { +#ifdef OS_WIN + return true; +#else // OS_WIN + union { + unsigned char c[4]; + unsigned int i; + } u; + static_assert(sizeof(u.c) == sizeof(u.i), + "Expecting (unsigned) int is 32-bit integer."); + static_assert(sizeof(u) == sizeof(u.i), + "Checking alignment."); + u.i = 0x12345678U; + return u.c[0] == 0x78U; +#endif // OS_WIN +} + } // namespace mozc diff --git a/src/base/util.h b/src/base/util.h index f87cd1b..71d9269 100644 --- a/src/base/util.h +++ b/src/base/util.h @@ -460,6 +460,9 @@ // length of s is not eight or s is in an invalid format. static bool DeserializeUint64(StringPiece s, uint64 *x); + // Checks endian-ness at runtime. + static bool IsLittleEndian(); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(Util); }; diff --git a/src/converter/gen_segmenter_bitarray.cc b/src/converter/gen_segmenter_bitarray.cc index d06e063..2b32510 100644 --- a/src/converter/gen_segmenter_bitarray.cc +++ b/src/converter/gen_segmenter_bitarray.cc @@ -42,7 +42,7 @@ #include "base/file_stream.h" #include "base/logging.h" #include "base/port.h" -#include "base/system_util.h" +#include "base/util.h" #include "protocol/segmenter_data.pb.h" namespace mozc { @@ -189,7 +189,7 @@ CHECK(barray.array()); CHECK_GT(barray.size(), 0); - CHECK(SystemUtil::IsLittleEndian()) + CHECK(Util::IsLittleEndian()) << "Architecture must be little endian"; { mozc::converter::SegmenterDataSizeInfo pb; diff --git a/src/data/version/mozc_version_template.bzl b/src/data/version/mozc_version_template.bzl index f01337f..530adb8 100644 --- a/src/data/version/mozc_version_template.bzl +++ b/src/data/version/mozc_version_template.bzl @@ -30,7 +30,7 @@ MAJOR=2 MINOR=19 -BUILD=2640 +BUILD=2641 REVISION=102 # This version represents the version of Mozc IME engine (converter, predictor, # etc.). This version info is included both in the Mozc server and in the Mozc diff --git a/src/data_manager/serialized_dictionary.cc b/src/data_manager/serialized_dictionary.cc index 798b55a..a22578b 100644 --- a/src/data_manager/serialized_dictionary.cc +++ b/src/data_manager/serialized_dictionary.cc @@ -43,7 +43,6 @@ #include "base/port.h" #include "base/serialized_string_array.h" #include "base/string_piece.h" -#include "base/system_util.h" #include "base/util.h" namespace mozc { @@ -114,7 +113,7 @@ const std::map &dic, std::unique_ptr *output_token_array_buf, std::unique_ptr *output_string_array_buf) { - CHECK(SystemUtil::IsLittleEndian()); + CHECK(Util::IsLittleEndian()); // Build a mapping from string to its index in a serialized string array. // Note that duplicate keys share the same index, so data is slightly diff --git a/src/rewriter/gen_usage_rewriter_dictionary_main.cc b/src/rewriter/gen_usage_rewriter_dictionary_main.cc index 0707231..532a5c8 100644 --- a/src/rewriter/gen_usage_rewriter_dictionary_main.cc +++ b/src/rewriter/gen_usage_rewriter_dictionary_main.cc @@ -104,7 +104,6 @@ #include "base/init_mozc.h" #include "base/logging.h" #include "base/serialized_string_array.h" -#include "base/system_util.h" #include "base/util.h" DEFINE_string(usage_data_file, "", "usage data file"); @@ -249,7 +248,7 @@ } void Convert() { - CHECK(SystemUtil::IsLittleEndian()); + CHECK(Util::IsLittleEndian()); // Load cforms_file std::map> inflection_map; diff --git a/src/server/mozc_server.cc b/src/server/mozc_server.cc index 5df7c4b..f1268d8 100644 --- a/src/server/mozc_server.cc +++ b/src/server/mozc_server.cc @@ -45,6 +45,7 @@ #include "base/run_level.h" #include "base/singleton.h" #include "base/system_util.h" +#include "base/util.h" #include "config/stats_config_util.h" #include "session/session_server.h" @@ -66,7 +67,7 @@ // Big endian is not supported. The storage for user history is endian // dependent. If we want to sync the data via network sync feature, we // will see some problems. - CHECK(mozc::SystemUtil::IsLittleEndian()) << "Big endian is not supported."; + CHECK(mozc::Util::IsLittleEndian()) << "Big endian is not supported."; #ifdef OS_WIN // http://msdn.microsoft.com/en-us/library/ms686227.aspx // Make sure that mozc_server exits all after other processes.