diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/exception.cc | 5 | ||||
-rw-r--r-- | util/fake_ofstream.hh | 14 | ||||
-rw-r--r-- | util/stream/chain.cc | 2 | ||||
-rw-r--r-- | util/stream/io.cc | 2 | ||||
-rw-r--r-- | util/usage.cc | 12 | ||||
-rw-r--r-- | util/usage.hh | 4 |
6 files changed, 29 insertions, 10 deletions
diff --git a/util/exception.cc b/util/exception.cc index 083bac20d..eaf4cbc21 100644 --- a/util/exception.cc +++ b/util/exception.cc @@ -51,6 +51,11 @@ void Exception::SetLocation(const char *file, unsigned int line, const char *fun } namespace { + +#ifdef __GNUC__ +const char *HandleStrerror(int ret, const char *buf) __attribute__ ((unused)); +const char *HandleStrerror(const char *ret, const char * /*buf*/) __attribute__ ((unused)); +#endif // At least one of these functions will not be called. #ifdef __clang__ #pragma clang diagnostic push diff --git a/util/fake_ofstream.hh b/util/fake_ofstream.hh index eefb1edce..987fa8015 100644 --- a/util/fake_ofstream.hh +++ b/util/fake_ofstream.hh @@ -17,16 +17,15 @@ namespace util { class FakeOFStream { public: - static const std::size_t kOutBuf = 1048576; - // Does not take ownership of out. // Allows default constructor, but must call SetFD. - explicit FakeOFStream(int out = -1) - : buf_(util::MallocOrThrow(kOutBuf)), - builder_(static_cast<char*>(buf_.get()), kOutBuf), + explicit FakeOFStream(int out = -1, std::size_t buffer_size = 1048576) + : buf_(util::MallocOrThrow(buffer_size)), + builder_(static_cast<char*>(buf_.get()), buffer_size), // Mostly the default but with inf instead. And no flags. convert_(double_conversion::DoubleToStringConverter::NO_FLAGS, "inf", "NaN", 'e', -6, 21, 6, 0), - fd_(out) {} + fd_(out), + buffer_size_(buffer_size) {} ~FakeOFStream() { if (buf_.get()) Flush(); @@ -51,7 +50,7 @@ class FakeOFStream { } FakeOFStream &operator<<(StringPiece str) { - if (str.size() > kOutBuf) { + if (str.size() > buffer_size_) { Flush(); util::WriteOrThrow(fd_, str.data(), str.size()); } else { @@ -98,6 +97,7 @@ class FakeOFStream { double_conversion::StringBuilder builder_; double_conversion::DoubleToStringConverter convert_; int fd_; + const std::size_t buffer_size_; }; } // namespace diff --git a/util/stream/chain.cc b/util/stream/chain.cc index 4596af7ae..ce29e428c 100644 --- a/util/stream/chain.cc +++ b/util/stream/chain.cc @@ -128,7 +128,7 @@ Link::~Link() { if (current_) { // Probably an exception unwinding. std::cerr << "Last input should have been poison." << std::endl; -// abort(); + // abort(); } else { if (!poisoned_) { // Poison is a block whose memory pointer is NULL. diff --git a/util/stream/io.cc b/util/stream/io.cc index c64004c0b..fa8467abd 100644 --- a/util/stream/io.cc +++ b/util/stream/io.cc @@ -70,6 +70,8 @@ void PWriteAndRecycle::Run(const ChainPosition &position) { offset += link->ValidSize(); link->SetValidSize(block_size); } + // Trim file to size. + util::ResizeOrThrow(file_, offset); } } // namespace stream diff --git a/util/usage.cc b/util/usage.cc index 2a4aa47d4..a597300e3 100644 --- a/util/usage.cc +++ b/util/usage.cc @@ -68,6 +68,18 @@ Wall GetWall() { } #endif +// gcc possible-unused function flags +#ifdef __GNUC__ +double Subtract(time_t first, time_t second) __attribute__ ((unused)); +double DoubleSec(time_t tv) __attribute__ ((unused)); +#if !defined(_WIN32) && !defined(_WIN64) +double Subtract(const struct timeval &first, const struct timeval &second) __attribute__ ((unused)); +double Subtract(const struct timespec &first, const struct timespec &second) __attribute__ ((unused)); +double DoubleSec(const struct timeval &tv) __attribute__ ((unused)); +double DoubleSec(const struct timespec &tv) __attribute__ ((unused)); +#endif +#endif + // Some of these functions are only used on some platforms. #ifdef __clang__ #pragma clang diagnostic push diff --git a/util/usage.hh b/util/usage.hh index 5407f5a54..e578b0a65 100644 --- a/util/usage.hh +++ b/util/usage.hh @@ -13,9 +13,9 @@ double WallTime(); void PrintUsage(std::ostream &to); // Determine how much physical memory there is. Return 0 on failure. -::uint64_t GuessPhysicalMemory(); +uint64_t GuessPhysicalMemory(); // Parse a size like unix sort. Sadly, this means the default multiplier is K. -::uint64_t ParseSize(const std::string &arg); +uint64_t ParseSize(const std::string &arg); } // namespace util #endif // UTIL_USAGE_H |