libroot/stdlib: Add qsort_r.

It's in POSIX-2024. Remove the libgnu implementation and just import
the changes from latest FreeBSD (dc36d6f9bb1753f3) instead.

While at it, put the non-standard sort functions behind
_DEFAULT_SOURCE.
This commit is contained in:
Augustin Cavalier
2025-03-13 19:30:39 -04:00
parent 194f7cff83
commit 95eee47cdc
7 changed files with 95 additions and 261 deletions
-37
View File
@@ -1,37 +0,0 @@
/*
* Copyright 2020 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Isaac Turner, [email protected]
* Jacob Secunda, [email protected]
*/
#ifndef _GNU_STDLIB_H_
#define _GNU_STDLIB_H_
#include_next <stdlib.h>
#include <features.h>
#ifdef _DEFAULT_SOURCE
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*_compare_function_qsort_r)(const void*, const void*, void*);
extern void qsort_r(void* base, size_t numElements, size_t sizeOfElement,
_compare_function_qsort_r, void* cookie);
#ifdef __cplusplus
}
#endif
#endif /* _DEFAULT_SOURCE */
#endif /* _GNU_STDLIB_H_ */