[GitHub] [incubator-brpc] jamesge commented on a change in pull request #924: adapt to Arm64

2019-09-23 Thread GitBox
jamesge commented on a change in pull request #924: adapt to Arm64
URL: https://github.com/apache/incubator-brpc/pull/924#discussion_r327037980
 
 

 ##
 File path: src/bthread/processor.h
 ##
 @@ -23,9 +23,17 @@
 #ifndef BTHREAD_PROCESSOR_H
 #define BTHREAD_PROCESSOR_H
 
+#include "butil/build_config.h"
+
 // Pause instruction to prevent excess processor bus usage, only works in GCC
 # ifndef cpu_relax
+#if defined(ARCH_CPU_X86_FAMILY)
+# define cpu_relax() asm volatile("pause\n": : :"memory")
+#elif defined(ARCH_CPU_ARM_FAMILY)
+# define cpu_relax() asm volatile("yield\n": : :"memory")
+#else
 # define cpu_relax() asm volatile("pause\n": : :"memory")
+#endif
 
 Review comment:
   @niukuo 现在先合并好了,以后需要时自然可以再改动。


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on a change in pull request #924: adapt to Arm64

2019-09-23 Thread GitBox
jamesge commented on a change in pull request #924: adapt to Arm64
URL: https://github.com/apache/incubator-brpc/pull/924#discussion_r326972182
 
 

 ##
 File path: src/bthread/processor.h
 ##
 @@ -23,9 +23,17 @@
 #ifndef BTHREAD_PROCESSOR_H
 #define BTHREAD_PROCESSOR_H
 
+#include "butil/build_config.h"
+
 // Pause instruction to prevent excess processor bus usage, only works in GCC
 # ifndef cpu_relax
+#if defined(ARCH_CPU_X86_FAMILY)
+# define cpu_relax() asm volatile("pause\n": : :"memory")
+#elif defined(ARCH_CPU_ARM_FAMILY)
+# define cpu_relax() asm volatile("yield\n": : :"memory")
+#else
 # define cpu_relax() asm volatile("pause\n": : :"memory")
+#endif
 
 Review comment:
   相同代码可以合并吗?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on a change in pull request #924: adapt to Arm64

2019-09-22 Thread GitBox
jamesge commented on a change in pull request #924: adapt to Arm64
URL: https://github.com/apache/incubator-brpc/pull/924#discussion_r326962632
 
 

 ##
 File path: src/bthread/processor.h
 ##
 @@ -23,9 +23,15 @@
 #ifndef BTHREAD_PROCESSOR_H
 #define BTHREAD_PROCESSOR_H
 
+#include "butil/build_config.h"
+
 // Pause instruction to prevent excess processor bus usage, only works in GCC
 # ifndef cpu_relax
+#if defined(ARCH_CPU_X86_FAMILY)
 # define cpu_relax() asm volatile("pause\n": : :"memory")
+#elif defined(ARCH_CPU_ARM_FAMILY)
+# define cpu_relax() asm volatile("yield\n": : :"memory")
+#endif
 
 Review comment:
   需要补充else分支,要么让上述一个分支成为默认行为,要么在其中打印#error


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org