FreeBSD Bugzilla – Attachment 152798 Details for
Bug 135718
[patch] enhance qsort(3) to properly handle 32-bit aligned data on 64-bit systems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Updated patch by Andrey Chernov
patch-qsort (text/plain), 2.22 KB, created by
Pedro F. Giffuni
on 2015-02-09 14:57:20 UTC
(
hide
)
Description:
Updated patch by Andrey Chernov
Filename:
MIME Type:
Creator:
Pedro F. Giffuni
Created:
2015-02-09 14:57:20 UTC
Size:
2.22 KB
patch
obsolete
>Index: lib/libc/stdlib/qsort.c >=================================================================== >--- lib/libc/stdlib/qsort.c (revision 278225) >+++ lib/libc/stdlib/qsort.c (working copy) >@@ -41,7 +41,7 @@ > typedef int cmp_t(const void *, const void *); > #endif > static inline char *med3(char *, char *, char *, cmp_t *, void *); >-static inline void swapfunc(char *, char *, int, int); >+static inline void swapfunc(char *, char *, int, int, int); > > #define min(a, b) (a) < (b) ? a : b > >@@ -59,29 +59,37 @@ > } while (--i > 0); \ > } > >-#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ >- es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; >+#define SWAPINIT(TYPE, a, es) swaptype_ ## TYPE = \ >+ ((char *)a - (char *)0) % sizeof(TYPE) || \ >+ es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1; > > static inline void >-swapfunc(a, b, n, swaptype) >+swapfunc(a, b, n, swaptype_long, swaptype_int) > char *a, *b; >- int n, swaptype; >+ int n, swaptype_long, swaptype_int; > { >- if(swaptype <= 1) >+ if (swaptype_long <= 1) > swapcode(long, a, b, n) >+ else if (swaptype_int <= 1) >+ swapcode(int, a, b, n) > else > swapcode(char, a, b, n) > } > > #define swap(a, b) \ >- if (swaptype == 0) { \ >+ if (swaptype_long == 0) { \ > long t = *(long *)(a); \ > *(long *)(a) = *(long *)(b); \ > *(long *)(b) = t; \ >+ } else if (swaptype_int == 0) { \ >+ int t = *(int *)(a); \ >+ *(int *)(a) = *(int *)(b); \ >+ *(int *)(b) = t; \ > } else \ >- swapfunc(a, b, es, swaptype) >+ swapfunc(a, b, es, swaptype_long, swaptype_int) > >-#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) >+#define vecswap(a, b, n) \ >+ if ((n) > 0) swapfunc(a, b, n, swaptype_long, swaptype_int) > > #ifdef I_AM_QSORT_R > #define CMP(t, x, y) (cmp((t), (x), (y))) >@@ -113,9 +121,10 @@ > char *pa, *pb, *pc, *pd, *pl, *pm, *pn; > size_t d, r; > int cmp_result; >- int swaptype, swap_cnt; >+ int swaptype_long, swaptype_int, swap_cnt; > >-loop: SWAPINIT(a, es); >+loop: SWAPINIT(long, a, es); >+ SWAPINIT(int, a, es); > swap_cnt = 0; > if (n < 7) { > for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 135718
:
97013
|
148195
| 152798