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 2013/05/20 21:09:52 UTC

[lucy-commits] [08/23] git commit: refs/heads/master - Don't use stdint types in Charmonizer::Probe::Floats

Don't use stdint types in Charmonizer::Probe::Floats

Use a char array to hold the floating point representations of special
values. This is needed for the upcoming changes that add the ability to
create a charmony.h which doesn't define the stdint types.


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

Branch: refs/heads/master
Commit: c029542cedf4ec03d0181ebabbf875b5be5e447c
Parents: e5e6cb9
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat May 18 17:14:46 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon May 20 21:01:12 2013 +0200

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Probe/Floats.c |   37 ++++++++++++++++++-----
 1 files changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/c029542c/charmonizer/src/Charmonizer/Probe/Floats.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Floats.c b/charmonizer/src/Charmonizer/Probe/Floats.c
index b78ec00..6c3969d 100644
--- a/charmonizer/src/Charmonizer/Probe/Floats.c
+++ b/charmonizer/src/Charmonizer/Probe/Floats.c
@@ -27,14 +27,35 @@ chaz_Floats_run(void) {
     chaz_ConfWriter_start_module("Floats");
 
     chaz_ConfWriter_append_conf(
-        "typedef union { uint32_t i; float f; } chy_floatu32;\n"
-        "typedef union { uint64_t i; double d; } chy_floatu64;\n"
-        "static const chy_floatu32 chy_f32inf    = {UINT32_C(0x7f800000)};\n"
-        "static const chy_floatu32 chy_f32neginf = {UINT32_C(0xff800000)};\n"
-        "static const chy_floatu32 chy_f32nan    = {UINT32_C(0x7fc00000)};\n"
-        "static const chy_floatu64 chy_f64inf    = {UINT64_C(0x7ff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64neginf = {UINT64_C(0xfff0000000000000)};\n"
-        "static const chy_floatu64 chy_f64nan    = {UINT64_C(0x7ff8000000000000)};\n"
+        "typedef union { unsigned char c[4]; float f; } chy_floatu32;\n"
+        "typedef union { unsigned char c[8]; double d; } chy_floatu64;\n"
+        "#ifdef CHY_BIG_END\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0x7F, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0xFF, 0x80, 0, 0 } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0x7F, 0xC0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } };\n"
+        "#else /* BIG_END */\n"
+        "static const chy_floatu32 chy_f32inf\n"
+        "    = { { 0, 0, 0x80, 0x7F } };\n"
+        "static const chy_floatu32 chy_f32neginf\n"
+        "    = { { 0, 0, 0x80, 0xFF } };\n"
+        "static const chy_floatu32 chy_f32nan\n"
+        "    = { { 0, 0, 0xC0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64inf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } };\n"
+        "static const chy_floatu64 chy_f64neginf\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } };\n"
+        "static const chy_floatu64 chy_f64nan\n"
+        "    = { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } };\n"
+        "#endif /* BIG_END */\n"
     );
     chaz_ConfWriter_add_def("F32_INF", "(chy_f32inf.f)");
     chaz_ConfWriter_add_def("F32_NEGINF", "(chy_f32neginf.f)");