~ubuntu-branches/ubuntu/saucy/python3.3/saucy-proposed

« back to all changes in this revision

Viewing changes to Modules/selectmodule.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-05-15 21:42:49 UTC
  • mfrom: (1.2.9) (22.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130515214249-otmm671u8fiylkc2
Tags: 3.3.2-1ubuntu1
Regenerate the control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1571
1571
#   error uintptr_t does not match int, long, or long long!
1572
1572
#endif
1573
1573
 
 
1574
/*
 
1575
 * kevent is not standard and its members vary across BSDs.
 
1576
 */
 
1577
#if !defined(__OpenBSD__)
 
1578
#   define IDENT_TYPE   T_UINTPTRT
 
1579
#   define IDENT_CAST   Py_intptr_t
 
1580
#   define DATA_TYPE    T_INTPTRT
 
1581
#   define DATA_FMT_UNIT INTPTRT_FMT_UNIT
 
1582
#   define IDENT_AsType PyLong_AsUintptr_t
 
1583
#else
 
1584
#   define IDENT_TYPE   T_UINT
 
1585
#   define IDENT_CAST   int
 
1586
#   define DATA_TYPE    T_INT
 
1587
#   define DATA_FMT_UNIT "i"
 
1588
#   define IDENT_AsType PyLong_AsUnsignedLong
 
1589
#endif
 
1590
 
1574
1591
/* Unfortunately, we can't store python objects in udata, because
1575
1592
 * kevents in the kernel can be removed without warning, which would
1576
1593
 * forever lose the refcount on the object stored with it.
1578
1595
 
1579
1596
#define KQ_OFF(x) offsetof(kqueue_event_Object, x)
1580
1597
static struct PyMemberDef kqueue_event_members[] = {
1581
 
    {"ident",           T_UINTPTRT,     KQ_OFF(e.ident)},
 
1598
    {"ident",           IDENT_TYPE,     KQ_OFF(e.ident)},
1582
1599
    {"filter",          T_SHORT,        KQ_OFF(e.filter)},
1583
1600
    {"flags",           T_USHORT,       KQ_OFF(e.flags)},
1584
1601
    {"fflags",          T_UINT,         KQ_OFF(e.fflags)},
1585
 
    {"data",            T_INTPTRT,      KQ_OFF(e.data)},
 
1602
    {"data",            DATA_TYPE,      KQ_OFF(e.data)},
1586
1603
    {"udata",           T_UINTPTRT,     KQ_OFF(e.udata)},
1587
1604
    {NULL} /* Sentinel */
1588
1605
};
1608
1625
    PyObject *pfd;
1609
1626
    static char *kwlist[] = {"ident", "filter", "flags", "fflags",
1610
1627
                             "data", "udata", NULL};
1611
 
    static char *fmt = "O|hhi" INTPTRT_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
 
1628
    static char *fmt = "O|hhi" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
1612
1629
 
1613
1630
    EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */
1614
1631
 
1618
1635
        return -1;
1619
1636
    }
1620
1637
 
1621
 
    if (PyLong_Check(pfd)) {
1622
 
        self->e.ident = PyLong_AsUintptr_t(pfd);
 
1638
    if (PyLong_Check(pfd)
 
1639
#if IDENT_TYPE == T_UINT
 
1640
        && PyLong_AsUnsignedLong(pfd) <= UINT_MAX
 
1641
#endif
 
1642
    ) {
 
1643
        self->e.ident = IDENT_AsType(pfd);
1623
1644
    }
1624
1645
    else {
1625
1646
        self->e.ident = PyObject_AsFileDescriptor(pfd);
1647
1668
            Py_TYPE(s)->tp_name, Py_TYPE(o)->tp_name);
1648
1669
        return NULL;
1649
1670
    }
1650
 
    if (((result = s->e.ident - o->e.ident) == 0) &&
 
1671
    if (((result = (IDENT_CAST)(s->e.ident - o->e.ident)) == 0) &&
1651
1672
        ((result = s->e.filter - o->e.filter) == 0) &&
1652
1673
        ((result = s->e.flags - o->e.flags) == 0) &&
1653
 
        ((result = s->e.fflags - o->e.fflags) == 0) &&
 
1674
        ((result = (int)(s->e.fflags - o->e.fflags)) == 0) &&
1654
1675
        ((result = s->e.data - o->e.data) == 0) &&
1655
1676
        ((result = s->e.udata - o->e.udata) == 0)
1656
1677
       ) {