1 //===-- Implementation header for qsort utilities ---------------*- C++ -*-===// 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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_SRC_STDLIB_QSORT_UTIL_H 10 #define LLVM_LIBC_SRC_STDLIB_QSORT_UTIL_H 11 12 #include "src/stdlib/heap_sort.h" 13 #include "src/stdlib/quick_sort.h" 14 15 #define LIBC_QSORT_QUICK_SORT 1 16 #define LIBC_QSORT_HEAP_SORT 2 17 18 #ifndef LIBC_QSORT_IMPL 19 #define LIBC_QSORT_IMPL LIBC_QSORT_QUICK_SORT 20 #endif // LIBC_QSORT_IMPL 21 22 #if (LIBC_QSORT_IMPL != LIBC_QSORT_QUICK_SORT && \ 23 LIBC_QSORT_IMPL != LIBC_QSORT_HEAP_SORT) 24 #error "LIBC_QSORT_IMPL is not recognized." 25 #endif 26 27 namespace LIBC_NAMESPACE_DECL { 28 namespace internal { 29 30 #if LIBC_QSORT_IMPL == LIBC_QSORT_QUICK_SORT 31 constexpr auto sort = quick_sort; 32 #elif LIBC_QSORT_IMPL == LIBC_QSORT_HEAP_SORT 33 constexpr auto sort = heap_sort; 34 #endif 35 36 } // namespace internal 37 } // namespace LIBC_NAMESPACE_DECL 38 39 #endif // LLVM_LIBC_SRC_STDLIB_QSORT_UTIL_H 40