1 // Just some platform utilities.
2 #ifndef PLATFORM_H_INCLUDED
3 #define PLATFORM_H_INCLUDED
5 // x86 intrinsics (__rdtsc etc.)
9 #define _CRT_SECURE_NO_DEPRECATE
11 #define ALIGNSPEC(type,name,alignment) __declspec(align(alignment)) type name
13 #elif defined(__GNUC__)
15 #include <x86intrin.h>
16 #define ALIGNSPEC(type,name,alignment) type name __attribute__((aligned(alignment)))
19 #error Unknown compiler!
26 #define WIN32_LEAN_AND_MEAN
34 LARGE_INTEGER ctr, freq;
35 QueryPerformanceCounter(&ctr);
36 QueryPerformanceFrequency(&freq);
37 return 1.0 * ctr.QuadPart / freq.QuadPart;
40 #elif defined(__linux__)
42 #define __STDC_FORMAT_MACROS
47 static inline double timer()
52 int status = clock_gettime(CLOCK_MONOTONIC, &ts);
54 return double(ts.tv_sec) + 1.0e-9 * double(ts.tv_nsec);
59 #error Unknown platform!
63 #endif // PLATFORM_H_INCLUDED