mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[Bug #18997] Don't define ruby_qsort when POSIX qsort_r is available
The current code would define ruby_qsort as a wrapper of qsort_s when it is available. When both qsort_s and POSIX (GNU) qsort_r are available, we should call qsort_r directly instead, and the qsort_s wrapper is redundant.
This commit is contained in:
parent
78af05ba0f
commit
7400628cb0
Notes:
git
2022-09-08 17:38:12 +09:00
Merged: https://github.com/ruby/ruby/pull/6332 Merged-By: nobu <nobu@ruby-lang.org>
1 changed files with 4 additions and 2 deletions
6
util.c
6
util.c
|
@ -218,6 +218,7 @@ ruby_strtoul(const char *str, char **endptr, int base)
|
||||||
|
|
||||||
typedef int (cmpfunc_t)(const void*, const void*, void*);
|
typedef int (cmpfunc_t)(const void*, const void*, void*);
|
||||||
|
|
||||||
|
#if !defined HAVE_GNU_QSORT_R
|
||||||
#if defined HAVE_QSORT_S && defined RUBY_MSVCRT_VERSION
|
#if defined HAVE_QSORT_S && defined RUBY_MSVCRT_VERSION
|
||||||
/* In contrast to its name, Visual Studio qsort_s is incompatible with
|
/* In contrast to its name, Visual Studio qsort_s is incompatible with
|
||||||
* C11 in the order of the comparison function's arguments, and same
|
* C11 in the order of the comparison function's arguments, and same
|
||||||
|
@ -263,7 +264,7 @@ ruby_qsort(void* base, const size_t nel, const size_t size, cmpfunc_t *cmp, void
|
||||||
qsort_s(base, nel, size, cmp, d);
|
qsort_s(base, nel, size, cmp, d);
|
||||||
}
|
}
|
||||||
# define HAVE_GNU_QSORT_R 1
|
# define HAVE_GNU_QSORT_R 1
|
||||||
#elif !defined HAVE_GNU_QSORT_R
|
#else
|
||||||
/* mm.c */
|
/* mm.c */
|
||||||
|
|
||||||
#define mmtype long
|
#define mmtype long
|
||||||
|
@ -530,7 +531,8 @@ ruby_qsort(void* base, const size_t nel, const size_t size, cmpfunc_t *cmp, void
|
||||||
else goto nxt; /* need not to sort both sides */
|
else goto nxt; /* need not to sort both sides */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_GNU_QSORT_R */
|
#endif
|
||||||
|
#endif /* !HAVE_GNU_QSORT_R */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ruby_strdup(const char *str)
|
ruby_strdup(const char *str)
|
||||||
|
|
Loading…
Reference in a new issue