IO-KQueue

 view release on metacpan or  search on metacpan

KQueue.xs  view on Meta::CPAN

    kqueue_t    kq
    uintptr_t   ident
    short       filter
    u_short     flags
    u_short     fflags
    intptr_t    data
    SV        * udata
  PREINIT:
    struct kevent ke;
    int i;
  PPCODE:
    memset(&ke, 0, sizeof(struct kevent));
    if (udata)
        SvREFCNT_inc(udata);
    else
        udata = &PL_sv_undef;
    EV_SET(&ke, ident, filter, flags, fflags, data, udata);
    i = kevent(kq, &ke, 1, NULL, 0, NULL);
    if (i == -1) {
        croak("set kevent failed: %s", strerror(errno));
    }

KQueue.xs  view on Meta::CPAN

void
kevent(kq, timeout=&PL_sv_undef)
    kqueue_t    kq
    SV *        timeout
  PREINIT:
    int num_events, i;
    struct timespec t;
    struct kevent *ke = NULL;
    struct timespec *tbuf = (struct timespec *)0;
    I32 max_events = SvIV(get_sv("IO::KQueue::MAX_EVENTS", FALSE));
  PPCODE:
    Newxz(ke, max_events, struct kevent);
    if (ke == NULL) {
        croak("malloc failed");
    }
    
    if (SvOK(timeout)) {
        I32 time = SvIV(timeout);
        if (time >= 0) {
            t.tv_sec = time / 1000;
            t.tv_nsec = (time % 1000) * 1000000;

const-xs.inc  view on Meta::CPAN

	dTARGET;
#endif
	STRLEN		len;
        int		type;
	IV		iv = 0; /* avoid uninit var warning */
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
    INPUT:
	SV *		sv;
        const char *	s = SvPV(sv, len);
    PPCODE:
        /* Change this to constant(aTHX_ s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(aTHX_ s, len, &iv);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv =
	    sv_2mortal(newSVpvf("%s is not a valid IO::KQueue macro", s));
          PUSHs(sv);



( run in 0.709 second using v1.01-cache-2.11-cpan-3d66aa2751a )