ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.264 by root, Fri Nov 14 02:29:09 2008 UTC vs.
Revision 1.265 by root, Fri Nov 14 02:42:26 2008 UTC

711 } 711 }
712 712
713 return rss; 713 return rss;
714} 714}
715 715
716/** set stacklevel support **************************************************/
717
718/* we sometimes need to create the effect of pp_set_stacklevel calling us */
719#define SSL_HEAD (void)0
720/* we somtimes need to create the effect of leaving via pp_set_stacklevel */
721#define SSL_TAIL set_stacklevel_tail (aTHX)
722
723INLINE void
724set_stacklevel_tail (pTHX)
725{
726 dSP;
727 int gimme = GIMME_V;
728
729 if (gimme == G_SCALAR)
730 XPUSHs (&PL_sv_undef);
731
732 PUTBACK;
733}
734
716/** coroutine stack handling ************************************************/ 735/** coroutine stack handling ************************************************/
717 736
718static int (*orig_sigelem_get) (pTHX_ SV *sv, MAGIC *mg); 737static int (*orig_sigelem_get) (pTHX_ SV *sv, MAGIC *mg);
719static int (*orig_sigelem_set) (pTHX_ SV *sv, MAGIC *mg); 738static int (*orig_sigelem_set) (pTHX_ SV *sv, MAGIC *mg);
720static int (*orig_sigelem_clr) (pTHX_ SV *sv, MAGIC *mg); 739static int (*orig_sigelem_clr) (pTHX_ SV *sv, MAGIC *mg);
723#ifndef MgPV_nolen_const 742#ifndef MgPV_nolen_const
724#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \ 743#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \
725 SvPV_nolen((SV*)((mg)->mg_ptr)) : \ 744 SvPV_nolen((SV*)((mg)->mg_ptr)) : \
726 (const char*)(mg)->mg_ptr) 745 (const char*)(mg)->mg_ptr)
727#endif 746#endif
728
729/* we sometimes need to create the effect of entersub calling us */
730#define SSL_HEAD (void)0
731/* we somtimes need to create the effect of leaving via entersub */
732#define SSL_TAIL (void)0
733 747
734/* 748/*
735 * This overrides the default magic get method of %SIG elements. 749 * This overrides the default magic get method of %SIG elements.
736 * The original one doesn't provide for reading back of PL_diehook/PL_warnhook 750 * The original one doesn't provide for reading back of PL_diehook/PL_warnhook
737 * and instead of tryign to save and restore the hash elements, we just provide 751 * and instead of tryign to save and restore the hash elements, we just provide
857 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); 871 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX);
858 SPAGAIN; 872 SPAGAIN;
859 } 873 }
860 874
861 /* this newly created coroutine might be run on an existing cctx which most 875 /* this newly created coroutine might be run on an existing cctx which most
862 * likely was suspended in set_stacklevel, called from entersub. 876 * likely was suspended in set_stacklevel, called from pp_set_stacklevel,
863 * set_stacklevel doesn't do anything on return, but entersub does LEAVE, 877 * so we have to emulate entering pp_set_stacklevel here.
864 * so we ENTER here for symmetry.
865 */ 878 */
866 SSL_HEAD; 879 SSL_HEAD;
867} 880}
868 881
869static void 882static void
1105# endif 1118# endif
1106#endif 1119#endif
1107 { 1120 {
1108 dTHX; 1121 dTHX;
1109 1122
1110 /* entersub called ENTER, but we never 'returned', undo that here */ 1123 /* we are the alternative tail to pp_set_stacklevel */
1124 /* so do the same things here */
1111 SSL_TAIL; 1125 SSL_TAIL;
1112 1126
1113 /* we now skip the op that did lead to transfer() */ 1127 /* we now skip the op that did lead to transfer() */
1114 PL_op = PL_op->op_next; 1128 PL_op = PL_op->op_next;
1115 1129
1885 prepare_cede (aTHX_ &ta); 1899 prepare_cede (aTHX_ &ta);
1886 break; 1900 break;
1887 1901
1888 case 4: 1902 case 4:
1889 if (!prepare_cede_notself (aTHX_ &ta)) 1903 if (!prepare_cede_notself (aTHX_ &ta))
1890 RETURN; 1904 goto skip;
1891 1905
1892 break; 1906 break;
1893 } 1907 }
1894 1908
1895 TRANSFER (ta, 0); 1909 TRANSFER (ta, 0);
1896 SPAGAIN; 1910 SPAGAIN;
1897 1911
1898skip: 1912skip:
1899 1913 PUTBACK;
1914 SSL_TAIL;
1915 SPAGAIN;
1900 RETURN; 1916 RETURN;
1901} 1917}
1902 1918
1903MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_ 1919MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_
1904 1920

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines