summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embed.fnc1
-rw-r--r--embed.h2
-rw-r--r--pp_sort.c10
-rw-r--r--proto.h4
4 files changed, 13 insertions, 4 deletions
diff --git a/embed.fnc b/embed.fnc
index e04236f407..4ffa057d0e 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1275,6 +1275,7 @@ s |I32 |amagic_cmp_locale|NN SV *a|NN SV *b
s |I32 |sortcv |NN SV *a|NN SV *b
s |I32 |sortcv_xsub |NN SV *a|NN SV *b
s |I32 |sortcv_stacked |NN SV *a|NN SV *b
+s |void |qsortsvu |NN SV** array|size_t num_elts|NN SVCOMPARE_t compare
#endif
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
diff --git a/embed.h b/embed.h
index 2885e22b7d..95b2de2f72 100644
--- a/embed.h
+++ b/embed.h
@@ -1280,6 +1280,7 @@
#define sortcv S_sortcv
#define sortcv_xsub S_sortcv_xsub
#define sortcv_stacked S_sortcv_stacked
+#define qsortsvu S_qsortsvu
#endif
#endif
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
@@ -3460,6 +3461,7 @@
#define sortcv(a,b) S_sortcv(aTHX_ a,b)
#define sortcv_xsub(a,b) S_sortcv_xsub(aTHX_ a,b)
#define sortcv_stacked(a,b) S_sortcv_stacked(aTHX_ a,b)
+#define qsortsvu(a,b,c) S_qsortsvu(aTHX_ a,b,c)
#endif
#endif
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
diff --git a/pp_sort.c b/pp_sort.c
index ab383c1215..f349c6ff52 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1365,8 +1365,10 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp, U32 flags)
PL_sort_RealCmp = cmp; /* Put comparison routine where cmpindir can find it */
/* sort, with indirection */
- S_qsortsvu(aTHX_ (gptr *)indir, nmemb,
- ((flags & SORTf_DESC) != 0 ? cmpindir_desc : cmpindir));
+ if (flags & SORTf_DESC)
+ qsortsvu((gptr *)indir, nmemb, cmpindir_desc);
+ else
+ qsortsvu((gptr *)indir, nmemb, cmpindir);
pp = indir;
q = list1;
@@ -1413,11 +1415,11 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp, U32 flags)
const SVCOMPARE_t savecmp = PL_sort_RealCmp; /* Save current comparison routine, if any */
PL_sort_RealCmp = cmp; /* Put comparison routine where cmp_desc can find it */
cmp = cmp_desc;
- S_qsortsvu(aTHX_ list1, nmemb, cmp);
+ qsortsvu(list1, nmemb, cmp);
/* restore prevailing comparison routine */
PL_sort_RealCmp = savecmp;
} else {
- S_qsortsvu(aTHX_ list1, nmemb, cmp);
+ qsortsvu(list1, nmemb, cmp);
}
}
diff --git a/proto.h b/proto.h
index 8bfa8c6d41..a0d5dec2aa 100644
--- a/proto.h
+++ b/proto.h
@@ -3488,6 +3488,10 @@ STATIC I32 S_sortcv_stacked(pTHX_ SV *a, SV *b)
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_2);
+STATIC void S_qsortsvu(pTHX_ SV** array, size_t num_elts, SVCOMPARE_t compare)
+ __attribute__nonnull__(pTHX_1)
+ __attribute__nonnull__(pTHX_3);
+
#endif
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)