[njs] The nxt_expect() macro.

Valentin Bartenev vbart at nginx.com
Mon Dec 19 11:34:05 UTC 2016


details:   http://hg.nginx.org/njs/rev/a76d7066a117
branches:  
changeset: 287:a76d7066a117
user:      Valentin Bartenev <vbart at nginx.com>
date:      Mon Dec 19 14:19:43 2016 +0300
description:
The nxt_expect() macro.

diffstat:

 nxt/nxt_clang.h |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 631a3be91d22 -r a76d7066a117 nxt/nxt_clang.h
--- a/nxt/nxt_clang.h	Fri Dec 16 17:52:15 2016 +0300
+++ b/nxt/nxt_clang.h	Mon Dec 19 14:19:43 2016 +0300
@@ -27,10 +27,12 @@
 
 
 #if (NXT_HAVE_BUILTIN_EXPECT)
-#define nxt_fast_path(x)   __builtin_expect((long) (x), 1)
-#define nxt_slow_path(x)   __builtin_expect((long) (x), 0)
+#define nxt_expect(c, x)   __builtin_expect((long) (x), (c))
+#define nxt_fast_path(x)   nxt_expect(1, x)
+#define nxt_slow_path(x)   nxt_expect(0, x)
 
 #else
+#define nxt_expect(c, x)   (x)
 #define nxt_fast_path(x)   (x)
 #define nxt_slow_path(x)   (x)
 #endif


More information about the nginx-devel mailing list