EV

 view release on metacpan or  search on metacpan

EV.xs  view on Meta::CPAN


      if (retval < now)
        retval = now;
    }
  else
    retval = now;

  FREETMPS;
  LEAVE;

  return retval;
}

#define CHECK_REPEAT(repeat) if (repeat < 0.) \
  croak (# repeat " value must be >= 0");

#define CHECK_FD(fh,fd) if ((fd) < 0) \
  croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh));

#define CHECK_SIG(sv,num) if ((num) < 0) \
  croak ("illegal signal number or name: %s", SvPV_nolen (sv));

static void
default_fork (void)
{
  ev_loop_fork (EV_DEFAULT_UC);
}

/////////////////////////////////////////////////////////////////////////////
// XS interface functions

MODULE = EV		PACKAGE = EV		PREFIX = ev_

PROTOTYPES: ENABLE

BOOT:
{
  HV *stash = gv_stashpv ("EV", 1);

  static const struct {
    const char *name;
    IV iv;
  } *civ, const_iv[] = {
#   define const_iv(pfx, name) { # name, (IV) pfx ## name },
    const_iv (EV_, MINPRI)
    const_iv (EV_, MAXPRI)

    const_iv (EV_, UNDEF)
    const_iv (EV_, NONE)
    const_iv (EV_, READ)
    const_iv (EV_, WRITE)
    const_iv (EV_, IO)
    const_iv (EV_, TIMER)
    const_iv (EV_, PERIODIC)
    const_iv (EV_, SIGNAL)
    const_iv (EV_, CHILD)
    const_iv (EV_, STAT)
    const_iv (EV_, IDLE)
    const_iv (EV_, PREPARE)
    /*const_iv (EV_, CHECK) needs special tretament */
    const_iv (EV_, EMBED)
    const_iv (EV_, FORK)
    const_iv (EV_, CLEANUP)
    const_iv (EV_, ASYNC)
    const_iv (EV_, CUSTOM)
    const_iv (EV_, ERROR)

    const_iv (EV, RUN_NOWAIT)
    const_iv (EV, RUN_ONCE)

    const_iv (EV, BREAK_CANCEL)
    const_iv (EV, BREAK_ONE)
    const_iv (EV, BREAK_ALL)
    const_iv (EV, BACKEND_SELECT)
    const_iv (EV, BACKEND_POLL)
    const_iv (EV, BACKEND_EPOLL)
    const_iv (EV, BACKEND_KQUEUE)
    const_iv (EV, BACKEND_DEVPOLL)
    const_iv (EV, BACKEND_PORT)
    const_iv (EV, BACKEND_ALL)
    const_iv (EV, BACKEND_MASK)
    const_iv (EV, FLAG_AUTO)
    const_iv (EV, FLAG_FORKCHECK)
    const_iv (EV, FLAG_SIGNALFD)
    const_iv (EV, FLAG_NOSIGMASK)
    const_iv (EV, FLAG_NOENV)
    const_iv (EV, FLAG_NOINOTIFY)

    const_iv (EV_, VERSION_MAJOR)
    const_iv (EV_, VERSION_MINOR)
#if EV_COMPAT3
    const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
    const_iv (EV_, TIMEOUT)
    const_iv (EV, LOOP_NONBLOCK)
    const_iv (EV, LOOP_ONESHOT)
    const_iv (EV, UNLOOP_CANCEL)
    const_iv (EV, UNLOOP_ONE)
    const_iv (EV, UNLOOP_ALL)
#endif
  };

  for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
    newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));

  /* since this clashes with perl CHECK blocks, */
  /* but we are interested in constants, */
  /* and not blocks, we treat CHECK specially. */
  {
    /* the local $^W = 0 takes care of the warning */
    CV *cv = newCONSTSUB (stash, "CHECK", newSViv (EV_CHECK));
    /* now we need to re-set the gv, in case it was hijacked */
    GvCV_set (gv_fetchpv ("EV::CHECK", GV_ADD, SVt_PVCV), cv);
  }

  stash_loop     = gv_stashpv ("EV::Loop"    , 1);
  stash_watcher  = gv_stashpv ("EV::Watcher" , 1);
  stash_io       = gv_stashpv ("EV::IO"      , 1);
  stash_timer    = gv_stashpv ("EV::Timer"   , 1);
  stash_periodic = gv_stashpv ("EV::Periodic", 1);
  stash_signal   = gv_stashpv ("EV::Signal"  , 1);
  stash_idle     = gv_stashpv ("EV::Idle"    , 1);



( run in 0.897 second using v1.01-cache-2.11-cpan-71847e10f99 )