summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-08-20 17:19:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-08-20 17:19:30 (GMT)
commitc1131a02e53fd33e0bdf77ffa90c02f6ad93ff8e (patch)
tree07fedb8532f8502d3c1507a92f302dbb7ecd6c7c
parent94ce84440f71233ec37d404c2f03c7bffb997c6e (diff)
downloadhdf5-c1131a02e53fd33e0bdf77ffa90c02f6ad93ff8e.zip
hdf5-c1131a02e53fd33e0bdf77ffa90c02f6ad93ff8e.tar.gz
hdf5-c1131a02e53fd33e0bdf77ffa90c02f6ad93ff8e.tar.bz2
[svn-r4393] Purpose:
Bug Fix Description: Byte swapping routine was core dumping when attempting to convert 0 elements. Solution: Don't try to byte swap when there is nothing to do... :-) Apologies to Kent for my comments on Friday about testing his checkins, especially when it was I who needed to do moer testing. :-/ Platforms tested: Solaris 2.7 (arabica)
-rw-r--r--src/H5Tconv.c1030
1 files changed, 516 insertions, 514 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 1e0b82c..d339266 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -541,536 +541,538 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
buf_stride = buf_stride ? buf_stride : src->size;
/* Optimize for popular sizes */
- switch(md) {
- case 1: /* Swap 2-byte objects */
+ if(nelmts>0) {
+ switch(md) {
+ case 1: /* Swap 2-byte objects */
#ifdef NO_DUFFS_DEVICE
- for (i=0; i<nelmts; i++, buf+=buf_stride) {
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- }
+ for (i=0; i<nelmts; i++, buf+=buf_stride) {
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ }
#else /* NO_DUFFS_DEVICE */
-{
- size_t duff_count = (nelmts + 7) / 8;
-
- switch (nelmts % 8)
- {
- case 0:
- do
- {
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 7:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 6:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 5:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 4:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 3:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 2:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- case 1:
- /* Swap the byte pair */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
- buf+=buf_stride;
- }
- while (--duff_count > 0);
- }
-}
+ {
+ size_t duff_count = (nelmts + 7) / 8;
+
+ switch ((long)(nelmts % 8))
+ {
+ case 0:
+ do
+ {
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 7:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 6:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 5:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 4:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 3:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 2:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ case 1:
+ /* Swap the byte pair */
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ buf+=buf_stride;
+ }
+ while (--duff_count > 0);
+ }
+ }
#endif /* NO_DUFFS_DEVICE */
- break;
+ break;
- case 2: /* Swap 4-byte objects */
+ case 2: /* Swap 4-byte objects */
#ifdef NO_DUFFS_DEVICE
- for (i=0; i<nelmts; i++, buf+=buf_stride) {
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
- }
+ for (i=0; i<nelmts; i++, buf+=buf_stride) {
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+ }
#else /* NO_DUFFS_DEVICE */
-{
- size_t duff_count = (nelmts + 7) / 8;
-
- switch (nelmts % 8)
- {
- case 0:
- do
- {
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 7:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 6:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 5:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 4:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 3:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 2:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 1:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[3];
- buf[3] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[1];
- buf[1] = buf[2];
- buf[2] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- }
- while (--duff_count > 0);
- }
-}
+ {
+ size_t duff_count = (nelmts + 7) / 8;
+
+ switch ((long)(nelmts % 8))
+ {
+ case 0:
+ do
+ {
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 7:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 6:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 5:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 4:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 3:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 2:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 1:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[3];
+ buf[3] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[2];
+ buf[2] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ }
+ while (--duff_count > 0);
+ }
+ }
#endif /* NO_DUFFS_DEVICE */
- break;
+ break;
- case 4: /* Swap 8-byte objects */
+ case 4: /* Swap 8-byte objects */
#ifdef NO_DUFFS_DEVICE
- for (i=0; i<nelmts; i++, buf+=buf_stride) {
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
- }
+ for (i=0; i<nelmts; i++, buf+=buf_stride) {
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+ }
#else /* NO_DUFFS_DEVICE */
-{
- size_t duff_count = (nelmts + 7) / 8;
-
- switch (nelmts % 8)
- {
- case 0:
- do
- {
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 7:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 6:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 5:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 4:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 3:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 2:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 1:
- /* Swap the outer pair of bytes */
- tmp = buf[0];
- buf[0] = buf[7];
- buf[7] = tmp;
-
- /* Swap the next-outer pair of bytes */
- tmp = buf[1];
- buf[1] = buf[6];
- buf[6] = tmp;
-
- /* Swap the next-next-outer pair of bytes */
- tmp = buf[2];
- buf[2] = buf[5];
- buf[5] = tmp;
-
- /* Swap the inner pair of bytes */
- tmp = buf[3];
- buf[3] = buf[4];
- buf[4] = tmp;
-
- /* Advance the pointer */
- buf+=buf_stride;
- }
- while (--duff_count > 0);
- }
-}
+ {
+ size_t duff_count = (nelmts + 7) / 8;
+
+ switch ((long)(nelmts % 8))
+ {
+ case 0:
+ do
+ {
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 7:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 6:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 5:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 4:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 3:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 2:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 1:
+ /* Swap the outer pair of bytes */
+ tmp = buf[0];
+ buf[0] = buf[7];
+ buf[7] = tmp;
+
+ /* Swap the next-outer pair of bytes */
+ tmp = buf[1];
+ buf[1] = buf[6];
+ buf[6] = tmp;
+
+ /* Swap the next-next-outer pair of bytes */
+ tmp = buf[2];
+ buf[2] = buf[5];
+ buf[5] = tmp;
+
+ /* Swap the inner pair of bytes */
+ tmp = buf[3];
+ buf[3] = buf[4];
+ buf[4] = tmp;
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ }
+ while (--duff_count > 0);
+ }
+ }
#endif /* NO_DUFFS_DEVICE */
- break;
+ break;
- default: /* Swap n-byte objects */
+ default: /* Swap n-byte objects */
#ifdef NO_DUFFS_DEVICE
- for (i=0; i<nelmts; i++, buf+=buf_stride) {
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
+ for (i=0; i<nelmts; i++, buf+=buf_stride) {
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
}
- }
#else /* NO_DUFFS_DEVICE */
-{
- size_t duff_count = (nelmts + 7) / 8;
-
- switch (nelmts % 8)
- {
- case 0:
- do
- {
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 7:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 6:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 5:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 4:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 3:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 2:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- case 1:
- /* Generic byte-swapping loop */
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
-
- /* Advance the pointer */
- buf+=buf_stride;
- }
- while (--duff_count > 0);
- }
-}
+ {
+ size_t duff_count = (nelmts + 7) / 8;
+
+ switch ((long)(nelmts % 8))
+ {
+ case 0:
+ do
+ {
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 7:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 6:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 5:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 4:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 3:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 2:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ case 1:
+ /* Generic byte-swapping loop */
+ for (j=0; j<md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
+ }
+
+ /* Advance the pointer */
+ buf+=buf_stride;
+ }
+ while (--duff_count > 0);
+ }
+ }
#endif /* NO_DUFFS_DEVICE */
- break;
- } /* end switch */
+ break;
+ } /* end switch */
+ } /* end if */
break;
case H5T_CONV_FREE: