Lines 489-500
Link Here
|
489 |
|
489 |
|
490 |
|
490 |
|
491 |
/** \brief Swap the content of two buffers |
491 |
/** \brief Swap the content of two buffers |
492 |
* |
492 |
* Modifications to 64-bit by Fabio A. Correa <facorread at gmail> |
493 |
* The swap() function swaps the content of buffer s1 with buffer s2. |
493 |
* The swap() function swaps the content of buffer s1 with buffer s2. |
494 |
* 'size' bytes are swapped. |
494 |
* 'size' bytes are swapped. |
495 |
* |
495 |
* |
496 |
* If s1 and s2 both point to a 32 bit value and the size is a multiple |
496 |
* If s1 and s2 both point to a 64 bit value and the size is a multiple |
497 |
* of 4 bytes, then the swap is done 32 bits at a time. Otherwise the |
497 |
* of 8 bytes, then the swap is done 64 bits at a time. Otherwise the |
498 |
* default 8 bits at a time function is used. |
498 |
* default 8 bits at a time function is used. |
499 |
* |
499 |
* |
500 |
* \param s1 One of the buffers to swap |
500 |
* \param s1 One of the buffers to swap |
Lines 509-515
Link Here
|
509 |
if(size == 0) { |
509 |
if(size == 0) { |
510 |
return; |
510 |
return; |
511 |
} |
511 |
} |
512 |
if((size & 3) == 0 && (((int32_t) s1) & 3) == 0 && (((int32_t) s2) & 3) == 0) { |
512 |
if((sizeof(void*) == 8) && (size & 4) == 0 && ((((int64_t)s1) & 4) == 0) && ((((int64_t)s2) & 4) == 0)) { |
|
|
513 |
int64_t a; |
514 |
|
515 |
assert(sizeof(int64_t) == 8, "the swap() function assumes that the sizeof(int64_t) == 8...\n"); |
516 |
do { |
517 |
a = * (int64_t *) s1; |
518 |
* (int64_t *) s1 = * (int64_t *) s2; |
519 |
* (int64_t *) s2 = a; |
520 |
s1 = (int64_t *) s1 + 1; |
521 |
s2 = (int64_t *) s2 + 1; |
522 |
size -= sizeof(int64_t); |
523 |
} while(size > 0); |
524 |
} |
525 |
else if((sizeof(void*) == 4) && (size & 3) == 0 && (((int32_t) s1) & 3) == 0 && (((int32_t) s2) & 3) == 0) { |
513 |
int32_t a; |
526 |
int32_t a; |
514 |
|
527 |
|
515 |
assert(sizeof(int32_t) == 4, "the swap() function assumes that the sizeof(int32_t) == 4...\n"); |
528 |
assert(sizeof(int32_t) == 4, "the swap() function assumes that the sizeof(int32_t) == 4...\n"); |