Re: [PATCH 1/3] compat: add qsort_s()

2016-12-21 Thread René Scharfe
Am 12.12.2016 um 20:57 schrieb Jeff King: On Mon, Dec 12, 2016 at 08:51:14PM +0100, René Scharfe wrote: It's kinda cool to have a bespoke compatibility layer for major platforms, but the more I think about it the less I can answer why we would want that. Safety, reliability and performance

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-12 Thread Jeff King
On Mon, Dec 12, 2016 at 08:51:14PM +0100, René Scharfe wrote: > It's kinda cool to have a bespoke compatibility layer for major platforms, > but the more I think about it the less I can answer why we would want that. > Safety, reliability and performance can't be good reasons -- if our fallback >

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-12 Thread René Scharfe
Am 01.12.2016 um 21:22 schrieb Junio C Hamano: Junio C Hamano writes: Eh, wait. BSD and Microsoft have paramters reordered in the callback comparison function. I suspect that would not fly very well. Hmm. We could do it like this, which may not be too bad. It's kinda

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Junio C Hamano
René Scharfe writes: >> You can hack around it by passing a wrapper callback that flips the >> arguments. Since we have a "void *" data pointer, that would point to a >> struct holding the "real" callback and chaining to the original data >> pointer. >> >> It does incur the cost of

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread René Scharfe
Am 01.12.2016 um 21:19 schrieb Jeff King: On Thu, Dec 01, 2016 at 12:14:42PM -0800, Junio C Hamano wrote: Jeff King writes: To make matters more fun, apparently[1] there are multiple variants of qsort_r with different argument orders. _And_ apparently Microsoft defines

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Jeff King
On Thu, Dec 01, 2016 at 12:22:37PM -0800, Junio C Hamano wrote: > Junio C Hamano writes: > > > Eh, wait. BSD and Microsoft have paramters reordered in the > > callback comparison function. I suspect that would not fly very > > well. > > Hmm. We could do it like this,

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Junio C Hamano
Jeff King writes: > On Thu, Dec 01, 2016 at 12:14:42PM -0800, Junio C Hamano wrote: > >> Eh, wait. BSD and Microsoft have paramters reordered in the >> callback comparison function. I suspect that would not fly very >> well. > > You can hack around it by passing a wrapper

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Junio C Hamano
Junio C Hamano writes: > Eh, wait. BSD and Microsoft have paramters reordered in the > callback comparison function. I suspect that would not fly very > well. Hmm. We could do it like this, which may not be too bad. #if APPLE_QSORT_R struct apple_qsort_adapter {

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Jeff King
On Thu, Dec 01, 2016 at 12:14:42PM -0800, Junio C Hamano wrote: > Jeff King writes: > > > To make matters more fun, apparently[1] there are multiple variants of > > qsort_r with different argument orders. _And_ apparently Microsoft > > defines qsort_s, but it's not quite the same

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Junio C Hamano
Jeff King writes: > To make matters more fun, apparently[1] there are multiple variants of > qsort_r with different argument orders. _And_ apparently Microsoft > defines qsort_s, but it's not quite the same thing. But all of that can > be dealt with by having more specific flags

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread Jeff King
On Thu, Dec 01, 2016 at 05:26:43PM +0100, René Scharfe wrote: > The function qsort_s() was introduced with C11 Annex K; it provides the > ability to pass a context pointer to the comparison function, supports > the convention of using a NULL pointer for an empty array and performs a > few safety

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread René Scharfe
Am 01.12.2016 um 17:26 schrieb René Scharfe: > The function qsort_s() was introduced with C11 Annex K; it provides the > ability to pass a context pointer to the comparison function, supports > the convention of using a NULL pointer for an empty array and performs a > few safety checks. > > Add

[PATCH 1/3] compat: add qsort_s()

2016-12-01 Thread René Scharfe
The function qsort_s() was introduced with C11 Annex K; it provides the ability to pass a context pointer to the comparison function, supports the convention of using a NULL pointer for an empty array and performs a few safety checks. Add an implementation based on compat/qsort.c for platforms