From c55a1474dfdcf03554a8fee98a0023c481d96ec0 Mon Sep 17 00:00:00 2001 From: Graham Neubig Date: Thu, 10 Jan 2013 16:16:23 +0900 Subject: [PATCH 1/3] Updated experiment.meta --- scripts/ems/experiment.meta | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ems/experiment.meta b/scripts/ems/experiment.meta index 210fddb93..52596227c 100644 --- a/scripts/ems/experiment.meta +++ b/scripts/ems/experiment.meta @@ -401,21 +401,21 @@ mml-filter-before-wa prepare-data in: corpus-mml-prefilter=OR=corpus out: prepared-data - rerun-on-change: alignment-factors training-options script baseline-alignment-model + rerun-on-change: alignment-factors training-options script baseline-alignment-model external-bin-dr ignore-if: use-berkeley default-name: prepared run-giza in: prepared-data out: giza-alignment ignore-if: use-berkeley - rerun-on-change: giza-settings training-options script baseline-alignment-model + rerun-on-change: giza-settings training-options script baseline-alignment-model external-bin-dir default-name: giza error: not found not-error: 0 not found run-giza-inverse in: prepared-data out: giza-alignment-inverse - rerun-on-change: giza-settings training-options script baseline-alignment-model + rerun-on-change: giza-settings training-options script baseline-alignment-model external-bin-dir ignore-if: use-berkeley default-name: giza-inverse error: not found From f8b2b49afacb8fb65dd2b4ca334087557b163031 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Thu, 10 Jan 2013 13:32:17 +0000 Subject: [PATCH 2/3] Stupid android 64-bit file offsets, static assert sizeof(off_t) == 8 --- util/file.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/util/file.cc b/util/file.cc index cc4aad024..b5f434165 100644 --- a/util/file.cc +++ b/util/file.cc @@ -64,9 +64,16 @@ uint64_t SizeFile(int fd) { #if defined(_WIN32) || defined(_WIN64) __int64 ret = _filelengthi64(fd); return (ret == -1) ? kBadSize : ret; +#else // Not windows. + +#ifdef OS_ANDROID + struct stat64 sb; + int ret = fstat64(fd, &sb); #else struct stat sb; - if (fstat(fd, &sb) == -1 || (!sb.st_size && !S_ISREG(sb.st_mode))) return kBadSize; + int ret = fstat(fd, &sb); +#endif + if (ret == -1 || (!sb.st_size && !S_ISREG(sb.st_mode))) return kBadSize; return sb.st_size; #endif } @@ -139,11 +146,25 @@ void FSyncOrThrow(int fd) { } namespace { + +// Static assert for 64-bit off_t size. +#if !defined(_WIN32) && !defined(_WIN64) && !defined(OS_ANDROID) +template struct CheckOffT; +template <> struct CheckOffT<8> { + struct True {}; +}; +// If there's a compiler error on the next line, then off_t isn't 64 bit. And +// that makes me a sad panda. +typedef CheckOffT::True IgnoredType; +#endif + // Can't we all just get along? void InternalSeek(int fd, int64_t off, int whence) { UTIL_THROW_IF( #if defined(_WIN32) || defined(_WIN64) - (__int64)-1 == _lseeki64(fd, off, whence), + (__int64)-1 == _lseeki64(fd, off, whence), +#elif defined(OS_ANDROID) + (off64_t)-1 == lseek64(fd, off, whence), #else (off_t)-1 == lseek(fd, off, whence), #endif From 2e5c1af5da97b549984d36b3378e54ab5a3148c8 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Thu, 10 Jan 2013 13:45:41 +0000 Subject: [PATCH 3/3] Also ftruncate64 on android --- util/file.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/file.cc b/util/file.cc index b5f434165..072062cad 100644 --- a/util/file.cc +++ b/util/file.cc @@ -79,11 +79,15 @@ uint64_t SizeFile(int fd) { } void ResizeOrThrow(int fd, uint64_t to) { + UTIL_THROW_IF( #if defined(_WIN32) || defined(_WIN64) - UTIL_THROW_IF(_chsize_s(fd, to), ErrnoException, "Resizing to " << to << " bytes failed"); + _chsize_s +#elif defined(OS_ANDROID) + ftruncate64 #else - UTIL_THROW_IF(ftruncate(fd, to), ErrnoException, "Resizing to " << to << " bytes failed"); + ftruncate #endif + (fd, to), ErrnoException, "Resizing to " << to << " bytes failed"); } std::size_t PartialRead(int fd, void *to, std::size_t amount) {