More portable, particularly when building with Clang, which implements
all MSVC intrisincs in its own intrin.h, but doesn't actually support
`#pragma instrinsic`.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
#include <strings.h> /* for ffs */
#endif
+#if defined(_MSC_VER)
+#include <intrin.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#define FFS_DEFINED 1
#if defined(_MSC_VER) && (_M_IX86 || _M_AMD64 || _M_IA64)
-unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
-#pragma intrinsic(_BitScanForward)
static inline
unsigned long ffs( unsigned long u )
{
#if defined(PIPE_CC_MSVC)
-unsigned __int64 __rdtsc();
-#pragma intrinsic(__rdtsc)
+#include <intrin.h>
#define rdtsc() __rdtsc()
#elif defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
#if defined(_MSC_VER)
+#include <intrin.h>
+
/* Avoid 'expression is always true' warning */
#pragma warning(disable: 4296)
#elif defined(_MSC_VER)
-void _ReadWriteBarrier(void);
-#pragma intrinsic(_ReadWriteBarrier)
#define PIPE_READ_WRITE_BARRIER() _ReadWriteBarrier()
#else