]> sourceware.org Git - systemtap.git/commitdiff
dyninst runtime: make ilog2 evaluable even with -O0
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 17 Mar 2016 20:04:51 +0000 (16:04 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Fri, 18 Mar 2016 16:00:09 +0000 (12:00 -0400)
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

index a748b8afe748c3ba9b2e1d40d4cfc84842ca05a2..b140d1d03461ef7a0c2728e413e039dc6d4a1e9c 100644 (file)
 #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)                   \
  )
 
 
This page took 0.029728 seconds and 5 git commands to generate.