Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / stdlib / qsort_r.cpp
blob758991848eff87615dd05bb0df470e986eb22d9c
1 //===-- Implementation of qsort_r -----------------------------------------===//
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_r.h"
10 #include "src/__support/common.h"
11 #include "src/stdlib/qsort_util.h"
13 #include <stdint.h>
15 namespace LIBC_NAMESPACE {
17 LLVM_LIBC_FUNCTION(void, qsort_r,
18 (void *array, size_t array_size, size_t elem_size,
19 int (*compare)(const void *, const void *, void *),
20 void *arg)) {
21 if (array == nullptr || array_size == 0 || elem_size == 0)
22 return;
23 internal::Comparator c(compare, arg);
24 internal::quicksort(internal::Array(reinterpret_cast<uint8_t *>(array),
25 array_size, elem_size, c));
28 } // namespace LIBC_NAMESPACE