lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [05/15] git commit: refs/heads/install-c-library - Don't use stdint types in Charmonizer::Probe::Floats
Date Sat, 18 May 2013 19:23:50 GMT
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/4d150817
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4d150817
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4d150817

Branch: refs/heads/install-c-library
Commit: 4d15081723a18710f4c5685f9f9aa621c1107759
Parents: 35d8cc9
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat May 18 17:14:46 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat May 18 17:19:51 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/4d150817/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)");


Mime
View raw message