You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2017/02/04 17:47:33 UTC

[02/11] lucy-clownfish git commit: Remove U64_TO_DOUBLE macro

Remove U64_TO_DOUBLE macro

It was only needed for MSVC6.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/2b8147d3
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/2b8147d3
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/2b8147d3

Branch: refs/heads/master
Commit: 2b8147d3a728326732cd9d7b50b4154624d7836d
Parents: fa81ff1
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 13:28:36 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 15:10:50 2017 +0100

----------------------------------------------------------------------
 compiler/common/charmonizer.c                  | 33 ---------------------
 compiler/src/CFCBindCore.c                     |  6 ++--
 compiler/src/CFCPerlTypeMap.c                  |  9 ++----
 runtime/common/charmonizer.c                   | 33 ---------------------
 runtime/core/Clownfish/TestHarness/TestUtils.c |  2 +-
 runtime/test/Clownfish/Test/Util/TestMemory.c  |  5 ++--
 6 files changed, 7 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index d53ebc0..895f63a 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -7278,17 +7278,6 @@ static const char chaz_Integers_literal64_code[] =
     CHAZ_QUOTE(      return 0;                             )
     CHAZ_QUOTE(  }                                         );
 
-static const char chaz_Integers_u64_to_double_code[] =
-    CHAZ_QUOTE(  #include <stdio.h>                        )
-    CHAZ_QUOTE(  int main()                                )
-    CHAZ_QUOTE(  {                                         )
-    CHAZ_QUOTE(      unsigned %s int_num = 0;              )
-    CHAZ_QUOTE(      double float_num;                     )
-    CHAZ_QUOTE(      float_num = (double)int_num;          )
-    CHAZ_QUOTE(      printf("%%f\n", float_num);           )
-    CHAZ_QUOTE(      return 0;                             )
-    CHAZ_QUOTE(  }                                         );
-
 void
 chaz_Integers_run(void) {
     char *output;
@@ -7558,28 +7547,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Create macro for converting uint64_t to double. */
-    if (has_64) {
-        /*
-         * Determine whether unsigned 64-bit integers can be converted to
-         * double. Older MSVC versions don't support this conversion.
-         */
-        sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
-        output = chaz_CC_capture_output(code_buf, &output_len);
-        if (output != NULL) {
-            chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
-            free(output);
-        }
-        else {
-            chaz_ConfWriter_add_def(
-                "U64_TO_DOUBLE(num)",
-                "((num) & UINT64_C(0x8000000000000000) ? "
-                "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
-                "9223372036854775808.0 : "
-                "(double)(int64_t)(num))");
-        }
-    }
-
     chaz_ConfWriter_end_module();
 
     /* Integer typedefs. */

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index fc02dd2..0bca5e6 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -613,15 +613,13 @@ S_charmony_string_defines() {
         "#define CFISH_INLINE %s\n"
         "#define CFISH_EXPORT %s\n"
         "#define CFISH_IMPORT %s\n"
-        "#define CFISH_FUNC_MACRO %s\n"
-        "#define CFISH_U64_TO_DOUBLE(x) %s\n";
+        "#define CFISH_FUNC_MACRO %s\n";
     char *defines
         = CFCUtil_sprintf(pattern,
                           XSTRING(CHY_INLINE),
                           XSTRING(CHY_EXPORT),
                           XSTRING(CHY_IMPORT),
-                          XSTRING(CHY_FUNC_MACRO),
-                          XSTRING(CHY_U64_TO_DOUBLE(x)));
+                          XSTRING(CHY_FUNC_MACRO));
 
     return defines;
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlTypeMap.c b/compiler/src/CFCPerlTypeMap.c
index d416284..bc35ad9 100644
--- a/compiler/src/CFCPerlTypeMap.c
+++ b/compiler/src/CFCPerlTypeMap.c
@@ -153,10 +153,7 @@ CFCPerlTypeMap_to_perl(CFCType *type, const char *cf_var) {
             result = CFCUtil_sprintf("newSViv(%s)", cf_var);
         }
         else if (strcmp(specifier, "uint64_t") == 0) {
-            char pattern[] =
-                "sizeof(UV) == 8 ? "
-                "newSVuv((UV)%s) : newSVnv((NV)CFISH_U64_TO_DOUBLE(%s))";
-            result = CFCUtil_sprintf(pattern, cf_var, cf_var);
+            result = CFCUtil_sprintf("newSVuv(%s)", cf_var);
         }
         else if (strcmp(specifier, "uint32_t") == 0) {
             result = CFCUtil_sprintf("newSVuv(%s)", cf_var);
@@ -245,9 +242,7 @@ static const char typemap_output[] =
     "\n"
     "CFISH_BIG_UNSIGNED_INT\n"
     "    if (sizeof(UV) == 8) { sv_setuv($arg, (UV)$var); }\n"
-    "    else {\n"
-    "        sv_setnv($arg, (NV)CFISH_U64_TO_DOUBLE($var));\n"
-    "    }\n"
+    "    else                 { sv_setnv($arg, (NV)$var); }\n"
     "\n";
 
 void

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 840fa5a..64bf01f 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -7278,17 +7278,6 @@ static const char chaz_Integers_literal64_code[] =
     CHAZ_QUOTE(      return 0;                             )
     CHAZ_QUOTE(  }                                         );
 
-static const char chaz_Integers_u64_to_double_code[] =
-    CHAZ_QUOTE(  #include <stdio.h>                        )
-    CHAZ_QUOTE(  int main()                                )
-    CHAZ_QUOTE(  {                                         )
-    CHAZ_QUOTE(      unsigned %s int_num = 0;              )
-    CHAZ_QUOTE(      double float_num;                     )
-    CHAZ_QUOTE(      float_num = (double)int_num;          )
-    CHAZ_QUOTE(      printf("%%f\n", float_num);           )
-    CHAZ_QUOTE(      return 0;                             )
-    CHAZ_QUOTE(  }                                         );
-
 void
 chaz_Integers_run(void) {
     char *output;
@@ -7558,28 +7547,6 @@ chaz_Integers_run(void) {
         }
     }
 
-    /* Create macro for converting uint64_t to double. */
-    if (has_64) {
-        /*
-         * Determine whether unsigned 64-bit integers can be converted to
-         * double. Older MSVC versions don't support this conversion.
-         */
-        sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
-        output = chaz_CC_capture_output(code_buf, &output_len);
-        if (output != NULL) {
-            chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
-            free(output);
-        }
-        else {
-            chaz_ConfWriter_add_def(
-                "U64_TO_DOUBLE(num)",
-                "((num) & UINT64_C(0x8000000000000000) ? "
-                "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
-                "9223372036854775808.0 : "
-                "(double)(int64_t)(num))");
-        }
-    }
-
     chaz_ConfWriter_end_module();
 
     /* Integer typedefs. */

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/runtime/core/Clownfish/TestHarness/TestUtils.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/TestHarness/TestUtils.c b/runtime/core/Clownfish/TestHarness/TestUtils.c
index 38301d3..db94ebf 100644
--- a/runtime/core/Clownfish/TestHarness/TestUtils.c
+++ b/runtime/core/Clownfish/TestHarness/TestUtils.c
@@ -65,7 +65,7 @@ TestUtils_random_f64s(double *buf, size_t count) {
     double *f64s = buf ? buf : (double*)CALLOCATE(count, sizeof(double));
     for (size_t i = 0; i < count; i++) {
         uint64_t num = TestUtils_random_u64();
-        f64s[i] = CHY_U64_TO_DOUBLE(num) / (double)UINT64_MAX;
+        f64s[i] = (double)num / (double)UINT64_MAX;
     }
     return f64s;
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/runtime/test/Clownfish/Test/Util/TestMemory.c
----------------------------------------------------------------------
diff --git a/runtime/test/Clownfish/Test/Util/TestMemory.c b/runtime/test/Clownfish/Test/Util/TestMemory.c
index 8151c72..1083233 100644
--- a/runtime/test/Clownfish/Test/Util/TestMemory.c
+++ b/runtime/test/Clownfish/Test/Util/TestMemory.c
@@ -48,8 +48,7 @@ test_oversize__growth_rate(TestBatchRunner *runner) {
         }
         if (size > 0) {
             growth_count += 1;
-            double growth_rate = CHY_U64_TO_DOUBLE(next_size) /
-                                 CHY_U64_TO_DOUBLE(size);
+            double growth_rate = (double)next_size / (double)size;
             double sum = growth_rate + (growth_count - 1) * average_growth_rate;
             average_growth_rate = sum / growth_count;
             if (average_growth_rate < 1.1) {
@@ -70,7 +69,7 @@ test_oversize__growth_rate(TestBatchRunner *runner) {
 
     for (size_t minimum = 1; minimum < 8; minimum++) {
         uint64_t next_size = Memory_oversize(minimum, sizeof(void*));
-        double growth_rate = CHY_U64_TO_DOUBLE(next_size) / (double)minimum;
+        double growth_rate = (double)next_size / (double)minimum;
         TEST_TRUE(runner, growth_rate > 1.2,
                   "Growth rate is higher for smaller arrays (%u, %.3f)",
                   (unsigned)minimum, growth_rate);