diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2018-06-09 16:23:36 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2018-06-09 16:23:36 +0900 |
| commit | e0a827ff98e665a118e2001dfe29b14847a33070 (patch) | |
| tree | 8c4b0fdd2a5382a45bc0278a3762b81b2b0c7ee0 /src/AbstractDiskWriter.cc | |
| parent | 6f40026944d817a25a0275301eb295e49f23345c (diff) | |
Enable IndentPPDirectives
Diffstat (limited to 'src/AbstractDiskWriter.cc')
| -rw-r--r-- | src/AbstractDiskWriter.cc | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index a1eba628..ff4f8856 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -36,7 +36,7 @@ #include <unistd.h> #ifdef HAVE_MMAP -#include <sys/mman.h> +# include <sys/mman.h> #endif // HAVE_MMAP #include <fcntl.h> @@ -133,17 +133,17 @@ void AbstractDiskWriter::closeFile() #if defined(HAVE_MMAP) || defined(__MINGW32__) if (mapaddr_) { int errNum = 0; -#ifdef __MINGW32__ +# ifdef __MINGW32__ if (!UnmapViewOfFile(mapaddr_)) { errNum = GetLastError(); } CloseHandle(mapView_); mapView_ = INVALID_HANDLE_VALUE; -#else // !__MINGW32__ +# else // !__MINGW32__ if (munmap(mapaddr_, maplen_) == -1) { errNum = errno; } -#endif // !__MINGW32__ +# endif // !__MINGW32__ if (errNum != 0) { int errNum = fileError(); A2_LOG_ERROR(fmt("Unmapping file %s failed: %s", filename_.c_str(), @@ -224,13 +224,13 @@ int openFileWithFlags(const std::string& filename, int flags, errCode); } util::make_fd_cloexec(fd); -#if defined(__APPLE__) && defined(__MACH__) +# if defined(__APPLE__) && defined(__MACH__) // This may reduce memory consumption on Mac OS X. fcntl(fd, F_NOCACHE, 1); -#endif // __APPLE__ && __MACH__ +# endif // __APPLE__ && __MACH__ return fd; } -#endif // !__MINGW32__ +#endif // !__MINGW32__ } // namespace void AbstractDiskWriter::openExistingFile(int64_t totalLength) @@ -345,17 +345,17 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) if (mapaddr_) { if (static_cast<int64_t>(len + offset) > maplen_) { int errNum = 0; -#ifdef __MINGW32__ +# ifdef __MINGW32__ if (!UnmapViewOfFile(mapaddr_)) { errNum = GetLastError(); } CloseHandle(mapView_); mapView_ = INVALID_HANDLE_VALUE; -#else // !__MINGW32__ +# else // !__MINGW32__ if (munmap(mapaddr_, maplen_) == -1) { errNum = errno; } -#endif // !__MINGW32__ +# endif // !__MINGW32__ if (errNum != 0) { A2_LOG_ERROR(fmt("Unmapping file %s failed: %s", filename_.c_str(), fileStrerror(errNum).c_str())); @@ -385,7 +385,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) int errNum = 0; if (static_cast<int64_t>(len + offset) <= filesize) { -#ifdef __MINGW32__ +# ifdef __MINGW32__ mapView_ = CreateFileMapping(fd_, 0, PAGE_READWRITE, filesize >> 32, filesize & 0xffffffffu, 0); if (mapView_) { @@ -400,7 +400,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) else { errNum = GetLastError(); } -#else // !__MINGW32__ +# else // !__MINGW32__ auto pa = mmap(nullptr, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0); @@ -410,7 +410,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset) else { mapaddr_ = reinterpret_cast<unsigned char*>(pa); } -#endif // !__MINGW32__ +# endif // !__MINGW32__ if (mapaddr_) { A2_LOG_DEBUG(fmt("Mapping file %s succeeded, length=%" PRId64 "", filename_.c_str(), static_cast<uint64_t>(filesize))); @@ -517,7 +517,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) return; } #ifdef HAVE_SOME_FALLOCATE -#ifdef __MINGW32__ +# ifdef __MINGW32__ truncate(offset + length); if (!SetFileValidData(fd_, offset + length)) { auto errNum = fileError(); @@ -528,7 +528,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) "(see --file-allocation).", fileStrerror(errNum).c_str())); } -#elif defined(__APPLE__) && defined(__MACH__) +# elif defined(__APPLE__) && defined(__MACH__) const auto toalloc = offset + length - size(); fstore_t fstore = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0, toalloc, 0}; @@ -546,7 +546,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) } // This forces the allocation on disk. ftruncate(fd_, offset + length); -#elif HAVE_FALLOCATE +# elif HAVE_FALLOCATE // For linux, we use fallocate to detect file system supports // fallocate or not. int r; @@ -560,7 +560,7 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) isDiskFullError(errNum) ? error_code::NOT_ENOUGH_DISK_SPACE : error_code::FILE_IO_ERROR); } -#elif HAVE_POSIX_FALLOCATE +# elif HAVE_POSIX_FALLOCATE int r = posix_fallocate(fd_, offset, length); if (r != 0) { throw DL_ABORT_EX3( @@ -569,9 +569,9 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse) isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE : error_code::FILE_IO_ERROR); } -#else -#error "no *_fallocate function available." -#endif +# else +# error "no *_fallocate function available." +# endif #endif // HAVE_SOME_FALLOCATE } |
