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.385 by root, Sat Feb 19 05:42:46 2011 UTC vs.
Revision 1.386 by root, Sat Feb 19 06:51:23 2011 UTC

313 /* entersub is an UNOP, select a LISTOP... keep your fingers crossed */ 313 /* entersub is an UNOP, select a LISTOP... keep your fingers crossed */
314 PL_op->op_flags |= OPf_STACKED; 314 PL_op->op_flags |= OPf_STACKED;
315 PL_op->op_private = 0; 315 PL_op->op_private = 0;
316 return PL_ppaddr [OP_ENTERSUB](aTHX); 316 return PL_ppaddr [OP_ENTERSUB](aTHX);
317} 317}
318
319/** time stuff **************************************************************/
320
321#ifdef HAS_GETTIMEOFDAY
322
323static void
324coro_u2time (aTHX_ UV ret[2])
325{
326 struct timeval tv;
327 gettimeofday (&tv, 0);
328
329 ret [0] = tv.tv_sec;
330 ret [1] = tv.tv_usec;
331}
332
333static double
334coro_nvtime ()
335{
336 struct timeval tv;
337 gettimeofday (&tv, 0);
338
339 return tv.tv_sec + tv.tv_usec * 1e-6;
340}
341
342static void
343time_init (void)
344{
345 nvtime = coro_nvtime;
346 u2time = coro_u2time;
347}
348
349#else
350
351static void
352time_init (void)
353{
354 SV **svp;
355
356 require_pv ("Time::HiRes");
357
358 svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
359
360 if (!svp) croak ("Time::HiRes is required");
361 if (!SvIOK (*svp)) croak ("Time::NVtime isn't a function pointer");
362
363 nvtime = INT2PTR (double (*)(), SvIV (*svp));
364
365 svp = hv_fetch (PL_modglobal, "Time::U2time", 12, 0);
366 u2time = INT2PTR (void (*)(pTHX_ UV ret[2]), SvIV (*svp));
367}
368
369#endif
318 370
319/** lowlevel stuff **********************************************************/ 371/** lowlevel stuff **********************************************************/
320 372
321static SV * 373static SV *
322coro_get_sv (pTHX_ const char *name, int create) 374coro_get_sv (pTHX_ const char *name, int create)
3109 coroapi.prepare_nop = prepare_nop; 3161 coroapi.prepare_nop = prepare_nop;
3110 coroapi.prepare_schedule = prepare_schedule; 3162 coroapi.prepare_schedule = prepare_schedule;
3111 coroapi.prepare_cede = prepare_cede; 3163 coroapi.prepare_cede = prepare_cede;
3112 coroapi.prepare_cede_notself = prepare_cede_notself; 3164 coroapi.prepare_cede_notself = prepare_cede_notself;
3113 3165
3114 { 3166 time_init ();
3115 SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
3116
3117 if (!svp) croak ("Time::HiRes is required");
3118 if (!SvIOK (*svp)) croak ("Time::NVtime isn't a function pointer");
3119
3120 nvtime = INT2PTR (double (*)(), SvIV (*svp));
3121
3122 svp = hv_fetch (PL_modglobal, "Time::U2time", 12, 0);
3123 u2time = INT2PTR (void (*)(pTHX_ UV ret[2]), SvIV (*svp));
3124 }
3125 3167
3126 assert (("PRIO_NORMAL must be 0", !CORO_PRIO_NORMAL)); 3168 assert (("PRIO_NORMAL must be 0", !CORO_PRIO_NORMAL));
3127} 3169}
3128 3170
3129SV * 3171SV *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines