--- qsort.c 2009-06-18 13:32:58.000000000 -0500 +++ qsort.c.patched 2009-06-18 14:22:02.000000000 -0500 @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/qsort.c,v 1.15 2008/01/14 09:21:34 das Exp $"); #include +#include #ifdef I_AM_QSORT_R typedef int cmp_t(void *, const void *, const void *); @@ -59,8 +60,15 @@ } while (--i > 0); \ } -#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ +#if LONG_BIT > WORD_BIT +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? ((char *)a - (char *)0) % sizeof(int) || es % \ + sizeof(int) ? 3 : 2 : es == sizeof(long)? 0 : 1; +#else +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; +#endif + static inline void swapfunc(a, b, n, swaptype) @@ -69,6 +77,10 @@ { if(swaptype <= 1) swapcode(long, a, b, n) +#if LONG_BIT > WORD_BIT + else if(swaptype <= 2) + swapcode(int, a, b, n) +#endif else swapcode(char, a, b, n) }