Advertisement
Guest User

Untitled

a guest
Apr 16th, 2016
176
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. https://gcc.gnu.org/ml/gcc-patches/2009-06/msg01249.html
  2. --- gcc/gcc/toplev.c    (revision 148539)
  3. +++ gcc/gcc/toplev.c    (revision 148540)
  4. @@ -532,11 +532,11 @@ read_integral_parameter (const char *p,
  5.    return atoi (p);
  6.  }
  7.  
  8. -/* When compiling with a recent enough GCC, we use the GNU C "extern inline"
  9. -   for floor_log2 and exact_log2; see toplev.h.  That construct, however,
  10. -   conflicts with the ISO C++ One Definition Rule.   */
  11. +#if GCC_VERSION < 3004
  12.  
  13. -#if GCC_VERSION < 3004 || !defined (__cplusplus)
  14. +/* The functions floor_log2 and exact_log2 are defined as inline
  15. +   functions in toplev.h if GCC_VERSION >= 3004.  The definitions here
  16. +   are used for older versions of gcc.  */
  17.  
  18.  /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  19.     If X is 0, return -1.  */
  20. @@ -549,9 +549,6 @@ floor_log2 (unsigned HOST_WIDE_INT x)
  21.    if (x == 0)
  22.      return -1;
  23.  
  24. -#ifdef CLZ_HWI
  25. -  t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
  26. -#else
  27.    if (HOST_BITS_PER_WIDE_INT > 64)
  28.      if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
  29.        t += 64;
  30. @@ -568,7 +565,6 @@ floor_log2 (unsigned HOST_WIDE_INT x)
  31.      t += 2;
  32.    if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
  33.      t += 1;
  34. -#endif
  35.  
  36.    return t;
  37.  }
  38. @@ -581,14 +577,10 @@ exact_log2 (unsigned HOST_WIDE_INT x)
  39.  {
  40.    if (x != (x & -x))
  41.      return -1;
  42. -#ifdef CTZ_HWI
  43. -  return x ? CTZ_HWI (x) : -1;
  44. -#else
  45.    return floor_log2 (x);
  46. -#endif
  47.  }
  48.  
  49. -#endif /*  GCC_VERSION < 3004 || !defined (__cplusplus)  */
  50. +#endif /* GCC_VERSION < 3004 */
  51.  
  52.  /* Handler for fatal signals, such as SIGSEGV.  These are transformed
  53.     into ICE messages, which is much more user friendly.  In case the
  54. --- gcc/gcc/toplev.h    (revision 148539)
  55. +++ gcc/gcc/toplev.h    (revision 148540)
  56. @@ -169,14 +169,17 @@ extern void decode_d_option       (const char
  57.  extern bool fast_math_flags_set_p  (void);
  58.  extern bool fast_math_flags_struct_set_p (struct cl_optimization *);
  59.  
  60. +/* Inline versions of the above for speed.  */
  61. +#if GCC_VERSION < 3004
  62. +
  63.  /* Return log2, or -1 if not exact.  */
  64.  extern int exact_log2                  (unsigned HOST_WIDE_INT);
  65.  
  66.  /* Return floor of log2, with -1 for zero.  */
  67.  extern int floor_log2                  (unsigned HOST_WIDE_INT);
  68.  
  69. -/* Inline versions of the above for speed.  */
  70. -#if GCC_VERSION >= 3004
  71. +#else /* GCC_VERSION >= 3004 */
  72. +
  73.  # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
  74.  #  define CLZ_HWI __builtin_clzl
  75.  #  define CTZ_HWI __builtin_ctzl
  76. @@ -188,17 +191,18 @@ extern int floor_log2                  (
  77.  #  define CTZ_HWI __builtin_ctz
  78.  # endif
  79.  
  80. -extern inline int
  81. +static inline int
  82.  floor_log2 (unsigned HOST_WIDE_INT x)
  83.  {
  84.    return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1;
  85.  }
  86.  
  87. -extern inline int
  88. +static inline int
  89.  exact_log2 (unsigned HOST_WIDE_INT x)
  90.  {
  91.    return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1;
  92.  }
  93. +
  94.  #endif /* GCC_VERSION >= 3004 */
  95.  
  96.  /* Functions used to get and set GCC's notion of in what directory
Advertisement
RAW Paste Data Copied
Advertisement