aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-08-06 23:54:52 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-08-06 23:55:40 +0300
commit0fe0e7ff60a87834a4838e4f1ec651cf7c78a2f2 (patch)
treea2827c40b9c9962e64fb1ba35369a147c08e00ea
parentcode style (diff)
downloadwinapi-debug-0fe0e7ff60a87834a4838e4f1ec651cf7c78a2f2.tar.gz
winapi-debug-0fe0e7ff60a87834a4838e4f1ec651cf7c78a2f2.zip
don't hash bitwise (because you know, padding)
-rw-r--r--CMakeLists.txt5
-rw-r--r--include/pdb/utils/file.hpp19
2 files changed, 19 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecf45d0..79829a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,11 +6,14 @@ project(pdb_repo CXX)
include(common.cmake)
+find_package(Boost REQUIRED)
+
file(GLOB_RECURSE pdb_repo_include "include/*.hpp")
file(GLOB_RECURSE pdb_repo_src "src/*.cpp")
add_library(pdb_repo ${pdb_repo_include} ${pdb_repo_src})
-target_compile_definitions(pdb_repo PRIVATE NOMINMAX PUBLIC _NO_CVCONST_H)
+target_compile_definitions(pdb_repo PRIVATE WIN32_LEAN_AND_MEAN PUBLIC _NO_CVCONST_H)
target_include_directories(pdb_repo PUBLIC include/)
+target_include_directories(pdb_repo SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(pdb_repo PRIVATE DbgHelp)
add_subdirectory(utils)
diff --git a/include/pdb/utils/file.hpp b/include/pdb/utils/file.hpp
index 50975aa..bf97115 100644
--- a/include/pdb/utils/file.hpp
+++ b/include/pdb/utils/file.hpp
@@ -7,12 +7,15 @@
#include <Windows.h>
+#pragma warning(push, 0)
+#include <boost/functional/hash.hpp>
+#pragma warning(pop)
+
#include <cstddef>
#include <cstring>
#include <functional>
#include <string>
-#include <type_traits>
namespace pdb
{
@@ -20,14 +23,19 @@ namespace pdb
{
std::size_t get_size(const std::string&);
+ inline bool operator==(const FILE_ID_128& a, const FILE_ID_128& b)
+ {
+ return 0 == std::memcmp(a.Identifier, b.Identifier, sizeof(a.Identifier));
+ }
+
struct ID
{
const FILE_ID_INFO raw;
bool operator==(const ID& other) const
{
- static_assert(std::is_pod<FILE_ID_INFO>::value, "Can't memcmp if file IDs aren't PODs");
- return 0 == std::memcmp(&raw, &other.raw, sizeof(FILE_ID_INFO));
+ return raw.VolumeSerialNumber == other.raw.VolumeSerialNumber
+ && raw.FileId == other.raw.FileId;
}
};
@@ -42,7 +50,10 @@ namespace std
{
std::size_t operator()(const pdb::file::ID& id) const
{
- return _Bitwise_hash<FILE_ID_INFO>{}(id.raw);
+ std::size_t seed = 0;
+ boost::hash_combine(seed, id.raw.VolumeSerialNumber);
+ boost::hash_combine(seed, id.raw.FileId.Identifier);
+ return seed;
}
};
}