34#define PRINT_HASH(H) \
36 printf ("c PRINT_HASH %32s () = %020" PRIu64 "\n", __func__, H); \
40#define PRINT_HASH(...) \
55static uint64_t hash_machine_identifier () {
56 FILE *
file = fopen (
"/var/lib/dbus/machine-id",
"r");
60 memset (buffer, 0,
sizeof buffer);
61 size_t bytes = fread (buffer, 1,
sizeof buffer - 1,
file);
64 if (bytes && bytes <
sizeof buffer) {
92#include <netinet/in.h>
95#include <sys/socket.h>
104static uint64_t hash_network_addresses () {
114 struct ifaddrs *addrs;
115 if (!getifaddrs (&addrs)) {
116 for (
struct ifaddrs *addr = addrs; addr; addr = addr->ifa_next) {
119 const int family = addr->ifa_addr->sa_family;
120 if (family == AF_INET || family == AF_INET6) {
121 const int size = (family == AF_INET) ?
sizeof (
struct sockaddr_in)
122 :
sizeof (
struct sockaddr_in6);
124 if (!getnameinfo (addr->ifa_addr, size, buffer,
sizeof buffer, 0, 0,
126 uint64_t tmp = hash_string (buffer);
128 printf (
"c PRINT_HASH %35s = %020" PRIu64
"\n", buffer, tmp);
132 res *= 10000000000000000051ul;
160static uint64_t hash_time () {
161 uint64_t res = ::time (0);
175#include <sys/types.h>
187static uint64_t hash_process () {
188 uint64_t res = getpid ();
207static uint64_t hash_clock_cycles () {
208 uint64_t res = std::clock ();
220 add (hash_machine_identifier ());
221 add (hash_network_addresses ());
222 add (hash_clock_cycles ());
223 add (hash_process ());
226 printf (
"c PRINT_HASH %32s = %020" PRIu64
"\n",
"combined", state);
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define CADICAL_assert(ignore)
uint64_t hash_string(const char *str)