* Remove ill-considered "swap_cnt" switch to insertion sort,
* in favor of a simple check for presorted input.
*
- * CAUTION: if you change this file, see also qsort.c
+ * CAUTION: if you change this file, see also qsort.c, gen_qsort_tuple.pl
*
- * $PostgreSQL: pgsql/src/port/qsort_arg.c,v 1.1 2006/10/03 22:18:23 tgl Exp $
+ * src/port/qsort_arg.c
*/
/* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */
static char *med3(char *a, char *b, char *c,
- qsort_arg_comparator cmp, void *arg);
+ qsort_arg_comparator cmp, void *arg);
static void swapfunc(char *, char *, size_t, int);
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
/*
* Qsort routine based on J. L. Bentley and M. D. McIlroy,
* "Engineering a sort function",
(es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1;
static void
-swapfunc(a, b, n, swaptype)
-char *a,
- *b;
-size_t n;
-int swaptype;
+swapfunc(char *a, char *b, size_t n, int swaptype)
{
if (swaptype <= 1)
swapcode(long, a, b, n);
pc -= es;
}
pn = (char *) a + n * es;
- r = min(pa - (char *) a, pb - pa);
+ r = Min(pa - (char *) a, pb - pa);
vecswap(a, pb - r, r);
- r = min(pd - pc, pn - pd - es);
+ r = Min(pd - pc, pn - pd - es);
vecswap(pb, pn - r, r);
if ((r = pb - pa) > es)
qsort_arg(a, r / es, es, cmp, arg);