From nobody Sun Dec 22 07:31:32 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YGCWm6tHsz5jC97; Sun, 22 Dec 2024 07:31:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YGCWm6R3Pz4ZNK; Sun, 22 Dec 2024 07:31:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734852692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C4K9+/1k266WP05HjmlZHjE1Ze6T362GBXv7wRaK008=; b=MMb9R6Vz0VRRx69GRpLZEmevN88vmeLhgHtSjJmmg06aQVczRS/zbuHeYTP2++GI2XieoB E3ifraCa64kb2T9/4E8S68fIcp4TScx+pGU4B43NPjT+NZngFqv+0BrP1bPMFN0Ll3Wf9N O+7WQ/S64sed3XQTp80W3o8cRAjogDPwInt91ggKjBUohqt2CHvdVzC7Sal/mFA9KW4UcI KArx2wUL2Jko/tkwQRLKzqB+APfZUEcFPJ5zjzYSF80FWYBGDjudvVlXR8izZ1sCcJJfji N8ts4xCszJyxXeQtU18W0eDaHpgFo8QaY2Y2CA1afaKdo+mcEiu0ObZpGYAIOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734852692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C4K9+/1k266WP05HjmlZHjE1Ze6T362GBXv7wRaK008=; b=OsWDQD02J6h1wjCJrsZC4WL5Bo22SyqfdoRbqXhHxa4z2SyRTs7QW7mQ9erWCjhiIRF8Db I68G79uVOsmbrHXjDqJg5GizJpcCipMxQLyvyg62HC1mB/Lx7iMwgApwTuzsjciSug3zh1 7b/Wo/vs79klkspHjcnG6J7/BNJOLHaWj8IGC4xAz+vz8H9VaytFeoYWvA1ivdh9kRVlH9 TxB6o8TOW6V0TGoPAEm//hErCQcsNnlPQxiiDKDHesYupjdtzTmLM/xrSGQZJrYB/Np9g+ MswA4extS1LmkG+m96L9OPicacGb8ED1XOMfLlXpMdauFA2ZVTJ1Zg784S9Rpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734852692; a=rsa-sha256; cv=none; b=e7pfMbwZt3WJ3dIFxuVSkyX+7G/vjFAG0IS6Baa65iZkJiHr9QtEy4FCOG4+wbSjqStMl9 nmJ+TNgUX+iOJLw+BvffwRUGpsiECpX7IN+XQNg6yb35jqdSI4WI0ArRlK3EJkFFWflzQS BSd26/G0Kani40BwDFIzItIMa4fEG9aH4PRPRdxHqCAib4cHP67Mwhid3zPADinPFQgiq8 2zNHvRkvWOPnClbL9m9U6HpD12XBddVCg5PlV8aBlmlLuFtm6Hpl+Fac13gw9Edkbp7ZVx lj1EPMAxLe8a5wrzNsLcXsrABlmNJ/9o06jng5/jyKwO+Vi7wBFRBVhLYK+d7g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YGCWm63Hpz10LC; Sun, 22 Dec 2024 07:31:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BM7VWKr099639; Sun, 22 Dec 2024 07:31:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BM7VWAW099636; Sun, 22 Dec 2024 07:31:32 GMT (envelope-from git) Date: Sun, 22 Dec 2024 07:31:32 GMT Message-Id: <202412220731.4BM7VWAW099636@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 97cf82ebe022 - stable/14 - Revise qsort(3) reflect POSIX.1-2024 update. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 97cf82ebe02210daf14801f40164adc98e5197f4 Auto-Submitted: auto-generated The branch stable/14 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=97cf82ebe02210daf14801f40164adc98e5197f4 commit 97cf82ebe02210daf14801f40164adc98e5197f4 Author: Xin LI AuthorDate: 2024-10-28 06:15:21 +0000 Commit: Xin LI 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 .