branches/zip:

Change mach_read_int_type() to return an integer type (ullint) instead
of array of bytes that later needs to be converted to an appropriate
integer type.

Approved by:	Sunny
This commit is contained in:
vasil 2007-10-25 11:45:11 +00:00
parent 51f09f6447
commit 806d940575
3 changed files with 27 additions and 50 deletions

View file

@ -368,10 +368,10 @@ mach_write_to_2_little_endian(
Convert integral type from storage byte order (big endian) to
host byte order. */
UNIV_INLINE
void
ullint
mach_read_int_type(
/*===============*/
byte* dest, /* out: where to write */
/* out: integer value */
const byte* src, /* in: where to read from */
ulint len, /* in: length of src */
ibool unsigned_type); /* in: signed or unsigned flag */

View file

@ -730,33 +730,39 @@ mach_write_to_2_little_endian(
Convert integral type from storage byte order (big endian) to
host byte order. */
UNIV_INLINE
void
ullint
mach_read_int_type(
/*===============*/
byte* dest, /* out: where to write */
/* out: integer value */
const byte* src, /* in: where to read from */
ulint len, /* in: length of src */
ibool unsigned_type) /* in: signed or unsigned flag */
{
#ifdef WORDS_BIGENDIAN
memcpy(dest, src, len);
/* XXX this can be optimized on big-endian machines */
if (!unsigned_type) {
dest[0] ^= 128;
}
#else
byte* ptr;
ullint ret;
uint i;
/* Convert integer data from Innobase to a little-endian format,
sign bit restored to normal. */
if (unsigned_type || (src[0] & 0x80)) {
for (ptr = dest + len; ptr != dest; ++src) {
--ptr;
*ptr = *src;
ret = 0x0000000000000000ULL;
} else {
ret = 0xFFFFFFFFFFFFFF00ULL;
}
if (!unsigned_type) {
dest[len - 1] ^= 128;
if (unsigned_type) {
ret |= src[0];
} else {
ret |= src[0] ^ 0x80;
}
#endif
for (i = 1; i < len; i++) {
ret <<= 8;
ret |= src[i];
}
return(ret);
}

View file

@ -4616,8 +4616,6 @@ row_search_autoinc_read_column(
const byte* data;
ib_longlong value;
mem_heap_t* heap = NULL;
/* Our requirement is that dest should be word aligned. */
byte dest[sizeof(value)];
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
@ -4635,35 +4633,8 @@ row_search_autoinc_read_column(
ut_a(len != UNIV_SQL_NULL);
ut_a(len <= sizeof value);
mach_read_int_type(dest, data, len, unsigned_type);
/* The assumption here is that the AUTOINC value can't be negative
and that dest is word aligned. */
switch (len) {
case 8:
value = *(ib_longlong*) dest;
break;
case 4:
value = *(ib_uint32_t*) dest;
break;
case 3:
value = *(ib_uint32_t*) dest;
value &= 0xFFFFFF;
break;
case 2:
value = *(uint16 *) dest;
break;
case 1:
value = *dest;
break;
default:
ut_error;
}
/* we assume AUTOINC value cannot be negative */
value = (ib_longlong) mach_read_int_type(data, len, unsigned_type);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);