[前][次][番号順一覧][スレッド一覧]

ruby-changes:73478

From: Xin <ko1@a...>
Date: Thu, 8 Sep 2022 17:38:03 +0900 (JST)
Subject: [ruby-changes:73478] 7400628cb0 (master): [Bug #18997] Don't define ruby_qsort when POSIX qsort_r is available

https://git.ruby-lang.org/ruby.git/commit/?id=7400628cb0

From 7400628cb054a9a9651d69411a100fc9d518099f Mon Sep 17 00:00:00 2001
From: Xin Li <delphij@u...>
Date: Thu, 8 Sep 2022 01:37:37 -0700
Subject: [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.
---
 util.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/util.c b/util.c
index c7fb0998a8..74f2d11b94 100644
--- a/util.c
+++ b/util.c
@@ -218,6 +218,7 @@ ruby_strtoul(const char *str, char **endptr, int base) https://github.com/ruby/ruby/blob/trunk/util.c#L218
 
 typedef int (cmpfunc_t)(const void*, const void*, void*);
 
+#if !defined HAVE_GNU_QSORT_R
 #if defined HAVE_QSORT_S && defined RUBY_MSVCRT_VERSION
 /* In contrast to its name, Visual Studio qsort_s is incompatible with
  * 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 https://github.com/ruby/ruby/blob/trunk/util.c#L264
     qsort_s(base, nel, size, cmp, d);
 }
 # define HAVE_GNU_QSORT_R 1
-#elif !defined HAVE_GNU_QSORT_R
+#else
 /* mm.c */
 
 #define mmtype long
@@ -530,7 +531,8 @@ ruby_qsort(void* base, const size_t nel, const size_t size, cmpfunc_t *cmp, void https://github.com/ruby/ruby/blob/trunk/util.c#L531
     else goto nxt;                         /* need not to sort both sides */
   }
 }
-#endif /* HAVE_GNU_QSORT_R */
+#endif
+#endif /* !HAVE_GNU_QSORT_R */
 
 char *
 ruby_strdup(const char *str)
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]