Browse Source

*** empty log message ***

master
Marc Alexander Lehmann 2 years ago
parent
commit
82602c5e08
  1. 10
      ev.c
  2. 26
      ev_linuxaio.c
  3. 10
      ev_poll.c

10
ev.c

@ -440,7 +440,7 @@
#if EV_USE_LINUXAIO
# include <sys/syscall.h>
# if !SYS_io_getevents || !EV_USE_EPOLL
# if !SYS_io_getevents || !EV_USE_EPOLL /* ev_linxaio uses ev_poll.c:ev_epoll_create */
# undef EV_USE_LINUXAIO
# define EV_USE_LINUXAIO 0
# endif
@ -1991,10 +1991,10 @@ array_realloc (int elem, void *base, int *cur, int cnt)
return ev_realloc (base, elem * *cur);
}
#define array_needsize_noinit(base,count)
#define array_needsize_noinit(base,offset,count)
#define array_needsize_zerofill(base,count) \
memset ((void *)(base), 0, sizeof (*(base)) * (count))
#define array_needsize_zerofill(base,offset,count) \
memset ((void *)(base + offset), 0, sizeof (*(base)) * (count))
#define array_needsize(type,base,cur,cnt,init) \
if (expect_false ((cnt) > (cur))) \
@ -2002,7 +2002,7 @@ array_realloc (int elem, void *base, int *cur, int cnt)
ecb_unused int ocur_ = (cur); \
(base) = (type *)array_realloc \
(sizeof (type), (base), &(cur), (cnt)); \
init ((base) + (ocur_), (cur) - ocur_); \
init ((base), ocur_, ((cur) - ocur_)); \
}
#if 0

26
ev_linuxaio.c

@ -127,17 +127,23 @@ typedef struct aniocb
inline_size
void
linuxaio_array_needsize_iocbp (ANIOCBP *base, int count)
linuxaio_array_needsize_iocbp (ANIOCBP *base, int offset, int count)
{
/* TODO: quite the overhead to allocate every iocb separately, maybe use our own alocator? */
while (count--)
{
*base = (ANIOCBP)ev_malloc (sizeof (**base));
/* TODO: full zero initialize required? */
memset (*base, 0, sizeof (**base));
/* would be nice to initialize fd/data as well, but array_needsize API doesn't support that */
(*base)->io.aio_lio_opcode = IOCB_CMD_POLL;
++base;
ANIOCBP iocb = (ANIOCBP)ev_malloc (sizeof (*iocb));
/* full zero initialise is probably not required at the moment, but
* this is not well documented, so we better do it.
*/
memset (iocb, 0, sizeof (*iocb));
iocb->io.aio_lio_opcode = IOCB_CMD_POLL;
iocb->io.aio_data = offset;
iocb->io.aio_fildes = offset;
base [offset++] = iocb;
}
}
@ -155,7 +161,7 @@ static void
linuxaio_modify (EV_P_ int fd, int oev, int nev)
{
array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp);
struct aniocb *iocb = linuxaio_iocbps [fd];
ANIOCBP iocb = linuxaio_iocbps [fd];
#if EPOLL_FALLBACK
if (iocb->io.aio_reqprio < 0)
@ -170,9 +176,7 @@ linuxaio_modify (EV_P_ int fd, int oev, int nev)
if (nev)
{
iocb->io.aio_data = fd;
iocb->io.aio_fildes = fd;
iocb->io.aio_buf =
iocb->io.aio_buf =
(nev & EV_READ ? POLLIN : 0)
| (nev & EV_WRITE ? POLLOUT : 0);

10
ev_poll.c

@ -41,10 +41,12 @@
inline_size
void
pollidx_init (int *base, int count)
array_needsize_pollidx (int *base, int offset, int count)
{
/* consider using memset (.., -1, ...), which is practically guaranteed
* to work on all systems implementing poll */
/* using memset (.., -1, ...) is tempting, we we try
* to be ultraportable
*/
base += offset;
while (count--)
*base++ = -1;
}
@ -57,7 +59,7 @@ poll_modify (EV_P_ int fd, int oev, int nev)
if (oev == nev)
return;
array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init);
array_needsize (int, pollidxs, pollidxmax, fd + 1, array_needsize_pollidx);
idx = pollidxs [fd];

Loading…
Cancel
Save