git: 97cf82ebe022 - stable/14 - Revise qsort(3) reflect POSIX.1-2024 update.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 22 Dec 2024 07:31:32 UTC
The branch stable/14 has been updated by delphij:
URL: https://cgit.FreeBSD.org/src/commit/?id=97cf82ebe02210daf14801f40164adc98e5197f4
commit 97cf82ebe02210daf14801f40164adc98e5197f4
Author: Xin LI <delphij@FreeBSD.org>
AuthorDate: 2024-10-28 06:15:21 +0000
Commit: Xin LI <delphij@FreeBSD.org>
CommitDate: 2024-12-22 07:30:52 +0000
Revise qsort(3) reflect POSIX.1-2024 update.
Reviewed by: emaste, trasz
Differential Revision: https://reviews.freebsd.org/D47262
(cherry picked from commit 3df1abdfd9c309efbdc7884d6b6f6fe25efcb397)
---
lib/libc/stdlib/qsort.3 | 49 ++++++++++++++++++++++++-------------------------
1 file changed, 24 insertions(+), 25 deletions(-)
diff --git a/lib/libc/stdlib/qsort.3 b/lib/libc/stdlib/qsort.3
index 6e585cecbf48..e2e29e7cf04f 100644
--- a/lib/libc/stdlib/qsort.3
+++ b/lib/libc/stdlib/qsort.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)qsort.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd April 19, 2023
+.Dd October 25, 2024
.Dt QSORT 3
.Os
.Sh NAME
@@ -250,16 +248,8 @@ untrue.
The
.Fn qsort_s
function behaves the same as
-.Fn qsort_r , except that:
-.Bl -dash
-.It
-The order of arguments is different
-.It
-The order of arguments to
-.Fa compar
-is different
-.It
-If
+.Fn qsort_r ,
+except that if
.Fa nmemb
or
.Fa size
@@ -279,7 +269,6 @@ returns an error.
Note that the handler is called before
.Fn qsort_s
returns the error, and the handler function might not return.
-.El
.Sh RETURN VALUES
The
.Fn qsort
@@ -335,16 +324,21 @@ main(void)
.Sh COMPATIBILITY
The order of arguments for the comparison function used with
.Fn qsort_r
-is different from the one used by
-.Fn qsort_s ,
+is historically different from the one used by
+.Fn qsort_s
and the GNU libc implementation of
.Fn qsort_r .
-When porting software written for GNU libc, it is usually possible
-to replace
+However, as of
+.Fx 14.0 ,
+the
.Fn qsort_r
-with
-.Fn qsort_s
-to work around this problem.
+has been updated so that the
+.Fa thunk
+parameter appears last to match
+.St -p1003.1-2024 .
+Both the historical and the updated interfaces are now accepted
+via C11 generic selection and C++ polymorphism,
+but the updated interface is recommended for portable applications.
.Pp
.Fn qsort_s
is part of the
@@ -428,11 +422,15 @@ were unable to allocate memory.
.Sh STANDARDS
The
.Fn qsort
-function
-conforms to
+function conforms to
.St -isoC .
+The
+.Fn qsort_r
+function conforms to
+.St -p1003.1-2024 .
+The
.Fn qsort_s
-conforms to
+function conforms to
.St -isoC-2011
K.3.6.3.2.
.Sh HISTORY
@@ -444,4 +442,5 @@ In
.Fx 14.0 ,
the prototype of
.Fn qsort_r
-was updated to match POSIX.
+was updated to match
+.St -p1003.1-2024 .