sort.h 909 B

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