blob: 76483cff33726138440ae8843f16a93791a47869 [file] [log] [blame]
Simon Glass16ff5702019-11-14 12:57:19 -07001/* 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 */
20void 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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010030 * Return: comparison value (less than, equal to, or greater than 0)
Simon Glass16ff5702019-11-14 12:57:19 -070031 */
32int strcmp_compar(const void *s1, const void *s2);
33
34#endif