libc: Add qsort()

This commit is contained in:
apio 2023-05-02 20:45:43 +02:00
parent dcd93cce3a
commit d1801d484c
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 9 additions and 1 deletions

View File

@ -115,7 +115,9 @@ extern "C"
/* Clear all environment variables. */ /* Clear all environment variables. */
int clearenv(void); int clearenv(void);
void qsort(void*, size_t, size_t, int (*)(const void*, const void*)); /* Sort an array of arbitrary elements using a comparison function. */
void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
void* bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*)); void* bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*));
/* Convert a multibyte character string to a wide character string. */ /* Convert a multibyte character string to a wide character string. */

View File

@ -2,6 +2,7 @@
#include <limits.h> #include <limits.h>
#include <luna/Heap.h> #include <luna/Heap.h>
#include <luna/NumberParsing.h> #include <luna/NumberParsing.h>
#include <luna/Sort.h>
#include <luna/Utf8.h> #include <luna/Utf8.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/syscall.h> #include <sys/syscall.h>
@ -199,4 +200,9 @@ extern "C"
return status; return status;
} }
void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*))
{
c_quicksort(base, nmemb, size, compar);
}
} }