qsort.3: document qsort_r
Ben <software-QW8DL1zPdzBaa/[email protected]> wrote on 2011-12-29 20:50:25 GMT:
Quoted 2 lines
Following a discussion on
comp.lang.c, I noticed that glibc'sqsort_ris not documented in the man pages.
Hi Ben,
I addressed this omission in a patch dated 24th October:
http://article.gmane.org/gmane.linux.man/2397
Best regards,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 55128.1325592712-/[email protected]
Mark, Ben,
Mark submitted an initial patch that I have been slow to respond to. Mark, is there anything in Ben's patch that could be included in your patch?
Thanks,
Michael
Quoted 14 lines · Mark R Bannister
Ben <software-QW8DL1zPdzBaa/[email protected]> wrote on 2011-12-29 20:50:25 GMT:
Quoted 2 lines
Following a discussion on
comp.lang.c, I noticed that glibc'sqsort_ris not documented in the man pages.Hi Ben,
I addressed this omission in a patch dated 24th October:
http://article.gmane.org/gmane.linux.man/2397Best regards,
Mark.
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Author of "The Linux Programming Interface"; http://man7.org/tlpi/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAKgNAkhgUnrHnxhOhjL8+tH=Msq_+ASgqvzWAwHc5+TpqOzx7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 5 lines · Michael Kerrisk (man-pages)
Mark, Ben,
Mark submitted an initial patch that I have been slow to respond to. Mark, is there anything in Ben's patch that could be included in your patch?
I included a reference to the feature test macros used to enable qsort_r. That's pretty much the only significant difference. The other changes were to alter the spacing in the SYNOPSIS section to reflect the more usual style for function pointers.
I've attached a new patch that (a) has all of Mark's patch, (b) a reference to the feature test macros, (c) the two spacing changes in the type of the function pointers, and (d) replacing "sorts an array" with "sort and array" which, I think, is better when two functions are being described. I hope that helps. If it doesn't please feel free to ignore it.
Signature · 1 line
Ben.
qsort.3 renamed from qsort.3.orig +42 -8
@@ -28,19 +28,35 @@ .\" Modified 1993-03-29, David Metcalfe .\" Modified 1993-07-24, Rik Faith ([email protected]) .\" 2006-01-15, mtk, Added example program. +.\" Modified 2011-10-24, Mark R. Bannister ([email protected]) +.\" to add qsort_r() +.\" Modified 2012-03-05, Ben Bacarisse ([email protected]) added +.\" reference to feature test macro for qsort_r. .\" -.\" FIXME glibc 2.8 added qsort_r(), which needs to be documented. -.\" -.TH QSORT 3 2009-09-15 "" "Linux Programmer's Manual" +.TH QSORT 3 2012-03-05 "" "Linux Programmer's Manual" .SH NAME -qsort \- sorts an array +qsort, qsort_r \- sort an array .SH SYNOPSIS .nf .B #include <stdlib.h> .sp .BI "void qsort(void *" base ", size_t " nmemb ", size_t " size , -.BI " int(*" compar ")(const void *, const void *));" +.BI " int (*" compar ")(const void *, const void *));" +.sp +.BI "void qsort_r(void *" base ", size_t " nmemb ", size_t " size , +.BI " int (*" compar ")(const void *, const void *, void *)," +.BI " void *" arg ");" .fi +.sp +.in -4n +Feature Test Macro Requirements for glibc (see +.BR feature_test_macros (7)): +.in +.sp +.ad l +.BR qsort_r (): +_GNU_SOURCE +.ad b .SH DESCRIPTION The .BR qsort ()
@@ -58,16 +74,34 @@ less than, equal to, or greater than the second. If two members compare as equal, their order in the sorted array is undefined. +.PP +The +.BR qsort_r () +function is identical to +.BR qsort () +except that the comparison function +.I compar +takes a third argument. A pointer is passed to the comparison function via +.IR arg . +In this way, the comparison function does not need to use global variables to +pass through arbitrary arguments, and is therefore re-entrant and safe to +use in threads. .SH "RETURN VALUE" The .BR qsort () -function returns no value. +and +.BR qsort_r () +functions return no value. .SH "CONFORMING TO" -SVr4, 4.3BSD, C89, C99. +The +.BR qsort () +function conforms to SVr4, 4.3BSD, C89, C99. .SH NOTES Library routines suitable for use as the .I compar -argument include +argument to +.BR qsort () +include .BR alphasort (3) and .BR versionsort (3).
A message that is not in the archive (sent off-list or not yet received): 1330984528.3439.13.camel-P4ps6/[email protected]
Hi Ben,
Quoted 12 lines · Ben
Quoted 5 lines · Michael Kerrisk (man-pages)
Mark, Ben,
Mark submitted an initial patch that I have been slow to respond to. Mark, is there anything in Ben's patch that could be included in your patch?
I included a reference to the feature test macros used to enable
qsort_r. That's pretty much the only significant difference. The other changes were to alter the spacing in the SYNOPSIS section to reflect the more usual style for function pointers.
Quoted 6 lines
I've attached a new patch that (a) has all of Mark's patch, (b) a reference to the feature test macros, (c) the two spacing changes in the type of the function pointers, and (d) replacing "sorts an array" with "sort and array" which, I think, is better when two functions are being described. I hope that helps. If it doesn't please feel free to ignore it.
Ben, thanks for that. I've applied all of the above.
Mark, thanks for the initial patch!
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Author of "The Linux Programming Interface"; http://man7.org/tlpi/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html