This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to implement qsort_r


On Dec  3 20:53, Yaakov Selkowitz wrote:
> I would like to add qsort_r to newlib.  However, there are two distinct
> signatures for this function on different platforms.
> 
> The BSDs and OS X provide:
> 
> void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int
> (*compar)(void *, const void *, const void *));
> 
> http://www.freebsd.org/cgi/man.cgi?format=html&query=qsort%283%29
> 
> Where glibc provides:
> 
> void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void
> *, const void *, void *), void *arg);
> 
> http://man7.org/linux/man-pages/man3/qsort.3.html
> 
> (Personally, I think *neither* of these make sense; the BSD signature with
> the glibc compar typedef would be more consistent in terms of argument
> ordering, but nobody asked my opinion on the matter. :-)
> 
> In any case, the natural place for this is in newlib, but that means we
> either have to choose one (namely glibc, since that is what more software
> will be expecting) or handle this like we do strerror_r.  Any thoughts
> before I spend more time on this?

The implementation is pretty simple either way, so, yes, we could
implement both and let the header provide both as well along the lines
of strerror_r.

Alternatively, are there any known efforts to standarize the API?
Eric, any word from the Austin group in terms of qsort_r?


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Attachment: pgpARe7b6PuaB.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]