summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorArtur Bergman <sky@nanisky.com>2002-05-14 15:21:39 +0000
committerArtur Bergman <sky@nanisky.com>2002-05-14 15:21:39 +0000
commit147f47de4cf0d8224e5bba0fda69d1a6523548a2 (patch)
treecd49c8cf376ae1c4c80782e6f1c0d8e5e89e6fa6 /pp_sort.c
parenta4af207cede5b404b66a75e2aef9bcb3117451b7 (diff)
downloadperl-147f47de4cf0d8224e5bba0fda69d1a6523548a2.tar.gz
Turn the sort RealCmp for stable quicksorts into a
threadsafe per interpreter values. p4raw-id: //depot/perl@16592
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/pp_sort.c b/pp_sort.c
index 0a50ed53bb..d2d4bdee0a 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1286,7 +1286,6 @@ S_qsortsvu(pTHX_ SV ** array, size_t num_elts, SVCOMPARE_t compare)
* dictated by the indirect array.
*/
-static SVCOMPARE_t RealCmp;
static I32
cmpindir(pTHX_ gptr a, gptr b)
@@ -1295,7 +1294,7 @@ cmpindir(pTHX_ gptr a, gptr b)
gptr *ap = (gptr *)a;
gptr *bp = (gptr *)b;
- if ((sense = RealCmp(aTHX_ *ap, *bp)) == 0)
+ if ((sense = PL_sort_RealCmp(aTHX_ *ap, *bp)) == 0)
sense = (ap > bp) ? 1 : ((ap < bp) ? -1 : 0);
return sense;
}
@@ -1319,8 +1318,8 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp)
/* Copy pointers to original array elements into indirect array */
for (n = nmemb, pp = indir, q = list1; n--; ) *pp++ = q++;
- savecmp = RealCmp; /* Save current comparison routine, if any */
- RealCmp = cmp; /* Put comparison routine where cmpindir can find it */
+ savecmp = PL_sort_RealCmp; /* Save current comparison routine, if any */
+ PL_sort_RealCmp = cmp; /* Put comparison routine where cmpindir can find it */
/* sort, with indirection */
S_qsortsvu(aTHX_ (gptr *)indir, nmemb, cmpindir);
@@ -1365,7 +1364,7 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp)
/* free iff allocated */
if (indir != small) { Safefree(indir); }
/* restore prevailing comparison routine */
- RealCmp = savecmp;
+ PL_sort_RealCmp = savecmp;
} else {
S_qsortsvu(aTHX_ list1, nmemb, cmp);
}