Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __inline__ unsigned long long int rdtsc()
- {
- #ifdef __x86_64__
- unsigned int a, d;
- __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
- return (unsigned long)a | ((unsigned long)d << 32);
- #elif defined(__i386__)
- unsigned long long int x;
- __asm__ volatile ("rdtsc" : "=A" (x));
- return x;
- #else
- #define NO_CYCLE_COUNTER
- return 0;
- #endif
- }
- It may fail if the long type appears 32-bit - an overflow will occur in the "(unsigned long)d << 32" expression.
- This suspicious code was found in smhasher project by PVS-Studio static code analyzer.
- Warning message is:
- V629 Consider inspecting the '(unsigned long) d << 32' expression. Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type. Platform.h 78
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment