GraphDom
Toggle main menu visibility
Loading...
Searching...
No Matches
utility.h
1
/*
2
* Copyright 2026 Michele Comparini
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
#ifndef GRAPHDOM_UTILITY_H
8
#define GRAPHDOM_UTILITY_H
9
10
#include <cstdint>
11
12
namespace
graphdom::utility{}
13
14
namespace
graphdom::utility {
15
inline
std::uintptr_t hash_pointer(
const
void
*
const
input) {
16
if
constexpr
(
sizeof
(
void
*) == 8 ) {
17
// See "SplitMix64" written in 2015 by Sebastiano Vigna ( https://prng.di.unimi.it/splitmix64.c )
18
auto
output =
reinterpret_cast<
std::uintptr_t
>
( input ) + 0x9e3779b97f4a7c15;
19
output = (output ^ (output >> 30)) * 0xbf58476d1ce4e5b9;
20
output = (output ^ (output >> 27)) * 0x94d049bb133111eb;
21
return
output ^ (output >> 31);
22
}
23
else
if
constexpr
(
sizeof
(
void
*) == 4 ) {
24
// See "fmix32" function of "MurmurHash3" written by Austin Appleby ( https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp )
25
auto
output =
reinterpret_cast<
std::uintptr_t
>
( input );
26
output ^= output >> 16;
27
output *= 0x85ebca6b;
28
output ^= output >> 13;
29
output *= 0xc2b2ae35;
30
output ^= output >> 16;
31
return
output;
32
}
33
return
reinterpret_cast<
std::uintptr_t
>
( input );
34
}
35
}
36
37
38
#endif
//GRAPHDOM_UTILITY_H
include
graphdom
utility.h
Generated by
1.17.0