Simon Glass | 8bef79b | 2019-11-14 12:57:19 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2019 Google LLC |
| 4 | */ |
| 5 | |
| 6 | #ifndef __SORT_H |
| 7 | #define __SORT_H |
| 8 | |
| 9 | /** |
| 10 | * qsort() - Use the quicksort algorithm to sort some values |
| 11 | * |
| 12 | * @base: Base address of array to sort |
| 13 | * @nmemb: Number of members to sort |
| 14 | * @size: Size of each member in bytes |
| 15 | * @compar: Comparison function which should return: |
| 16 | * < 0 if element at s1 < element at s2, |
| 17 | * 0 if element at s1 == element at s2, |
| 18 | * > 0 if element at s1 > element at s2, |
| 19 | */ |
| 20 | void qsort(void *base, size_t nmemb, size_t size, |
| 21 | int (*compar)(const void *s1, const void *s2)); |
| 22 | |
| 23 | /** |
| 24 | * strcmp_compar() - compar function for string arrays |
| 25 | * |
| 26 | * This can be passed to qsort when a string array is being sorted |
| 27 | * |
| 28 | * @s1: First string to compare |
| 29 | * @s2: Second string to compare |
| 30 | * @return comparison value (less than, equal to, or greater than 0) |
| 31 | */ |
| 32 | int strcmp_compar(const void *s1, const void *s2); |
| 33 | |
| 34 | #endif |