changeset 21302:8376de2eaf00

define OCTAVE_HAVE_FAST_INT_OPS in octave-config.h * acinclude.m4 (OCTAVE_FAST_INT_OPS): Define OCTAVE_HAVE_FAST_INT_OPS instead of HAVE_FAST_INT_OPS. * oct-inttypes.cc, oct-inttypes.h: Use new macro name. * mk-octave-config-h.sh: Emit definition of OCTAVE_HAVE_FAST_INT_OPS. * build-env-features.sh: Also include symbols beginning with "OCTAVE_HAVE_".
author John W. Eaton <jwe@octave.org>
date Thu, 18 Feb 2016 16:42:42 -0500
parents 40de9f8f23a6
children 325e04c63f8c
files build-aux/mk-octave-config-h.sh libinterp/build-env-features.sh liboctave/util/oct-inttypes.cc liboctave/util/oct-inttypes.h m4/acinclude.m4
diffstat 5 files changed, 60 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/mk-octave-config-h.sh	Thu Feb 18 13:34:50 2016 -0800
+++ b/build-aux/mk-octave-config-h.sh	Thu Feb 18 16:42:42 2016 -0500
@@ -121,7 +121,7 @@
 #  define OCTAVE_IMPORT
 #endif
 
-#define OCTAVE_API OCTAVE_IMPORT
+n#define OCTAVE_API OCTAVE_IMPORT
 #define OCTINTERP_API OCTAVE_IMPORT
 
 #include <stdint.h>
@@ -151,6 +151,8 @@
 grep "#\(undef\|define\) OCTAVE_ENABLE_BOUNDS_CHECK" $config_h_file
 grep "#\(undef\|define\) OCTAVE_ENABLE_OPENMP" $config_h_file
 
+grep "#\(undef\|define\) OCTAVE_HAVE_FAST_INT_OPS" $config_h_file
+
 if grep "#undef HAVE_DEV_T" $config_h_file > /dev/null; then
   cat << EOF
 
--- a/libinterp/build-env-features.sh	Thu Feb 18 13:34:50 2016 -0800
+++ b/libinterp/build-env-features.sh	Thu Feb 18 16:42:42 2016 -0500
@@ -13,8 +13,8 @@
 cat << EOF
 // DO NOT EDIT!  Generated automatically from $conffile by Make."
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
 #endif
 
 #include "build-env.h"
@@ -36,12 +36,12 @@
 EOF
 
 $AWK \
-  '/#define HAVE_/ {
-     sub (/HAVE_/, "", $2);
+  '/#define \(OCTAVE_\|\)HAVE_/ {
+     sub (/\(OCTAVE_\|\)HAVE_/, "", $2);
      printf ("          m.assign (\"%s\", octave_value (true));\n", $2);
    }
-   /\/\* #undef HAVE_/ {
-     sub (/HAVE_/, "", $3);
+   /\/\* #undef \(OCTAVE_\|\)HAVE_/ {
+     sub (/\(OCTAVE_\|\)HAVE_/, "", $3);
      printf ("          m.assign (\"%s\", octave_value (false));\n", $3);
    } {
    }' $conffile | sort
--- a/liboctave/util/oct-inttypes.cc	Thu Feb 18 13:34:50 2016 -0800
+++ b/liboctave/util/oct-inttypes.cc	Thu Feb 18 16:42:42 2016 -0500
@@ -333,7 +333,7 @@
 
   // Essentially, what we do is compute sign, multiply absolute values
   // (as above) and impose the sign.
-  // FIXME: can we do something faster if we HAVE_FAST_INT_OPS?
+  // FIXME: can we do something faster if we OCTAVE_HAVE_FAST_INT_OPS?
 
   uint64_t usx = octave_int_abs (x);
   uint64_t usy = octave_int_abs (y);
--- a/liboctave/util/oct-inttypes.h	Thu Feb 18 13:34:50 2016 -0800
+++ b/liboctave/util/oct-inttypes.h	Thu Feb 18 16:42:42 2016 -0500
@@ -499,25 +499,31 @@
 
 #endif
 
-// Signed integer arithmetics.
-// Rationale: If HAVE_FAST_INT_OPS is defined, the following conditions
-// should hold:
-// 1. Signed numbers are represented by twos complement
-//    (see <http://en.wikipedia.org/wiki/Two%27s_complement>)
-// 2. static_cast to unsigned int counterpart works like interpreting
-//    the signed bit pattern as unsigned (and is thus zero-cost).
-// 3. Signed addition and subtraction yield the same bit results as unsigned.
-//    (We use casts to prevent optimization interference, so there is no
-//     need for things like -ftrapv).
-// 4. Bit operations on signed integers work like on unsigned integers,
-//    except for the shifts. Shifts are arithmetic.
+// Signed integer arithmetic.
+//
+// Rationale: If OCTAVE_HAVE_FAST_INT_OPS is defined, the following
+// conditions should hold:
+//
+//   1. Signed numbers are represented by twos complement (see
+//      <http://en.wikipedia.org/wiki/Two%27s_complement>)
+//
+//   2. static_cast to unsigned int counterpart works like
+//      interpreting the signed bit pattern as unsigned (and is thus
+//      zero-cost).
+//
+//   3. Signed addition and subtraction yield the same bit results as
+//      unsigned.  (We use casts to prevent optimization interference,
+//      so there is no need for things like -ftrapv).
+//
+//   4. Bit operations on signed integers work like on unsigned
+//      integers, except for the shifts. Shifts are arithmetic.
 //
 // The above conditions are satisfied by most modern platforms. If
