octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 3.1.52 fails to build in hppa/linux


From: John W. Eaton
Subject: Re: 3.1.52 fails to build in hppa/linux
Date: Sun, 22 Feb 2009 20:02:20 -0500

On 22-Feb-2009, Marco Atzeri wrote:

| 
| --- Dom 22/2/09, Jaroslav Hajek  ha scritto:
| 
| > >> And is OCTAVE_INT_USE_LONG_DOUBLE defined in
| > config.h? Do
| > >> you get the
| > >> same error as Rafael? You see, lines 511 and 514
| > in
| > >> oct-inttypes.cc
| > >> are inside an #ifdef OCTAVE_INT_USE_LONG_DOUBLE
| > block.
| > >>
| > >>
| > >>
| > >> --
| > >> RNDr. Jaroslav Hajek
| > >
| > > OCTAVE_INT_USE_LONG_DOUBLE is defined
| > >
| > > same errors from 511 to 516
| > >
| > > Regards
| > > Marco
| > 
| > Whoa, that's wicked. Those lines should not even be
| > compiled, then (I
| > meant, of course, ifndef block in the previous message).
| > Can you maybe
| > try posting just the preprocessor output?
| > 
| > The easiest way to get it is to cd to liboctave/, do
| > make pic/oct-inttypes.o
| > 
| > then copy the command shown to compile, but replace
| > "-c" by "-E" and
| > redirect -o to a suitable file. It will be probably too
| > large to post
| > it on the mailing list.
| 
| uploaded on
| http://matzeri.altervista.org/octave/
| 
| gcc -E output    oct-inttypes.E
| gcc -c logs      oct-inttypes.log-20090222-202140
| full command     oct_int.sh 

Does the attached change avoid the problem for you?  It allows me to
build Octave with GCC and OCTAVE_INT_USE_LONG_DOUBLE undefined.  So
maybe this is a GCC bug because I didn't change any code, I just moved
some function definitions to a header file.  But I did remove some
explicit instantiations, and I'm not sure I fully understand the rules
for instantiating templates, especially when some are explicitly
instantiated and some are not (at least I think that is true for the
classes defined in oct-inttypes.{h,cc}).

I also don't see how these lines could be compiled if
OCTAVE_INT_USE_LONG_DOUBLE is defined.

The lines to define it in config.h are

  #if (SIZEOF_LONG_DOUBLE >= 10) && defined (HAVE_ROUNDL)
  #define OCTAVE_INT_USE_LONG_DOUBLE
  #endif

I think you already said SIZEOF_LONG_DOUBLE is 12.  Is HAVE_ROUNDL
defined on your system?

jwe

diff --git a/liboctave/oct-inttypes.cc b/liboctave/oct-inttypes.cc
--- a/liboctave/oct-inttypes.cc
+++ b/liboctave/oct-inttypes.cc
@@ -51,92 +51,6 @@
 DECLARE_OCTAVE_INT_TYPENAME (uint64_t, "uint64")
 
 #ifndef OCTAVE_INT_USE_LONG_DOUBLE
-
-// Define comparison operators
-
-template <class xop> 
-OCTAVE_API bool 
-octave_int_cmp_op::mop (uint64_t x, double y)
-{
-  static const double xxup = std::numeric_limits<uint64_t>::max ();
-  // This converts to the nearest double. Unless there's an equality, the
-  // result is clear.
-  double xx = x;
-  if (xx != y)
-    return xop::op (xx, y);
-  else
-    {
-      // If equality occured we compare as integers.
-      if (xx == xxup)
-        return xop::gtval;
-      else
-        return xop::op (x, static_cast<uint64_t> (xx));
-    }
-}
-
-template <class xop> 
-OCTAVE_API bool 
-octave_int_cmp_op::mop (int64_t x, double y)
-{
-  static const double xxup = std::numeric_limits<int64_t>::max ();
-  static const double xxlo = std::numeric_limits<int64_t>::min ();
-  // This converts to the nearest double. Unless there's an equality, the
-  // result is clear.
-  double xx = x;
-  if (xx != y)
-    return xop::op (xx, y);
-  else
-    {
-      // If equality occured we compare as integers.
-      if (xx == xxup)
-        return xop::gtval;
-      else if (xx == xxlo)
-        return xop::ltval;
-      else
-        return xop::op (x, static_cast<int64_t> (xx));
-    }
-
-}
-
-// We define double-int operations by reverting the operator
-
-// A trait class reverting the operator
-template <class xop>
-class rev_op
-{
-public:
-  typedef xop op;
-};
-
-#define DEFINE_REVERTED_OPERATOR(OP1,OP2) \
-  template <> \
-  class rev_op<octave_int_cmp_op::OP1> \
-  { \
-  public: \
-    typedef octave_int_cmp_op::OP2 op; \
-  }
-
-DEFINE_REVERTED_OPERATOR(lt,gt);
-DEFINE_REVERTED_OPERATOR(gt,lt);
-DEFINE_REVERTED_OPERATOR(le,ge);
-DEFINE_REVERTED_OPERATOR(ge,le);
-
-template <class xop> 
-OCTAVE_API bool 
-octave_int_cmp_op::mop (double x, uint64_t y)
-{
-  typedef typename rev_op<xop>::op rop;
-  return mop<rop> (y, x);
-}
-
-template <class xop> 
-OCTAVE_API bool 
-octave_int_cmp_op::mop (double x, int64_t y)
-{
-  typedef typename rev_op<xop>::op rop;
-  return mop<rop> (y, x);
-}
-
 
 // Define handlers for int64 multiplication
 
