[Bug 1786] Make cairo implementation type accessible.
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Tue, 04 Feb 2014 16:09:23 -0800
changeset 10610 540e54a98bc8
parent 10609 4fe4f5afb5f3
child 10611 5390474ca6b7
[Bug 1786] Make cairo implementation type accessible.
src/core/model/cairo-wideint-private.h
src/core/model/cairo-wideint.c
src/core/model/int64x64-cairo.cc
src/core/model/int64x64-cairo.h
src/core/test/int64x64-test-suite.cc
--- a/src/core/model/cairo-wideint-private.h	Tue Feb 04 16:14:44 2014 -0800
+++ b/src/core/model/cairo-wideint-private.h	Tue Feb 04 16:09:23 2014 -0800
@@ -32,9 +32,13 @@
 #ifndef CAIRO_WIDEINT_H
 #define CAIRO_WIDEINT_H
 
-#include "ns3/core-config.h"
+// Adapt to ns-3 environment
 #define cairo_private 
 #define HAVE_UINT64_T 1
+// Implementation tags added below and in cairo-wideint.c:
+// extern const char * cairo_impl64;
+// extern const char * cairo_impl128;
+
 
 /*for compatibility with MacOS and Cygwin*/
 #ifndef HAVE_STDINT_H
@@ -90,6 +94,8 @@
 
 #if !HAVE_UINT64_T
 
+extern const char * cairo_impl64;
+
 typedef struct _cairo_uint64 {
   uint32_t    lo, hi;
 } cairo_uint64_t, cairo_int64_t;
@@ -129,6 +135,8 @@
 
 #else
 
+extern const char * cairo_impl64;
+
 typedef uint64_t    cairo_uint64_t;
 typedef int64_t     cairo_int64_t;
 
@@ -209,6 +217,8 @@
 
 #if !HAVE_UINT128_T
 
+extern const char * cairo_impl128;
+
 typedef struct cairo_uint128 {
   cairo_uint64_t      lo, hi;
 } cairo_uint128_t, cairo_int128_t;
@@ -252,6 +262,8 @@
 
 #else   /* !HAVE_UINT128_T */
 
+extern const char * cairo_impl128;
+
 typedef uint128_t       cairo_uint128_t;
 typedef int128_t        cairo_int128_t;
 
--- a/src/core/model/cairo-wideint.c	Tue Feb 04 16:14:44 2014 -0800
+++ b/src/core/model/cairo-wideint.c	Tue Feb 04 16:09:23 2014 -0800
@@ -32,6 +32,8 @@
 
 #if HAVE_UINT64_T
 
+const char * cairo_impl64 = "uint64_t";
+
 #define _cairo_uint32s_to_uint64(h,l) ((uint64_t) (h) << 32 | (l))
 
 cairo_uquorem64_t
@@ -46,6 +48,8 @@
 
 #else
 
+const char * cairo_impl64 = "uint32_t";
+
 cairo_uint64_t
 _cairo_uint32_to_uint64 (uint32_t i)
 {
@@ -312,6 +316,8 @@
 
 #if HAVE_UINT128_T
 
+const char * cairo_impl128 = "uint128_t";
+
 cairo_uquorem128_t
 _cairo_uint128_divrem (cairo_uint128_t num, cairo_uint128_t den)
 {
@@ -324,6 +330,8 @@
 
 #else
 
+const char * cairo_impl128 = "cairo_uint64_t";
+
 cairo_uint128_t
 _cairo_uint32_to_uint128 (uint32_t i)
 {
--- a/src/core/model/int64x64-cairo.cc	Tue Feb 04 16:14:44 2014 -0800
+++ b/src/core/model/int64x64-cairo.cc	Tue Feb 04 16:09:23 2014 -0800
@@ -17,13 +17,13 @@
  *
  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
  */
-#include "int64x64-cairo.h"
 #include "test.h"
 #include "abort.h"
 #include "assert.h"
 #include "log.h"
 #include <cmath>
 #include <iostream>
+#include "int64x64-cairo.h"
 
 // Note:  Logging in this file is largely avoided due to the
 // number of calls that are made to these functions and the possibility
--- a/src/core/model/int64x64-cairo.h	Tue Feb 04 16:14:44 2014 -0800
+++ b/src/core/model/int64x64-cairo.h	Tue Feb 04 16:09:23 2014 -0800
@@ -2,7 +2,6 @@
 #if !defined(INT64X64_CAIRO_H) && defined (INT64X64_USE_CAIRO) && !defined(PYTHON_SCAN)
 #define INT64X64_CAIRO_H
 
-#include <stdint.h>
 #include <cmath>  // pow
 
 #include "cairo-wideint-private.h"
@@ -62,7 +61,7 @@
   /**
    * Type tag for the underlying implementation.
    *
-   * A few testcases are are sensitive to implementation,
+   * A few testcases are sensitive to implementation,
    * specifically the double implementation.  To handle this,
    * we expose the underlying implementation type here.
    */
--- a/src/core/test/int64x64-test-suite.cc	Tue Feb 04 16:14:44 2014 -0800
+++ b/src/core/test/int64x64-test-suite.cc	Tue Feb 04 16:09:23 2014 -0800
@@ -784,6 +784,44 @@
 }
 
 
+class Int64x64ImplTestCase : public TestCase
+{
+public:
+  Int64x64ImplTestCase ();
+  virtual void DoRun (void);
+};
+
+Int64x64ImplTestCase::Int64x64ImplTestCase ()
+  : TestCase ("Print the implementation")
+{
+}
+
+void
+Int64x64ImplTestCase::DoRun (void)
+{
+  std::cout << std::endl;
+  std::cout << GetParent ()->GetName () << ": " << GetName () << ":"
+	    << std::endl;
+
+  
+  std::cout << "int64x64_t::implementation: ";
+  switch (int64x64_t::implementation)
+    {
+    case (int64x64_t::int128_impl) : std::cout << "int128_impl"; break;
+    case (int64x64_t::cairo_impl)  : std::cout << "cairo_impl";  break;
+    case (int64x64_t::ld_impl)     : std::cout << "ld_impl";     break;
+    default :                        std::cout << "unknown!";    
+    }
+  std::cout << std::endl;
+  
+  if (int64x64_t::implementation == int64x64_t::cairo_impl)
+    {
+      std::cout << "cairo_impl64:  " << cairo_impl64 << std::endl;
+      std::cout << "cairo_impl128: " << cairo_impl128 << std::endl;
+    }
+
+  std::cout << std::endl;
+}
 
 static class Int64x64128TestSuite : public TestSuite
 {
@@ -800,5 +838,6 @@
     AddTestCase (new Int64x64Bug863TestCase (), TestCase::QUICK);
     AddTestCase (new Int64x64Bug1786TestCase (), TestCase::QUICK);
     AddTestCase (new Int64x64InvertTestCase (), TestCase::QUICK);
+    AddTestCase (new Int64x64ImplTestCase (), TestCase::QUICK);
   }
 } g_int64x64TestSuite;