-// HAVE_FAST_INT_OPS is defined, bit tricks and wraparound arithmetics are used
-// to avoid conditional jumps as much as possible, thus being friendly to
-// modern pipeline processor architectures.
-// Otherwise, we fall back to a bullet-proof code that only uses assumptions
-// guaranteed by the standard.
+// OCTAVE_HAVE_FAST_INT_OPS is defined, bit tricks and wraparound
+// arithmetics are used to avoid conditional jumps as much as
+// possible, thus being friendly to modern pipeline processor
+// architectures.  Otherwise, we fall back to a bullet-proof code that
+// only uses assumptions guaranteed by the standard.
 
 template <typename T>
 class octave_int_arith_base<T, true> : octave_int_base<T>
@@ -530,7 +536,7 @@
   static T
   __signbit (T x)
   {
-#ifdef HAVE_FAST_INT_OPS
+#if defined (OCTAVE_HAVE_FAST_INT_OPS)
     return static_cast<UT> (x) >> std::numeric_limits<T>::digits;
 #else
     return (x < 0) ? 1 : 0;
@@ -540,7 +546,7 @@
   static T
   abs (T x)
   {
-#ifdef HAVE_FAST_INT_OPS
+#if defined (OCTAVE_HAVE_FAST_INT_OPS)
     // This is close to how GCC does std::abs, but we can't just use std::abs,
     // because its behaviour for INT_MIN is undefined and the compiler could
     // discard the following test.
@@ -589,7 +595,7 @@
   static T
   minus (T x)
   {
-#ifdef HAVE_FAST_INT_OPS
+#if defined (OCTAVE_HAVE_FAST_INT_OPS)
     T y = -x;
     if (y == octave_int_base<T>::min_val ())
       {
@@ -612,7 +618,7 @@
   static T
   add (T x, T y)
   {
-#ifdef HAVE_FAST_INT_OPS
+#if defined (OCTAVE_HAVE_FAST_INT_OPS)
     // The typecasts do nothing, but they are here to prevent an optimizing
     // compiler from interfering. Also, the signed operations on small types
     // actually return int.
@@ -654,7 +660,7 @@
   static T
   sub (T x, T y)
   {
-#ifdef HAVE_FAST_INT_OPS
+#if defined (OCTAVE_HAVE_FAST_INT_OPS)
     // The typecasts do nothing, but they are here to prevent an optimizing
     // compiler from interfering. Also, the signed operations on small types
     // actually return int.
@@ -789,9 +795,9 @@
 
   long double p = static_cast<long double> (x) * static_cast<long double> (y);
 
-  // NOTE: We could maybe do it with a single branch if HAVE_FAST_INT_OPS,
-  // but it would require one more runtime conversion, so the question is
-  // whether it would really be faster.
+  // NOTE: We could maybe do it with a single branch if
+  // OCTAVE_HAVE_FAST_INT_OPS, but it would require one more runtime
+  // conversion, so the question is whether it would really be faster.
   if (p > static_cast<long double> (octave_int_base<int64_t>::max_val ()))
     retval = octave_int_base<int64_t>::max_val ();
   else if (p < static_cast<long double> (octave_int_base<int64_t>::min_val ()))
--- a/m4/acinclude.m4	Thu Feb 18 13:34:50 2016 -0800
+++ b/m4/acinclude.m4	Thu Feb 18 16:42:42 2016 -0500
@@ -1495,18 +1495,24 @@
   fi
 ])
 dnl
-dnl Check whether fast signed integer arithmetics using bit tricks
-dnl can be used in oct-inttypes.h.  Defines HAVE_FAST_INT_OPS if
-dnl the following conditions hold:
-dnl 1. Signed numbers are represented by twos complement
-dnl    (see <http://en.wikipedia.org/wiki/Two%27s_complement>)
-dnl 2. static_cast to unsigned int counterpart works like interpreting
-dnl    the signed bit pattern as unsigned (and is thus zero-cost).
-dnl 3. Signed addition and subtraction yield the same bit results as unsigned.
-dnl    (We use casts to prevent optimization interference, so there is no
-dnl     need for things like -ftrapv).
-dnl 4. Bit operations on signed integers work like on unsigned integers,
-dnl    except for the shifts.  Shifts are arithmetic.
+dnl Check whether fast signed integer arithmetic using bit tricks
+dnl can be used in oct-inttypes.h.
+dnl
+dnl Defines OCTAVE_HAVE_FAST_INT_OPS if the following conditions hold:
+dnl
+dnl   1. Signed numbers are represented by twos complement (see
+dnl      <http://en.wikipedia.org/wiki/Two%27s_complement>)
+dnl
+dnl   2. static_cast to unsigned int counterpart works like
+dnl      interpreting the signed bit pattern as unsigned (and is thus
+dnl      zero-cost). 
+dnl
+dnl   3. Signed addition and subtraction yield the same bit results
+dnl      as unsigned.  (We use casts to prevent optimization
+dnl      interference, so there is no need for things like -ftrapv).
+dnl
+dnl   4. Bit operations on signed integers work like on unsigned
+dnl      integers, except for the shifts.  Shifts are arithmetic.
 dnl
 AC_DEFUN([OCTAVE_FAST_INT_OPS], [
   AC_CACHE_CHECK([whether fast integer arithmetics is usable],
@@ -1563,7 +1569,7 @@
     AC_LANG_POP(C++)
   ])
   if test $octave_cv_fast_int_ops = yes; then
-    AC_DEFINE(HAVE_FAST_INT_OPS, 1,
+    AC_DEFINE(OCTAVE_HAVE_FAST_INT_OPS, 1,
       [Define to 1 if signed integers use two's complement.])
   fi
 ])