123 char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
124 size_t d, r, swap_cnt;
129 if(depth_limit-- <= 0)
142 for(pm = (
char*)a + es; pm < (
char*)a + n * es; pm += es)
144 for(pl = pm; pl > (
char*)a &&
CMP(
thunk, pl - es, pl) > 0; pl -= es)
151 pm = (
char*)a + (n / 2) * es;
155 pn = (
char*)a + (n - 1) * es;
166 pa = pb = (
char*)a + es;
168 pc = pd = (
char*)a + (n - 1) * es;
171 while(pb <= pc && (cmp_result =
CMP(
thunk, pb, a)) <= 0)
181 while(pb <= pc && (cmp_result =
CMP(
thunk, pc, a)) >= 0)
201 pn = (
char*)a + n * es;
202 r =
min((uintptr_t)pa - (uintptr_t)a, (uintptr_t)pb - (uintptr_t)pa);
204 r =
min((uintptr_t)pd - (uintptr_t)pc, (uintptr_t)pn - (uintptr_t)pd - (uintptr_t)es);
210 for(pm = (
char*)a + es; pm < (
char*)a + n * es; pm += es)
212 for(pl = pm; pl > (
char*)a &&
CMP(
thunk, pl - es, pl) > 0; pl -= es)
225 if((r = (uintptr_t)pb - (uintptr_t)pa) > es)
233 if((r = (uintptr_t)pd - (uintptr_t)pc) > es)
static char * med3(char *a, char *b, char *c, cmp_t *cmd, void *thunk) __attribute__((always_inline))
int cmp(Bigint *a, Bigint *b)
int heapsort(void *vbase, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
Sorts the given array pointed to by vbase in ascending order.
static void _qsort(void *a, size_t n, size_t es, #define thunk cmp_t *cmp, int depth_limit)
int heapsort_r(void *vbase, size_t nmemb, size_t size, void *thunk, int(*compar)(void *, const void *, const void *))
Sorts the given array pointed to by vbase in ascending order.