File: init.c

package info (click to toggle)
haskell-hashable 1.4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 200 kB
  • sloc: haskell: 1,199; ansic: 77; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdint.h>

#include <windows.h>

uint64_t hs_hashable_init() {
    /* Handy list at https://stackoverflow.com/a/3487338/1308058 */

    uint64_t a = GetCurrentProcessId(); /* DWORD */
    uint64_t b = GetCurrentThreadId(); /* DWORD */
    uint64_t c = GetTickCount(); /* DWORD */

    SYSTEMTIME t = {0,0,0,0,0,0,0,0};
    GetSystemTime(&t);

    LARGE_INTEGER i;
    QueryPerformanceCounter(&i);

    return a ^ (b << 32) ^ (c << 16)
        ^ ((uint64_t) t.wYear         << 56)
        ^ ((uint64_t) t.wMonth        << 48)
        ^ ((uint64_t) t.wDayOfWeek    << 40)
        ^ ((uint64_t) t.wDay          << 32)
        ^ ((uint64_t) t.wHour         << 24)
        ^ ((uint64_t) t.wMinute       << 16)
        ^ ((uint64_t) t.wSecond       << 8)
        ^ ((uint64_t) t.wMilliseconds << 0)
        ^ ((uint64_t) i.QuadPart);
}