diff mbox series

slirp: Mark debugging calls as unlikely

Message ID 20181121224220.10595-1-samuel.thibault@ens-lyon.org
State New
Headers show
Series slirp: Mark debugging calls as unlikely | expand

Commit Message

Samuel Thibault Nov. 21, 2018, 10:42 p.m. UTC
to get them out of the hot path.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 slirp/debug.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Marc-André Lureau Nov. 22, 2018, 7:13 a.m. UTC | #1
Hi

On Thu, Nov 22, 2018 at 2:54 AM Samuel Thibault
<samuel.thibault@ens-lyon.org> wrote:
>
> to get them out of the hot path.
>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  slirp/debug.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/slirp/debug.h b/slirp/debug.h
> index ff920f0b87..ad4e07aa01 100644
> --- a/slirp/debug.h
> +++ b/slirp/debug.h
> @@ -17,7 +17,7 @@
>  extern int slirp_debug;
>
>  #define DEBUG_CALL(fmt, ...) do {               \
> -    if (slirp_debug & DBG_CALL) {               \
> +    if (unlikely(slirp_debug & DBG_CALL)) {     \
>          fprintf(dfd, fmt, ##__VA_ARGS__);       \
>          fprintf(dfd, "...\n");                  \
>          fflush(dfd);                            \
> @@ -25,7 +25,7 @@ extern int slirp_debug;
>  } while (0)
>
>  #define DEBUG_ARG(fmt, ...) do {                \
> -    if (slirp_debug & DBG_CALL) {               \
> +    if (unlikely(slirp_debug & DBG_CALL)) {     \
>          fputc(' ', dfd);                        \
>          fprintf(dfd, fmt, ##__VA_ARGS__);       \
>          fputc('\n', dfd);                       \
> @@ -36,14 +36,14 @@ extern int slirp_debug;
>  #define DEBUG_ARGS(fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__)
>
>  #define DEBUG_MISC(fmt, ...) do {               \
> -    if (slirp_debug & DBG_MISC) {               \
> +    if (unlikely(slirp_debug & DBG_MISC)) {     \
>          fprintf(dfd, fmt, ##__VA_ARGS__);       \
>          fflush(dfd);                            \
>      }                                           \
>  } while (0)
>
>  #define DEBUG_ERROR(fmt, ...) do {              \
> -    if (slirp_debug & DBG_ERROR) {              \
> +    if (unlikely(slirp_debug & DBG_ERROR)) {    \
>          fprintf(dfd, fmt, ##__VA_ARGS__);       \
>          fflush(dfd);                            \
>      }                                           \
> --
> 2.19.1
>
>

With s/unlikely/G_UNLIKELY:
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Samuel Thibault Nov. 22, 2018, 9:13 a.m. UTC | #2
Marc-André Lureau, le jeu. 22 nov. 2018 11:13:51 +0400, a ecrit:
> With s/unlikely/G_UNLIKELY:
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Right, pushed, thanks :)
diff mbox series

Patch

diff --git a/slirp/debug.h b/slirp/debug.h
index ff920f0b87..ad4e07aa01 100644
--- a/slirp/debug.h
+++ b/slirp/debug.h
@@ -17,7 +17,7 @@ 
 extern int slirp_debug;
 
 #define DEBUG_CALL(fmt, ...) do {               \
-    if (slirp_debug & DBG_CALL) {               \
+    if (unlikely(slirp_debug & DBG_CALL)) {     \
         fprintf(dfd, fmt, ##__VA_ARGS__);       \
         fprintf(dfd, "...\n");                  \
         fflush(dfd);                            \
@@ -25,7 +25,7 @@  extern int slirp_debug;
 } while (0)
 
 #define DEBUG_ARG(fmt, ...) do {                \
-    if (slirp_debug & DBG_CALL) {               \
+    if (unlikely(slirp_debug & DBG_CALL)) {     \
         fputc(' ', dfd);                        \
         fprintf(dfd, fmt, ##__VA_ARGS__);       \
         fputc('\n', dfd);                       \
@@ -36,14 +36,14 @@  extern int slirp_debug;
 #define DEBUG_ARGS(fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__)
 
 #define DEBUG_MISC(fmt, ...) do {               \
-    if (slirp_debug & DBG_MISC) {               \
+    if (unlikely(slirp_debug & DBG_MISC)) {     \
         fprintf(dfd, fmt, ##__VA_ARGS__);       \
         fflush(dfd);                            \
     }                                           \
 } while (0)
 
 #define DEBUG_ERROR(fmt, ...) do {              \
-    if (slirp_debug & DBG_ERROR) {              \
+    if (unlikely(slirp_debug & DBG_ERROR)) {    \
         fprintf(dfd, fmt, ##__VA_ARGS__);       \
         fflush(dfd);                            \
     }                                           \