On 3/11/21 9:23 PM, Jacek Caban wrote:
On 11.03.2021 11:47, Rémi Bernon wrote:
On 3/10/21 10:20 PM, Rémi Bernon wrote:
On 3/10/21 9:44 PM, Jacek Caban wrote:
On 10.03.2021 17:13, Rémi Bernon wrote:
Apparently clang >= 4.0.0 has __rdtsc (but not __rdtscp). Can we just assume clang >= 4.0.0 is used and something like that would be acceptable instead?
There is __has_builtin(), which would be cleaner in this case, IMHO.
Both compilers ship __rdtscp in ia32intrin.h header (gcc also __rdtscp, which clang doesn't need). I was considering something like this inside our intrin.h:
#if defined(__i386__) || defined(__x86_64__)
# include <x86intrin.h>
#endif
I believe that this should solve your problem. This rises some compatibility concerns, but I think it may be fine. It's shipped with compilers themselves for all platforms (not by mingw-w64).
Jacek
Ah yes sure, I didn't know these were available in intel intrinsic headers. I guess that would be perfect then.
Except that it has some conflicts with msvcrt _(l)rot[r|l] functions in stdlib.h. Can we remove the definitions from there?
#undefs, like in the attached patch, seem to be enough.
Jacek
IMHO if these are definitions, it would be more efficient to have #ifndef instead, and use the compiler builtin intrinsic when it is available.
But then, I'm not sure we can reliably assume they are always definitions (it seems to be the case on Clang and GCC, but there's no guarantee it'll always be).