2121# ifndef WIN32_LEAN_AND_MEAN
2222# define WIN32_LEAN_AND_MEAN
2323# endif
24- # include < windows.h>
2524# include < psapi.h>
25+ # include < windows.h>
2626#else
2727# include < sys/mman.h>
2828#endif
@@ -78,21 +78,18 @@ class ParallelMemStreamBuf : public std::streambuf {
7878 MEMORY_BASIC_INFORMATION mbi{};
7979 if (VirtualQuery (data, &mbi, sizeof (mbi)) && mbi.Type == MEM_MAPPED) {
8080 wchar_t dev_path[MAX_PATH] = {};
81- if (GetMappedFileNameW (GetCurrentProcess (),
82- const_cast <void *>(data),
83- dev_path,
84- MAX_PATH) > 0 ) {
81+ if (GetMappedFileNameW (GetCurrentProcess (), const_cast <void *>(data), dev_path, MAX_PATH) > 0 ) {
8582 // Convert device path (\Device\HarddiskVolume3\...) to Win32 path.
8683 wchar_t win32_path[MAX_PATH] = {};
8784 if (resolve_device_path (dev_path, win32_path, MAX_PATH)) {
8885 // Compute the file offset: the region base may be at a
8986 // different page boundary than the pointer we received.
9087 // AllocationBase is the start of the mapped view.
9188 const std::streamoff file_offset =
92- reinterpret_cast <const char *>(data) -
93- reinterpret_cast < const char *>(mbi. AllocationBase );
94- m_file_buf = std::make_unique<ParallelReadStreamBuf>(
95- std::filesystem::path (win32_path), file_offset, threshold);
89+ reinterpret_cast <const char *>(data) - reinterpret_cast < const char *>(mbi. AllocationBase );
90+ m_file_buf = std::make_unique<ParallelReadStreamBuf>( std::filesystem::path (win32_path),
91+ file_offset,
92+ threshold);
9693 }
9794 }
9895 }
@@ -298,9 +295,7 @@ class ParallelMemStreamBuf : public std::streambuf {
298295 // Parse /proc/self/maps to find the file backing an mmap address.
299296 // Returns true and fills out_path/out_offset if the address is inside
300297 // a named file mapping (i.e. not anonymous / [stack] / [heap]).
301- static bool get_mmap_file_info (const void * addr,
302- std::filesystem::path& out_path,
303- std::streamoff& out_offset) {
298+ static bool get_mmap_file_info (const void * addr, std::filesystem::path& out_path, std::streamoff& out_offset) {
304299 std::ifstream maps_file (" /proc/self/maps" );
305300 if (!maps_file.is_open ())
306301 return false ;
@@ -316,21 +311,17 @@ class ParallelMemStreamBuf : public std::streambuf {
316311 const auto dash = addr_range.find (' -' );
317312 if (dash == std::string::npos)
318313 continue ;
319- const auto range_start =
320- static_cast <uintptr_t >(std::stoull (addr_range.substr (0 , dash), nullptr , 16 ));
321- const auto range_end =
322- static_cast <uintptr_t >(std::stoull (addr_range.substr (dash + 1 ), nullptr , 16 ));
314+ const auto range_start = static_cast <uintptr_t >(std::stoull (addr_range.substr (0 , dash), nullptr , 16 ));
315+ const auto range_end = static_cast <uintptr_t >(std::stoull (addr_range.substr (dash + 1 ), nullptr , 16 ));
323316 if (addr_val < range_start || addr_val >= range_end)
324317 continue ;
325318 // Read optional pathname
326319 std::string path;
327320 if (!(iss >> path) || path.empty () || path[0 ] != ' /' )
328321 return false ; // anonymous or special region, no benefit
329322 out_path = path;
330- const auto map_offset =
331- static_cast <std::streamoff>(std::stoull (offset_str, nullptr , 16 ));
332- out_offset = map_offset +
333- static_cast <std::streamoff>(addr_val - range_start);
323+ const auto map_offset = static_cast <std::streamoff>(std::stoull (offset_str, nullptr , 16 ));
324+ out_offset = map_offset + static_cast <std::streamoff>(addr_val - range_start);
334325 return true ;
335326 }
336327 return false ;
0 commit comments