Codebase list mozc / 6261445
Move SystemUtil::IsLittleEndian to Util This CL removes the dependency on system_util from some build tools. BUG= TEST= REF_BUG=31945229 REF_CL=136122387 REF_TIME=2016-10-14T13:24:52+09:00 REF_TIME_RAW=1476419092 +0900 Noriyuki Takahashi 7 years ago
11 changed file(s) with 32 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
450450 'sources': [
451451 'serialized_string_array.cc',
452452 ],
453 'dependencies': [
454 'base_core',
455 ],
453456 },
454457 ],
455458 'conditions': [
3333 #include "base/file_stream.h"
3434 #include "base/logging.h"
3535 #include "base/port.h"
36 #include "base/system_util.h"
36 #include "base/util.h"
3737
3838 namespace mozc {
3939 namespace {
4343 } // namespace
4444
4545 SerializedStringArray::SerializedStringArray() {
46 DCHECK(SystemUtil::IsLittleEndian()) << "Little endian is assumed";
46 DCHECK(Util::IsLittleEndian()) << "Little endian is assumed";
4747 clear();
4848 }
4949
864864 #endif // OS_WIN, OS_MACOSX, OS_LINUX
865865 }
866866
867 bool SystemUtil::IsLittleEndian() {
868 #ifndef OS_WIN
869 union {
870 unsigned char c[4];
871 unsigned int i;
872 } u;
873 static_assert(sizeof(u.c) == sizeof(u.i),
874 "Expecting (unsigned) int is 32-bit integer.");
875 static_assert(sizeof(u) == sizeof(u.i),
876 "Checking alignment.");
877 u.i = 0x12345678U;
878 return u.c[0] == 0x78U;
879 #else // OS_WIN
880 return true;
881 #endif // OS_WIN
882 }
883
884867 } // namespace mozc
166166 // retrieve total physical memory. returns 0 if any error occurs.
167167 static uint64 GetTotalPhysicalMemory();
168168
169 // check endian-ness at runtime.
170 static bool IsLittleEndian();
171
172169 private:
173170 DISALLOW_IMPLICIT_CONSTRUCTORS(SystemUtil);
174171 };
17701770 return true;
17711771 }
17721772
1773 bool Util::IsLittleEndian() {
1774 #ifdef OS_WIN
1775 return true;
1776 #else // OS_WIN
1777 union {
1778 unsigned char c[4];
1779 unsigned int i;
1780 } u;
1781 static_assert(sizeof(u.c) == sizeof(u.i),
1782 "Expecting (unsigned) int is 32-bit integer.");
1783 static_assert(sizeof(u) == sizeof(u.i),
1784 "Checking alignment.");
1785 u.i = 0x12345678U;
1786 return u.c[0] == 0x78U;
1787 #endif // OS_WIN
1788 }
1789
17731790 } // namespace mozc
459459 // length of s is not eight or s is in an invalid format.
460460 static bool DeserializeUint64(StringPiece s, uint64 *x);
461461
462 // Checks endian-ness at runtime.
463 static bool IsLittleEndian();
464
462465 private:
463466 DISALLOW_IMPLICIT_CONSTRUCTORS(Util);
464467 };
4141 #include "base/file_stream.h"
4242 #include "base/logging.h"
4343 #include "base/port.h"
44 #include "base/system_util.h"
44 #include "base/util.h"
4545 #include "protocol/segmenter_data.pb.h"
4646
4747 namespace mozc {
188188 CHECK(barray.array());
189189 CHECK_GT(barray.size(), 0);
190190
191 CHECK(SystemUtil::IsLittleEndian())
191 CHECK(Util::IsLittleEndian())
192192 << "Architecture must be little endian";
193193 {
194194 mozc::converter::SegmenterDataSizeInfo pb;
2929
3030 MAJOR=2
3131 MINOR=19
32 BUILD=2640
32 BUILD=2641
3333 REVISION=102
3434 # This version represents the version of Mozc IME engine (converter, predictor,
3535 # etc.). This version info is included both in the Mozc server and in the Mozc
4242 #include "base/port.h"
4343 #include "base/serialized_string_array.h"
4444 #include "base/string_piece.h"
45 #include "base/system_util.h"
4645 #include "base/util.h"
4746
4847 namespace mozc {
113112 const std::map<string, TokenList> &dic,
114113 std::unique_ptr<uint32[]> *output_token_array_buf,
115114 std::unique_ptr<uint32[]> *output_string_array_buf) {
116 CHECK(SystemUtil::IsLittleEndian());
115 CHECK(Util::IsLittleEndian());
117116
118117 // Build a mapping from string to its index in a serialized string array.
119118 // Note that duplicate keys share the same index, so data is slightly
103103 #include "base/init_mozc.h"
104104 #include "base/logging.h"
105105 #include "base/serialized_string_array.h"
106 #include "base/system_util.h"
107106 #include "base/util.h"
108107
109108 DEFINE_string(usage_data_file, "", "usage data file");
248247 }
249248
250249 void Convert() {
251 CHECK(SystemUtil::IsLittleEndian());
250 CHECK(Util::IsLittleEndian());
252251
253252 // Load cforms_file
254253 std::map<string, std::vector<ConjugationType>> inflection_map;
4444 #include "base/run_level.h"
4545 #include "base/singleton.h"
4646 #include "base/system_util.h"
47 #include "base/util.h"
4748 #include "config/stats_config_util.h"
4849 #include "session/session_server.h"
4950
6566 // Big endian is not supported. The storage for user history is endian
6667 // dependent. If we want to sync the data via network sync feature, we
6768 // will see some problems.
68 CHECK(mozc::SystemUtil::IsLittleEndian()) << "Big endian is not supported.";
69 CHECK(mozc::Util::IsLittleEndian()) << "Big endian is not supported.";
6970 #ifdef OS_WIN
7071 // http://msdn.microsoft.com/en-us/library/ms686227.aspx
7172 // Make sure that mozc_server exits all after other processes.