From nobody Fri Oct 25 07:32:47 2024 X-Original-To: dev-commits-src-main@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 4XZZHz51Fpz5bNgq; Fri, 25 Oct 2024 07:32:47 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZZHz4bSqz4xnq; Fri, 25 Oct 2024 07:32:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729841567; 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=WZcQ/+hNEbDtSIsbOkjOYNrWGR5WbSItId+RkW4eGiY=; b=SsCmncfqUsJ5vWaaFbuIB/BEZ44CG7DVCG54DVlc3DvFn7AvFVUm2ZY1ppH0PlVxGZtmaS 3WqfiqJciZC19n6/aAGj6UhX99rHVMWptAos/rv/l9rRqylKsviSxrUfieHgcmw+Lzk7Xj ppG8d2QpIrN6LWblMJYhqlaQx2JkLqe64OZqnTc68GhKBy1cZvv6IxLPQ13B+RMhTxfjIv xNK937ClmR3n4V0EgWRD48UhWwIlNOvUe9+F9hh+rgv5+Jo+DLMK3poRM1rbLU10IXkgcz UTOF7SzlcvqtoPUt31+xLcV5v2f0A5qaVD6/wdSjssmEY9rl1jHgLAqK0gAUZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729841567; 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=WZcQ/+hNEbDtSIsbOkjOYNrWGR5WbSItId+RkW4eGiY=; b=EDH25SKV4hlklldZUTbLMFQHZ7As3e1mbJoRgGoVOOaP8PXpK+XMzEK1wSi/QM8dwXNhZV UWLANZDnV/aaQZxXqVAenlmi/q+f3/TR1LehfOmjmG0pyX4GeUItSA4tIUrVqPxkuvgE5m LbzzqH9H19iV7L7mc+TTRKN42UF+tFFCSRVaafSherQQwTwZI2hqnTdJ89vPFQ6JYVGu/Z lRCmJDD2Y38XEUU/hnQedjnMjvRb54wZN8o0BiapImC9wVVDjjUCNjCps5FLzLwmjZ9doF 6uxCBxNfM/dXqTUfpsbmNsa8E+l+bhIedXjyWsX15FFkwMNnOlGtWOYKT3X0eQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729841567; a=rsa-sha256; cv=none; b=XRWDpdP+dqra4JtGOyIaJo2t/nX+oSlXx7tETrnFXIDYRH8jIVhxlpKs0rLReN43y85qOr t0840JjRkzzFiYHGgglp5fEvgbSnlwwQDb9h3eaw5x0B6fNd5VTQENc2OIhpL21/cfgpVu bBWF6fab7HrTCW01XrOlkdMynYkNzABja5e5pwQeTC8eahXo+jTqbv2Nq5FhC9n/tLppOt PJpvCo8zSzXwiyi5T8TpUMwoVkGF3faUiPWb+Og5RHsSG087duxPqQxmWWH0lY2EO318z3 2FxlkxfUuETAAdDYwTMslxYBf/I15rbZOMcZQ7qSNWzXj1M9W7KZn5jPxFobkg== 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 4XZZHz3wwczHrN; Fri, 25 Oct 2024 07:32:47 +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 49P7WlJp090031; Fri, 25 Oct 2024 07:32:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49P7WlCV090028; Fri, 25 Oct 2024 07:32:47 GMT (envelope-from git) Date: Fri, 25 Oct 2024 07:32:47 GMT Message-Id: <202410250732.49P7WlCV090028@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: 3df1abdfd9c3 - main - Revise qsort(3 reflect POSIX.1-2024 update. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 3df1abdfd9c309efbdc7884d6b6f6fe25efcb397 Auto-Submitted: auto-generated The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=3df1abdfd9c309efbdc7884d6b6f6fe25efcb397 commit 3df1abdfd9c309efbdc7884d6b6f6fe25efcb397 Author: Xin LI AuthorDate: 2024-10-25 07:31:50 +0000 Commit: Xin LI CommitDate: 2024-10-25 07:31:50 +0000 Revise qsort(3 reflect POSIX.1-2024 update. Reviewed by: emaste, trasz MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D47262 --- lib/libc/stdlib/qsort.3 | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/libc/stdlib/qsort.3 b/lib/libc/stdlib/qsort.3 index 553f83eca8c7..e2e29e7cf04f 100644 --- a/lib/libc/stdlib/qsort.3 +++ b/lib/libc/stdlib/qsort.3 @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 19, 2023 +.Dd October 25, 2024 .Dt QSORT 3 .Os .Sh NAME @@ -248,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 @@ -277,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 @@ -333,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 @@ -426,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 @@ -442,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 .