barrier: explicitly check for x86 architecture

Prepare for the addition of more architectures by replacing the #else
case with an explicit x86 check, and add a final #else to trigger a
compile-time error if the architecture is not supported.

This adds a empty #defines of spdk_wmb() and spdk_mb() in the #else
error case so that they still show up in the generated Doxygen output.

Change-Id: Ia9e9de1648694013de1cd8a2e3edfa9b1166401c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/386345
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-11-08 16:28:58 -07:00 committed by Jim Harris
parent b1864503cd
commit ccf8cb1834

View File

@ -51,15 +51,21 @@ extern "C" {
/** Write memory barrier */
#ifdef __PPC64__
#define spdk_wmb() __asm volatile("sync" ::: "memory")
#else
#elif defined(__i386__) || defined(__x86_64__)
#define spdk_wmb() __asm volatile("sfence" ::: "memory")
#else
#define spdk_wmb()
#error Unknown architecture
#endif
/** Full read/write memory barrier */
#ifdef __PPC64__
#define spdk_mb() __asm volatile("sync" ::: "memory")
#else
#elif defined(__i386__) || defined(__x86_64__)
#define spdk_mb() __asm volatile("mfence" ::: "memory")
#else
#define spdk_mb()
#error Unknown architecture
#endif
#ifdef __cplusplus