From: Subrata <sub...@us...> - 2008-12-11 13:17:55
|
Update of /cvsroot/ltp/ltp/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27681/ltp/include Modified Files: tlibio.h Log Message: These patches enable AIO and listio in tlibio.c for linux, mostly by reusing code that is already in tlibio.c, and makes non-blocking read()/write() actually work. Also, they change pipeio.c to use this. Comments: 1) Patch 0001 enables aio and other types of io in tlibio.c code. Note that this means programs using functions from tlibio need linking with libaio and librt, 2) Patch 0002 changes non-blocking io in tlibio, so that it doesn't report EAGAIN to the client, but rather waits with select() for the io to become available (it would be possible extend this by adding more wait types). Also, it makes some minor changes to pipeio to make it work (eg. make opening the pipe always block, regardless of non-blocking setting). 3) Patch 0003 adds a semaphore to pipeio, to ensure all children have opened their pipes before reading & writing takes place. This avoids situations where one child gets to open the pipe after the parent deleted it (eg. because of an error). Also, it should eliminate all empty reads. 4) Patch 0004 changes error handling in pipeio to interpret every negative number as -errno. 5) Patch 0005 changes the way the end of the test is handled - before, the test ended after the last child was dead, but possibly before all data was read. The new way is to read all data and only if no data can be read, see if the children are dead. The patches should be applied in sequence. Signed-Off-By: JiÅÃ PaleÄek <jpa...@we...>, Index: tlibio.h =================================================================== RCS file: /cvsroot/ltp/ltp/include/tlibio.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tlibio.h 5 Dec 2005 19:14:50 -0000 1.3 --- tlibio.h 11 Dec 2008 13:17:49 -0000 1.4 *************** *** 42,46 **** #define LIO_IO_TYPES 00061 /* all io types, non-async */ #endif /* sgi */ ! #if defined(__linux__) || defined(__sun) || defined(__hpux) || defined(_AIX) #define LIO_IO_TYPES 00021 /* all io types */ #endif /* linux */ --- 42,50 ---- #define LIO_IO_TYPES 00061 /* all io types, non-async */ #endif /* sgi */ ! #if defined(__linux__) ! #define LIO_IO_TYPES 00061 /* all io types */ ! #define LIO_IO_ATYPES 00077 /* all io types */ ! #endif ! #if defined(__sun) || defined(__hpux) || defined(_AIX) #define LIO_IO_TYPES 00021 /* all io types */ #endif /* linux */ *************** *** 49,52 **** --- 53,60 ---- #endif /* CRAY */ + #ifndef LIO_IO_ATYPES + #define LIO_IO_ATYPES LIO_IO_TYPES + #endif + #define LIO_WAIT_NONE 00010000 /* return asap -- use with care */ #define LIO_WAIT_ACTIVE 00020000 /* spin looking at iosw fields, or EINPROGRESS */ *************** *** 54,58 **** #define LIO_WAIT_SIGPAUSE 00100000 /* call pause */ #define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */ ! #ifdef sgi #define LIO_WAIT_CBSUSPEND 00400000 /* aio_suspend waiting for callback */ #define LIO_WAIT_SIGSUSPEND 01000000 /* aio_suspend waiting for signal */ --- 62,66 ---- #define LIO_WAIT_SIGPAUSE 00100000 /* call pause */ #define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */ ! #if defined(sgi) || defined(__linux__) #define LIO_WAIT_CBSUSPEND 00400000 /* aio_suspend waiting for callback */ #define LIO_WAIT_SIGSUSPEND 01000000 /* aio_suspend waiting for signal */ *************** *** 60,64 **** #define LIO_WAIT_TYPES 00020000 /* all sync wait types (sorta) */ #endif /* sgi */ ! #if defined(__linux__) || defined(__sun) || defined(__hpux) || defined(_AIX) #define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */ #endif /* linux */ --- 68,72 ---- #define LIO_WAIT_TYPES 00020000 /* all sync wait types (sorta) */ #endif /* sgi */ ! #if defined(__sun) || defined(__hpux) || defined(_AIX) #define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */ #endif /* linux */ *************** *** 70,74 **** /* 00 000 0000 */ ! #ifdef sgi /* all callback wait types */ #define LIO_WAIT_CBTYPES (LIO_WAIT_CBSUSPEND) --- 78,82 ---- /* 00 000 0000 */ ! #if defined(sgi) || defined(__linux__) /* all callback wait types */ #define LIO_WAIT_CBTYPES (LIO_WAIT_CBSUSPEND) *************** *** 78,82 **** #define LIO_IO_ASYNC_TYPES (LIO_IO_ASYNC|LIO_IO_SLISTIO|LIO_IO_ALISTIO) #endif /* sgi */ ! #if defined(__linux__) || defined(__sun) || defined(__hpux) || defined(_AIX) /* all signal wait types */ #define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE) --- 86,90 ---- #define LIO_IO_ASYNC_TYPES (LIO_IO_ASYNC|LIO_IO_SLISTIO|LIO_IO_ALISTIO) #endif /* sgi */ ! #if defined(__sun) || defined(__hpux) || defined(_AIX) /* all signal wait types */ #define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE) *************** *** 130,138 **** int lio_check_asyncio(char *io_type, int size, struct iosw *status); #endif /* CRAY */ ! #ifdef sgi #include <aio.h> int lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp); int lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method); #endif /* sgi */ /* --- 138,151 ---- int lio_check_asyncio(char *io_type, int size, struct iosw *status); #endif /* CRAY */ ! #if defined (sgi) #include <aio.h> int lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp); int lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method); #endif /* sgi */ + #if defined(__linux__) + #include <aio.h> + int lio_wait4asyncio(int method, int fd, struct aiocb *aiocbp); + int lio_check_asyncio(char *io_type, int size, struct aiocb *aiocbp, int method); + #endif /* |