@@ -498,23 +412,6 @@
     return x * (1.0/y);
 }
 
-#define INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP,T1,T2) \
-  template OCTAVE_API bool \
-  octave_int_cmp_op::mop<octave_int_cmp_op::OP> (T1 x, T2 y)
-
-#define INSTANTIATE_INT64_DOUBLE_CMP_OP(OP) \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, double, int64_t); \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, double, uint64_t); \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, int64_t, double); \
-  INSTANTIATE_INT64_DOUBLE_CMP_OP0(OP, uint64_t, double)
-
-INSTANTIATE_INT64_DOUBLE_CMP_OP(lt);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(le);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(gt);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(ge);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(eq);
-INSTANTIATE_INT64_DOUBLE_CMP_OP(ne);
-
 #endif
 
 //template <class T>
diff --git a/liboctave/oct-inttypes.h b/liboctave/oct-inttypes.h
--- a/liboctave/oct-inttypes.h
+++ b/liboctave/oct-inttypes.h
@@ -104,6 +104,8 @@
       static bool op (T, T) { return value; } \
     }
 
+template <class xop> class rev_op;
+
 // Handles non-homogeneous integer comparisons. Avoids doing useless tests.
 class octave_int_cmp_op
 {
@@ -199,14 +201,93 @@
 #undef DEFINE_LONG_DOUBLE_CMP_OP
 
 #else
-  // ... otherwise, use external handlers
-  template <class xop> static OCTAVE_API bool mop (uint64_t, double);
-  template <class xop> static OCTAVE_API bool mop (int64_t, double);
-  template <class xop> static OCTAVE_API bool mop (double, uint64_t);
-  template <class xop> static OCTAVE_API bool mop (double, int64_t);
+
+  template <class xop> 
+  static bool 
+  mop (uint64_t x, double y)
+  {
+    static const double xxup = std::numeric_limits<uint64_t>::max ();
+    // This converts to the nearest double. Unless there's an equality, the
+    // result is clear.
+    double xx = x;
+    if (xx != y)
+      return xop::op (xx, y);
+    else
+      {
+       // If equality occured we compare as integers.
+       if (xx == xxup)
+         return xop::gtval;
+       else
+         return xop::op (x, static_cast<uint64_t> (xx));
+      }
+  }
+
+  template <class xop> 
+  static bool 
+  mop (int64_t x, double y)
+  {
+    static const double xxup = std::numeric_limits<int64_t>::max ();
+    static const double xxlo = std::numeric_limits<int64_t>::min ();
+    // This converts to the nearest double. Unless there's an equality, the
+    // result is clear.
+    double xx = x;
+    if (xx != y)
+      return xop::op (xx, y);
+    else
+      {
+       // If equality occured we compare as integers.
+       if (xx == xxup)
+         return xop::gtval;
+       else if (xx == xxlo)
+         return xop::ltval;
+       else
+         return xop::op (x, static_cast<int64_t> (xx));
+      }
+
+  }
+
+  // We define double-int operations by reverting the operator
+
+  template <class xop> 
+  static bool 
+  mop (double x, uint64_t y)
+  {
+    typedef typename rev_op<xop>::op rop;
+    return mop<rop> (y, x);
+  }
+
+  template <class xop> 
+  static bool 
+  mop (double x, int64_t y)
+  {
+    typedef typename rev_op<xop>::op rop;
+    return mop<rop> (y, x);
+  }
+
 #endif
 
 };
+
+// A trait class reverting the operator
+template <class xop>
+class rev_op
+{
+public:
+  typedef xop op;
+};
+
+#define DEFINE_REVERTED_OPERATOR(OP1,OP2) \
+  template <> \
+  class rev_op<octave_int_cmp_op::OP1> \
+  { \
+  public: \
+    typedef octave_int_cmp_op::OP2 op; \
+  }
+
+DEFINE_REVERTED_OPERATOR(lt,gt);
+DEFINE_REVERTED_OPERATOR(gt,lt);
+DEFINE_REVERTED_OPERATOR(le,ge);
+DEFINE_REVERTED_OPERATOR(ge,le);
 
 // Base integer class. No data, just conversion methods and exception flags.
 template <class T> 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]