Changeset: 9cabfad252e9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9cabfad252e9
Modified Files:
        clients/examples/C/bincopydata.c
        common/utils/copybinary.h
Branch: copybinary
Log Message:

Also byteswap floating point testdata


diffs (47 lines):

diff --git a/clients/examples/C/bincopydata.c b/clients/examples/C/bincopydata.c
--- a/clients/examples/C/bincopydata.c
+++ b/clients/examples/C/bincopydata.c
@@ -149,7 +149,8 @@ gen_floats(FILE *f, bool byteswap, long 
        for (long i = 0; i < nrecs; i++) {
                float fl = (float)i;
                fl += 0.5;
-               (void)byteswap;
+               if (byteswap)
+                       COPY_BINARY_CONVERT32(fl);
                fwrite(&fl, sizeof(fl), 1, f);
        }
 }
@@ -162,7 +163,8 @@ gen_doubles(FILE *f, bool byteswap, long
        for (long i = 0; i < nrecs; i++) {
                double fl = (double)i;
                fl += 0.5;
-               (void)byteswap;
+               if (byteswap)
+                       COPY_BINARY_CONVERT64(fl);
                fwrite(&fl, sizeof(fl), 1, f);
        }
 }
diff --git a/common/utils/copybinary.h b/common/utils/copybinary.h
--- a/common/utils/copybinary.h
+++ b/common/utils/copybinary.h
@@ -78,16 +78,16 @@ typedef struct {
 // This makes it possible to also convert timestamps.
 
 #define COPY_BINARY_CONVERT16(lhs) \
-       do { (lhs) = COPY_BINARY_BYTESWAP16(lhs); } while (0)
+       do { *(uint16_t*)&(lhs) = COPY_BINARY_BYTESWAP16(lhs); } while (0)
 
 #define COPY_BINARY_CONVERT32(lhs) \
-       do { (lhs) = COPY_BINARY_BYTESWAP32(lhs); } while (0)
+       do { *(uint32_t*)&(lhs) = COPY_BINARY_BYTESWAP32(lhs); } while (0)
 
 #define COPY_BINARY_CONVERT64(lhs) \
-       do { (lhs) = COPY_BINARY_BYTESWAP64(lhs); } while (0)
+       do { *(uint64_t*)&(lhs) = COPY_BINARY_BYTESWAP64(lhs); } while (0)
 
 #define COPY_BINARY_CONVERT128(lhs) \
-       do { (lhs) = COPY_BINARY_BYTESWAP128(lhs); } while (0)
+       do { *(uhge*)&(lhs) = COPY_BINARY_BYTESWAP128(lhs); } while (0)
 
 #define COPY_BINARY_CONVERT_DATE(d) \
        do { COPY_BINARY_CONVERT16((d).year); } while (0)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to