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