stdlib: Avoid element self-comparisons in qsort
commitf8cfb6836e8d91bb789b2e7fd65338d6f5bd459c
authorFlorian Weimer <fweimer@redhat.com>
Wed, 8 Nov 2023 14:18:02 +0000 (8 15:18 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 8 Nov 2023 14:18:02 +0000 (8 15:18 +0100)
tree1002f133c1f0f02f1c8f3fcb464037d4c002b7d3
parentbf033c0072554366fe9617c283c982594059ad9d
stdlib: Avoid element self-comparisons in qsort

This improves compatibility with applications which assume that qsort
does not invoke the comparison function with equal pointer arguments.

The newly introduced branches should be predictable, as leading to a
call to the comparison function.  If the prediction fails, we avoid
calling the function.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
stdlib/qsort.c