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:
@@ -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_ */
|
||||
@@ -120,19 +120,25 @@ extern void lcong48(unsigned short int param[7]);
|
||||
|
||||
/* search and sort functions */
|
||||
typedef int (*_compare_function)(const void *, const void *);
|
||||
typedef int (*_compare_function_qsort_r)(const void*, const void*, void*);
|
||||
|
||||
extern void *bsearch(const void *key, const void *base, size_t numElements,
|
||||
size_t sizeOfElement, _compare_function);
|
||||
extern void qsort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern void qsort_r(void* base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function_qsort_r, void* cookie);
|
||||
|
||||
#ifdef _DEFAULT_SOURCE
|
||||
extern int heapsort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern int mergesort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern void qsort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern int radixsort(u_char const **base, int numElements,
|
||||
u_char const *table, u_int endByte);
|
||||
extern int sradixsort(u_char const **base, int numElements,
|
||||
u_char const *table, u_int endByte);
|
||||
#endif
|
||||
|
||||
/* misc math functions */
|
||||
extern int abs(int number);
|
||||
|
||||
Reference in New Issue
Block a user