30#define MID(lo, hi) (lo + ((hi - lo) >> 1))
53msort (
void *array,
void *buf,
size_t low,
size_t high,
size_t size,
54 int (* compare) (
const void *,
const void *,
void *),
void *
arg)
56 char *a1, *al, *am, *ah, *ls, *hs, *lo, *hi, *
b;
60 mid =
MID (low, high);
68 ah = ((
char *) array) + ((high + 1) *
size);
69 am = ((
char *) array) + ((mid + 1) *
size);
70 a1 = al = ((
char *) array) + (low *
size);
80 if (lo > al || hi > am) {
85 while (lo < am && compare (lo, hi,
arg) <= 0)
98 while (hi < ah && compare (hi, lo,
arg) < 0)
102 memcpy (
b, ls, lo - ls);
107 memcpy (
b, hs, hi - hs);
111 memcpy (
b, ls, lo - ls);
116 memcpy (a1, buf, copied);
125 memcpy (
b, lo, am - lo);
129 memcpy (a1, buf, copied);
134 int (* compare) (
const void *,
const void *,
void *),
void *
arg)
141 if (!(tmp = malloc (nmemb *
size))) {
154 int (*
cmp)(
const void *,
const void *,
void *
arg),
void *
arg)
int GMPQAPI() cmp(mp_rat op1, mp_rat op2)
static int MergeSort(void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *, void *), void *arg)
int isl_sort(void *const pbase, size_t total_elems, size_t size, int(*cmp)(const void *, const void *, void *arg), void *arg)
static void msort(void *array, void *buf, size_t low, size_t high, size_t size, int(*compare)(const void *, const void *, void *), void *arg)