From: Orvid King <blah38621@gmail.com> Date: Mon, 27 Jul 2015 23:16:56 +0000 (-0700) Subject: Add support for MSVC in asm_pause in Portability.h X-Git-Tag: v0.53.0~54 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=778b571111db32e14f1f9ecf7746f2e6e5ea7f3d;p=folly.git Add support for MSVC in asm_pause in Portability.h Summary: This implements support for `asm_volatile_pause` and `asm_pause`, as defined in `Portability.h`, for MSVC. This is needed because MSVC x64 doesn't support inline assembly. Closes #254 Reviewed By: @yfeldblum Differential Revision: D2283006 Pulled By: @sgolemon --- diff --git a/folly/Portability.h b/folly/Portability.h index fbd8e3ab..40a62603 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -284,17 +284,25 @@ inline size_t malloc_usable_size(void* ptr) { # define FOLLY_HAS_RTTI 1 #endif +#ifdef _MSC_VER +# include <intrin.h> +#endif + namespace folly { inline void asm_volatile_pause() { -#if defined(__i386__) || FOLLY_X64 +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) + ::_mm_pause(); +#elif defined(__i386__) || FOLLY_X64 asm volatile ("pause"); #elif FOLLY_A64 asm volatile ("wfe"); #endif } inline void asm_pause() { -#if defined(__i386__) || FOLLY_X64 +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) + ::_mm_pause(); +#elif defined(__i386__) || FOLLY_X64 asm ("pause"); #elif FOLLY_A64 asm ("wfe");