-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppport_sort.h
48 lines (36 loc) · 1014 Bytes
/
ppport_sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef PATCHLEVEL
#include <patchlevel.h> /* Perl's one, needed since 5.6 */
#endif
#if (PATCHLEVEL <= 6)
#if defined(USE_ITHREADS)
#define STORE_HASH_SORT \
ENTER; { \
PerlInterpreter *orig_perl = PERL_GET_CONTEXT; \
SAVESPTR(orig_perl); \
PERL_SET_CONTEXT(aTHX); \
qsort((char *) AvARRAY(av), len, sizeof(SV *), sortcmp); \
} LEAVE;
#else /* ! USE_ITHREADS */
#define STORE_HASH_SORT \
qsort((char *) AvARRAY(av), len, sizeof(SV *), sortcmp);
#endif /* USE_ITHREADS */
#else /* PATCHLEVEL > 6 */
#define STORE_HASH_SORT \
sortsv(AvARRAY(av), len, Perl_sv_cmp);
#endif /* PATCHLEVEL <= 6 */
#if (PATCHLEVEL <= 6)
/*
* sortcmp
*
* Sort two SVs
* Borrowed from perl source file pp_ctl.c, where it is used by pp_sort.
*/
static int
sortcmp(const void *a, const void *b)
{
#if defined(USE_ITHREADS)
dTHX;
#endif /* USE_ITHREADS */
return sv_cmp(*(SV * const *) a, *(SV * const *) b);
}
#endif /* PATCHLEVEL <= 6 */