diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 092ed8c3..2dc31332 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -115,7 +115,9 @@ extern "C" /* Clear all environment variables. */ 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*)); /* Convert a multibyte character string to a wide character string. */ diff --git a/libc/src/stdlib.cpp b/libc/src/stdlib.cpp index 6c62940d..59c6bd43 100644 --- a/libc/src/stdlib.cpp +++ b/libc/src/stdlib.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -199,4 +200,9 @@ extern "C" return status; } + + void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)) + { + c_quicksort(base, nmemb, size, compar); + } }