vppinfra: add COMPILE_TIME_CONST() macro
Type: improvement
Change-Id: I10d7489f57bc60eb92049962b4e6ea84974f17b8
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index 05af8fe..4629a7d 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -120,6 +120,7 @@
/* Hints to compiler about hot/cold code. */
#define PREDICT_FALSE(x) __builtin_expect((x),0)
#define PREDICT_TRUE(x) __builtin_expect((x),1)
+#define COMPILE_TIME_CONST(x) __builtin_constant_p (x)
/*
* Compiler barrier
diff --git a/src/vppinfra/string.h b/src/vppinfra/string.h
index fb46a0c..76d345e 100644
--- a/src/vppinfra/string.h
+++ b/src/vppinfra/string.h
@@ -143,7 +143,7 @@
* Optimize constant-number-of-bytes calls without asking
* "too many questions for someone from New Jersey"
*/
- if (__builtin_constant_p (n))
+ if (COMPILE_TIME_CONST (n))
{
clib_memcpy_fast (dest, src, n);
return EOK;