1 | winegcc -mwindows code/win32_handmade.cpp |
Up until day 10, this worked without any code modifications, but gcc doesn't support the __rdtsc intrinsic [EDIT: This is actually not true if you include x86intrin.h. See below.]. So I added this (which I stole from Stack Overflow) to the top of the file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #ifndef _MSC_VER #ifdef __i386__ static __inline__ unsigned long long __rdtsc(void) { unsigned long long int x; __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A"(x)); return x; } #endif #ifdef __x86_64__ static __inline__ unsigned long long __rdtsc(void) { unsigned hi, lo; __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); } #endif #endif |
This might also work on OS X, but I don't run OS X so I don't know.