… | |
… | |
3 | #include "EXTERN.h" |
3 | #include "EXTERN.h" |
4 | #include "perl.h" |
4 | #include "perl.h" |
5 | #include "XSUB.h" |
5 | #include "XSUB.h" |
6 | |
6 | |
7 | #include "patchlevel.h" |
7 | #include "patchlevel.h" |
|
|
8 | |
|
|
9 | #if USE_VALGRIND |
|
|
10 | # include <valgrind/valgrind.h> |
|
|
11 | #endif |
8 | |
12 | |
9 | #define PERL_VERSION_ATLEAST(a,b,c) \ |
13 | #define PERL_VERSION_ATLEAST(a,b,c) \ |
10 | (PERL_REVISION > (a) \ |
14 | (PERL_REVISION > (a) \ |
11 | || (PERL_REVISION == (a) \ |
15 | || (PERL_REVISION == (a) \ |
12 | && (PERL_VERSION > (b) \ |
16 | && (PERL_VERSION > (b) \ |
… | |
… | |
108 | |
112 | |
109 | /* cpu state */ |
113 | /* cpu state */ |
110 | void *idle_sp; /* sp of top-level transfer/schedule/cede call */ |
114 | void *idle_sp; /* sp of top-level transfer/schedule/cede call */ |
111 | JMPENV *top_env; |
115 | JMPENV *top_env; |
112 | coro_context cctx; |
116 | coro_context cctx; |
|
|
117 | |
|
|
118 | #if USE_VALGRIND |
|
|
119 | int valgrind_id; |
|
|
120 | #endif |
113 | } coro_stack; |
121 | } coro_stack; |
114 | |
122 | |
115 | /* this is a structure representing a perl-level coroutine */ |
123 | /* this is a structure representing a perl-level coroutine */ |
116 | struct coro { |
124 | struct coro { |
117 | /* the c coroutine allocated to this perl coroutine, if any */ |
125 | /* the c coroutine allocated to this perl coroutine, if any */ |
… | |
… | |
661 | _exit (EXIT_FAILURE); |
669 | _exit (EXIT_FAILURE); |
662 | } |
670 | } |
663 | |
671 | |
664 | #endif |
672 | #endif |
665 | |
673 | |
|
|
674 | #if USE_VALGRIND |
|
|
675 | stack->valgrind_id = VALGRIND_STACK_REGISTER ( |
|
|
676 | STACKGUARD * PAGESIZE + (char *)stack->sptr, |
|
|
677 | stack->ssize + (char *)stack->sptr |
|
|
678 | ); |
|
|
679 | #endif |
|
|
680 | |
666 | coro_create (&stack->cctx, coro_run, (void *)stack, stack->sptr, stack->ssize); |
681 | coro_create (&stack->cctx, coro_run, (void *)stack, stack->sptr, stack->ssize); |
667 | |
682 | |
668 | return stack; |
683 | return stack; |
669 | } |
684 | } |
670 | |
685 | |
671 | static void |
686 | static void |
672 | stack_free (coro_stack *stack) |
687 | stack_free (coro_stack *stack) |
673 | { |
688 | { |
674 | if (!stack) |
689 | if (!stack) |
675 | return; |
690 | return; |
|
|
691 | |
|
|
692 | #if USE_VALGRIND |
|
|
693 | VALGRIND_STACK_DEREGISTER (stack->valgrind_id); |
|
|
694 | #endif |
676 | |
695 | |
677 | #if HAVE_MMAP |
696 | #if HAVE_MMAP |
678 | munmap (stack->sptr, stack->ssize); |
697 | munmap (stack->sptr, stack->ssize); |
679 | #else |
698 | #else |
680 | Safefree (stack->sptr); |
699 | Safefree (stack->sptr); |