{"issue":{"created_at":"2011-12-03T22:34:21Z","state":"open","updated_at":"2011-12-03T22:34:21Z","comments":0,"user":{"gravatar_id":"a8b7c135a381716a35791d82429c6604","id":1216493,"url":"https://api.github.com/users/DanielGibson","login":"DanielGibson","avatar_url":"https://secure.gravatar.com/avatar/a8b7c135a381716a35791d82429c6604?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"https://github.com/phire/doom3.gpl/blob/master/neo/sys/linux/main.cpp#L259\r\nThis code doesn't work. (Probably because unsigned long is 64bits long on Linux/amd64, but rdtsc uses uint32_t values).\r\nUse the following (from Kai Blaschke in the iodoom3 mailing list) instead:\r\n\r\n    uint32_t lo, hi;\r\n\r\n    __asm__ __volatile__ (      // serialize\r\n    \"xorl %%eax,%%eax \\n        cpuid\"\r\n    ::: \"%rax\", \"%rbx\", \"%rcx\", \"%rdx\");\r\n    /* We cannot use \"=A\", since this would use %rax on x86_64 and return only the lower 32bits of the TSC */\r\n    __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\r\n    return (double) lo + (double) 0xFFFFFFFF * hi; \r\n\r\nCheers,\r\n- Daniel","assignee":null,"number":11,"id":2439602,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"title":"Sys_GetClockTicks() defective on x86_64","closed_at":null,"html_url":"https://github.com/phire/doom3.gpl/issues/11","url":"https://api.github.com/repos/phire/doom3.gpl/issues/11","milestone":null},"action":"opened"}