--- IO-AIO/AIO.xs 2006/10/23 22:44:21 1.61 +++ IO-AIO/AIO.xs 2006/10/23 23:48:31 1.63 @@ -1,4 +1,9 @@ +#if __linux +# define _GNU_SOURCE +#endif + #define _REENTRANT 1 + #include #include "EXTERN.h" @@ -111,8 +116,14 @@ static int max_outstanding = 1<<30; static int respipe [2]; -static pthread_mutex_t reslock = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t reqlock = PTHREAD_MUTEX_INITIALIZER; +#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) +# define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP +#else +# define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +#endif + +static pthread_mutex_t reslock = AIO_MUTEX_INIT; +static pthread_mutex_t reqlock = AIO_MUTEX_INIT; static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; static volatile aio_req reqs, reqe; /* queue start, queue end */ @@ -193,6 +204,8 @@ static void poll_wait () { + fd_set rfd; + while (nreqs) { aio_req req; @@ -203,7 +216,6 @@ if (req) return; - fd_set rfd; FD_ZERO(&rfd); FD_SET(respipe [0], &rfd);