From 0a749081241525dd343a0cdbd964b86816ccacfd Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 17 Mar 2016 16:04:51 -0400 Subject: [PATCH] dyninst runtime: make ilog2 evaluable even with -O0 While debugging a generated dyninst module, it became an obstacle that the __builtin_constant_p-guarded ilog2() macro expression failed down to a ____ilog2_NaN dummy function. With -O0, that function is at least referenced, thus blocking linkage. We ditch the constant-p checking, and provide an abort()ing fallback. --- runtime/dyninst/ilog2.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/runtime/dyninst/ilog2.h b/runtime/dyninst/ilog2.h index a748b8afe..b140d1d03 100644 --- a/runtime/dyninst/ilog2.h +++ b/runtime/dyninst/ilog2.h @@ -16,12 +16,6 @@ #ifndef _STAPDYN_LOG2_H #define _STAPDYN_LOG2_H -/* - * deal with unrepresentable constant logarithms - */ -extern __attribute__((const, noreturn)) -int ____ilog2_NaN(void); - /** * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value * @n - parameter @@ -34,8 +28,7 @@ int ____ilog2_NaN(void); */ #define ilog2(n) \ ( \ - __builtin_constant_p(n) ? ( \ - (n) < 1 ? ____ilog2_NaN() : \ + (n) < 1 ? (abort(),-1) : \ (n) & (1ULL << 63) ? 63 : \ (n) & (1ULL << 62) ? 62 : \ (n) & (1ULL << 61) ? 61 : \ @@ -100,9 +93,7 @@ int ____ilog2_NaN(void); (n) & (1ULL << 2) ? 2 : \ (n) & (1ULL << 1) ? 1 : \ (n) & (1ULL << 0) ? 0 : \ - ____ilog2_NaN() \ - ) : \ - ____ilog2_NaN() \ + (abort(), -1) \ ) -- 2.43.5