29 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/stdlib/qsort.h"10#include "hdr/stdint_proxy.h"11#include "src/__support/common.h"12#include "src/__support/macros/config.h"13#include "src/stdlib/qsort_util.h"14 15namespace LIBC_NAMESPACE_DECL {16 17LLVM_LIBC_FUNCTION(void, qsort,18 (void *array, size_t array_size, size_t elem_size,19 int (*compare)(const void *, const void *))) {20 21 const auto is_less = [compare](const void *a, const void *b) -> bool {22 return compare(a, b) < 0;23 };24 25 internal::unstable_sort(array, array_size, elem_size, is_less);26}27 28} // namespace LIBC_NAMESPACE_DECL29