Re: [PATCH 1/3] compat: add qsort_s()
- From
Jeff King <peff@peff.net>
- Date
- Dec 1, 2016, 20:26 UTC
- Message-ID
- <20161201202602.sfs6ycmh32ib5ed7@sigill.intra.peff.net>
- In-Reply-To
- <xmqqy3zz8kmq.fsf@gitster.mtv.corp.google.com>
On Thu, Dec 01, 2016 at 12:22:37PM -0800, Junio C Hamano wrote:
Show 7 quoted lines
> Junio C Hamano <gitster@pobox.com> 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.
Heh. Exactly, but I was too lazy to write it out in my other email. :)
The no-cost version would be more like:
#ifdef APPLE_QSORT_R #define DECLARE_CMP(func) int func(void *data, const void *va, const void *vb) #else #define DECLARE_CMP(func) int func(const void *va, const void *vb, void *data) #endif
and then:
DECLARE_CMP(foocmp); ...
DECLARE_CMP(foocmp)
{
const struct foo *a = va, *b = vb;
... etc ...
}-Peff