Date: Wednesday, February 1, 2006 @ 16:26:08
  Author: marc
    Path: /cvsroot/carob/carob/src

Modified: SQLDataSerialization.cpp (1.23 -> 1.24)

Just moved comment about floatToU32Bits() implementation from the call
point inside the code of the function.


--------------------------+
 SQLDataSerialization.cpp |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)


Index: carob/src/SQLDataSerialization.cpp
diff -u carob/src/SQLDataSerialization.cpp:1.23 
carob/src/SQLDataSerialization.cpp:1.24
--- carob/src/SQLDataSerialization.cpp:1.23     Wed Feb  1 13:39:24 2006
+++ carob/src/SQLDataSerialization.cpp  Wed Feb  1 16:26:08 2006
@@ -106,6 +106,14 @@
 uint32_t
 SQLDataSerialization::floatToU32Bits(float f)
 {
+    // "union casting" using { float; uint32_t; } or the simpler:
+    //        return * (uint32_t *) &f;
+    // are "undefined behaviour" because of aliasing rules, alignement issues, 
etc.
+    // See discussion thread "reinterpret_cast to extract bits" thread in 
comp.lang.c++
+    // in may 2004
+    // 
http://groups.google.fr/group/comp.std.c++/browse_frm/thread/272f1199322af93d/7d3368013656d923
+    // The more portable code below should not cost more than a couple
+    // of CPU cycles/converted float
     const unsigned char *bytes = reinterpret_cast<const unsigned char *>(&f);
     uint32_t ires = 0;
     for (int c=0, shift=0; c<4; c++, shift+=8)
@@ -139,11 +147,6 @@
 
   input >> intRead;  // this does call ntohl()
   
-  // "union casting" { float; uint32_t; } is not allowed because of aliasing 
rules
-  // alignement issues, etc.
-  // See discussion thread "reinterpret_cast to extract bits" thread in 
comp.lang.c++
-  // in may 2004
-  // 
http://groups.google.fr/group/comp.std.c++/browse_frm/thread/272f1199322af93d/7d3368013656d923
   if (floats_inverted_endianness)
       // obviously cannot use ntohl() to swap unconditionnally!
       throw NotImplementedException(L"Inverted endianness Not Implemented 
Yet");

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to