Imported Upstream version 0.6.27
[platform/upstream/libsolv.git] / src / qsort_r.c
index c4bc6d2..d49049a 100644 (file)
@@ -3,6 +3,8 @@
  * argument ordering
  */
 
+/* FIXME: should use mergesort instead */
+
 /*-
  * Copyright (c) 1992, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -45,7 +47,9 @@ typedef int            cmp_t(const void *, const void *, void *);
 static inline char     *med3(char *, char *, char *, cmp_t *, void *);
 static inline void      swapfunc(char *, char *, int, int);
 
+#ifndef min
 #define min(a, b)      (a) < (b) ? a : b
+#endif
 
 /*
  * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
@@ -107,7 +111,7 @@ loop:       SWAPINIT(a, es);
        swap_cnt = 0;
        if (n < 7) {
                for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
-                       for (pl = pm; 
+                       for (pl = pm;
                             pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
                             pl -= es)
                                swap(pl, pl - es);
@@ -155,7 +159,7 @@ loop:       SWAPINIT(a, es);
        }
        if (swap_cnt == 0) {  /* Switch to insertion sort */
                for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
-                       for (pl = pm; 
+                       for (pl = pm;
                             pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
                             pl -= es)
                                swap(pl, pl - es);