In article <20160827201952.gb6...@netbsd.org>, David Holland <dholland-t...@netbsd.org> wrote: >(Cc: tech-kern because of kheapsort()) > >Some time back I made a set of patches for qsort_r(), that is, a >version of qsort that allows passing a data pointer through, along >with corresponding mergesort_r() and heapsort_r(). > >After some discussion the conclusion was that instead of using thunks >to implement qsort in terms of qsort_r, it was better to implement >both versions in terms of a common internal version. The following >patchset does that. > >heapsort() is used in two places in the kernel as kheapsort(), which >takes an extra argument so that the heapsort code itself doesn't have >to know how to malloc in the kernel. I have done the following: > - add kheapsort_r() > - change the signature of plain kheapsort() to move the extra > argument to a place it is less likely to cause confusion with the > data argument; > - update the callers for the signature change; >but I have not changed either caller to call kheapsort_r >instead. Based on the code, this should probably be done later; then >the plain kheapsort can be removed. > >Note that this set of names and signatures matches what's in Linux. >Apparently FreeBSD did it differently, but there are reasons to prefer >this arrangement of arguments. > >Joerg also says that the _r names are inappropriate because the >originals are reentrant, but I think that's tilting at windmills and >it's more useful to be compatible.
I agree with joerg, but that's water under the bridge... Go for it. christos