[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / libc / src / stdlib / qsort.cpp
blob0bf5fc79805279fefd6962a44482ecee570d41d1
1 //===-- Implementation of qsort -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/stdlib/qsort.h"
10 #include "src/__support/common.h"
11 #include "src/__support/macros/config.h"
12 #include "src/stdlib/qsort_util.h"
14 #include <stdint.h>
16 namespace LIBC_NAMESPACE_DECL {
18 LLVM_LIBC_FUNCTION(void, qsort,
19 (void *array, size_t array_size, size_t elem_size,
20 int (*compare)(const void *, const void *))) {
22 const auto is_less = [compare](const void *a, const void *b) -> bool {
23 return compare(a, b) < 0;
26 internal::unstable_sort(array, array_size, elem_size, is_less);
29 } // namespace LIBC_NAMESPACE_DECL