diff --recursive --unified sswf-1.8.0/src/lib/libsswf_util.c++ sswf-1.8.0-new/src/lib/libsswf_util.c++ --- sswf-1.8.0/src/lib/libsswf_util.c++ 2006-11-28 03:08:07.000000000 -0500 +++ sswf-1.8.0-new/src/lib/libsswf_util.c++ 2007-03-20 11:07:26.000000000 -0500 @@ -489,12 +489,12 @@ /** \brief Swap the content of two buffers - * + * Modifications to 64-bit by Fabio A. Correa * The swap() function swaps the content of buffer s1 with buffer s2. * 'size' bytes are swapped. * - * If s1 and s2 both point to a 32 bit value and the size is a multiple - * of 4 bytes, then the swap is done 32 bits at a time. Otherwise the + * If s1 and s2 both point to a 64 bit value and the size is a multiple + * of 8 bytes, then the swap is done 64 bits at a time. Otherwise the * default 8 bits at a time function is used. * * \param s1 One of the buffers to swap @@ -509,7 +509,20 @@ if(size == 0) { return; } - if((size & 3) == 0 && (((int32_t) s1) & 3) == 0 && (((int32_t) s2) & 3) == 0) { + if((sizeof(void*) == 8) && (size & 4) == 0 && ((((int64_t)s1) & 4) == 0) && ((((int64_t)s2) & 4) == 0)) { + int64_t a; + + assert(sizeof(int64_t) == 8, "the swap() function assumes that the sizeof(int64_t) == 8...\n"); + do { + a = * (int64_t *) s1; + * (int64_t *) s1 = * (int64_t *) s2; + * (int64_t *) s2 = a; + s1 = (int64_t *) s1 + 1; + s2 = (int64_t *) s2 + 1; + size -= sizeof(int64_t); + } while(size > 0); + } + else if((sizeof(void*) == 4) && (size & 3) == 0 && (((int32_t) s1) & 3) == 0 && (((int32_t) s2) & 3) == 0) { int32_t a; assert(sizeof(int32_t) == 4, "the swap() function assumes that the sizeof(int32_t) == 4...\n");