22 #include "mysys_priv.h"
23 #include <myisampack.h>
37 static int native_compare(
size_t *length,
unsigned char **a,
unsigned char **b)
39 return memcmp(*a, *b, *length);
44 static int ptr_compare(
size_t *compare_length, uchar **a, uchar **b);
45 static int ptr_compare_0(
size_t *compare_length, uchar **a, uchar **b);
46 static int ptr_compare_1(
size_t *compare_length, uchar **a, uchar **b);
47 static int ptr_compare_2(
size_t *compare_length, uchar **a, uchar **b);
48 static int ptr_compare_3(
size_t *compare_length, uchar **a, uchar **b);
54 qsort2_cmp get_ptr_compare (
size_t size __attribute__((unused)))
56 return (qsort2_cmp) native_compare;
59 qsort2_cmp get_ptr_compare (
size_t size)
62 return (qsort2_cmp) ptr_compare;
64 case 0:
return (qsort2_cmp) ptr_compare_0;
65 case 1:
return (qsort2_cmp) ptr_compare_1;
66 case 2:
return (qsort2_cmp) ptr_compare_2;
67 case 3:
return (qsort2_cmp) ptr_compare_3;
79 #define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N]
83 static int ptr_compare(
size_t *compare_length, uchar **a, uchar **b)
85 reg3
int length= *compare_length;
86 reg1 uchar *first,*last;
91 if (*first++ != *last++)
92 return (
int) first[-1] - (int) last[-1];
94 return (
int) first[0] - (int) last[0];
98 static int ptr_compare_0(
size_t *compare_length,uchar **a, uchar **b)
100 reg3
int length= *compare_length;
101 reg1 uchar *first,*last;
119 static int ptr_compare_1(
size_t *compare_length,uchar **a, uchar **b)
121 reg3
int length= *compare_length-1;
122 reg1 uchar *first,*last;
124 first= *a+1; last= *b+1;
140 static int ptr_compare_2(
size_t *compare_length,uchar **a, uchar **b)
142 reg3
int length= *compare_length-2;
143 reg1 uchar *first,*last;
145 first= *a +2 ; last= *b +2;
162 static int ptr_compare_3(
size_t *compare_length,uchar **a, uchar **b)
164 reg3
int length= *compare_length-3;
165 reg1 uchar *first,*last;
167 first= *a +3 ; last= *b +3;
187 void my_store_ptr(uchar *buff,
size_t pack_length, my_off_t pos)
189 switch (pack_length) {
191 case 8: mi_int8store(buff,pos);
break;
192 case 7: mi_int7store(buff,pos);
break;
193 case 6: mi_int6store(buff,pos);
break;
194 case 5: mi_int5store(buff,pos);
break;
196 case 4: mi_int4store(buff,pos);
break;
197 case 3: mi_int3store(buff,pos);
break;
198 case 2: mi_int2store(buff,pos);
break;
199 case 1: buff[0]= (uchar) pos;
break;
200 default: DBUG_ASSERT(0);
205 my_off_t my_get_ptr(uchar *ptr,
size_t pack_length)
208 switch (pack_length) {
210 case 8: pos= (my_off_t) mi_uint8korr(ptr);
break;
211 case 7: pos= (my_off_t) mi_uint7korr(ptr);
break;
212 case 6: pos= (my_off_t) mi_uint6korr(ptr);
break;
213 case 5: pos= (my_off_t) mi_uint5korr(ptr);
break;
215 case 4: pos= (my_off_t) mi_uint4korr(ptr);
break;
216 case 3: pos= (my_off_t) mi_uint3korr(ptr);
break;
217 case 2: pos= (my_off_t) mi_uint2korr(ptr);
break;
218 case 1: pos= (my_off_t) *(uchar*) ptr;
break;
219 default: DBUG_ASSERT(0);
return 0;