File: init.c

package info (click to toggle)
haskell-splitmix 0.1.0.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: haskell: 1,366; ansic: 151; sh: 53; makefile: 9
file content (28 lines) | stat: -rw-r--r-- 837 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 splitmix_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);
}