tlibio: Detect <aio.h> support
PATCH v2 1/1 tlibio: Detect <aio.h> support
From: Petr Vorel <[email protected]>
Some libc (i.e. uclibc-ng or uclibc) does not implement <aio.h>. Requiring it for the core LTP library breaks build of these libc. Restore unintentional removal in fed3e3ee63.
Changes:
* Fix for all libc without <aio.h> support: previous check 'defined(__linux__) && !defined(__UCLIBC__)' was uclibc-ng specific (and check for __linux__ was not needed anyway). All of these used prior fed3e3ee63 is replaced just by HAVE_AIO_H.
* Comment out also if block first and last 'line if (...) {' and '}' if the block would be empty anyway.
* Further join preprocessor checks as code prior fed3e3ee63 contained code compiled for old unixes (e.g. sgi), which fed3e3ee63 removed.
* Remove nested preprocessors checks in code which is already checked (i.e. lio_wait4asyncio()).
* Fix wrong #endif comments.
* Add further cleanup of old unixes.
I also wonder if #else part of struct lio_info_type Lio_info1[] should be really defined for code without <aio.h>.
---
Changes v1->v2:
* instead of hardcoding UCLIBC add a proper configure check for <aio.h> (Cyril)
* join 2 commits into single
v1:
https://lore.kernel.org/ltp/[email protected]/
https://patchwork.ozlabs.org/project/ltp/list/?series=466584&state=*
Kind regards,
Petr
configure.ac | 1 + lib/tlibio.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-)
configure.ac +1 -0
@@ -48,6 +48,7 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP, PR_CAPBSET_READ],,,[#include <sys/prctl.h>]) AC_CHECK_DECLS([SEM_STAT_ANY],,,[#include <sys/sem.h>]) AC_CHECK_HEADERS_ONCE([ \ + aio.h \ asm/ldt.h \ asm/prctl.h \ cpuid.h \
lib/tlibio.c +43 -9
254 lines not on this page · raw message
Signature · 5 lines
2.50.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 24 lines · Petr Vorel
From: Petr Vorel <[email protected]>
Some libc (i.e. uclibc-ng or uclibc) does not implement <
aio.h>. Requiring it for the core LTP library breaks build of these libc. Restore unintentional removal infed3e3ee63.Changes:
* Fix for all libc without <aio.h> support: previous check 'defined(__linux__)&& !defined(__UCLIBC__)' was uclibc-ng specific (and check for__linux__was not needed anyway). All of these used priorfed3e3ee63is replaced just byHAVE_AIO_H.
* Comment out also if block first and last 'line if (...) {' and '}' if the block would be empty anyway.
* Further join preprocessor checks as code priorfed3e3ee63contained code compiled for old unixes (e.g. sgi), whichfed3e3ee63removed.
* Remove nested preprocessors checks in code which is already checked (i.e.lio_wait4asyncio()).
* Fix wrong #endif comments.
* Add further cleanup of old unixes.I also wonder if #else part of struct
lio_info_typeLio_info1[] should be really defined for code without <aio.h>.Fixes fed3e3ee63 ("lib/tlibio: Get rid of support for old UNIXes")
Quoted 14 lines
Fixes:
https://autobuild.buildroot.org/results/f3e/f3e03b9a1a69988d6497f36c9d64a37a66e9ad20/
Fixes:
https://autobuild.buildroot.org/results/856/856365f467efc449faee1951250e63d8d4442bbc/
Fixes:
https://autobuild.buildroot.org/results/2ac/2ac08cecd6a505f1bac1a673efc280b3a8dcb23a/
Fixes:
https://autobuild.buildroot.org/results/59b/59b3ad33667b7e87c81e49dd434d5f494e189e0d/
Fixes:
https://autobuild.buildroot.org/results/b1a/b1a36f9971c97300670d8d772ace11e5fedceaaa/
Signed-off-by
<https://autobuild.buildroot.org/results/b1a/b1a36f9971c97300670d8d772ace11e5fedceaaa/Signed-off-by>:
Petr Vorel <[email protected]>
---
Quoted 355 lines
Changes
v1->v2:
* instead of hardcoding UCLIBC add a proper configure check for <aio.h> (Cyril)
* join 2 commits into singlev1:
https://lore.kernel.org/ltp/[email protected]/
https://patchwork.ozlabs.org/project/ltp/list/?series=466584&state=*Kind regards,
Petrconfigure.ac | 1 + lib/tlibio.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-)configure.ac +1
-0@@ -48,6 +48,7 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP, PR_CAPBSET_READ],,,[#include <sys/prctl.h>]) AC_CHECK_DECLS([SEM_STAT_ANY],,,[#include <sys/sem.h>]) AC_CHECK_HEADERS_ONCE([ \ + aio.h \ asm/ldt.h \ asm/prctl.h \cpuid.h \lib/tlibio.c +4
-2@@ -88,7 +88,9 @@#include <stdint.h> #include <sys/uio.h> /* readv(2)/writev(2) */ #include <string.h> -#include <aio.h> +#ifdef HAVE_AIO_H +# include <aio.h> +#endif #include <stdlib.h> /* atoi, abs */ #include "tlibio.h" /* defines LIO* macros */ @@ -108,7 +110,7 @@ struct lio_info_type Lio_info1[] = { {"b", LIO_IO_ASYNC | LIO_WAIT_SIGPAUSE, "async i/o using pause"}, {"a", LIO_IO_ASYNC | LIO_WAIT_RECALL, "async i/o using recall/aio_suspend"}, -#if defined(sgi) || (defined(__linux__) && !defined(__UCLIBC__)) +#ifdef HAVE_AIO_H {"r",LIO_RANDOM |LIO_IO_TYPES |LIO_WAIT_TYPES , "random sync i/o types and wait methods"},@@ -159,7 +161,7 @@ char Lio_SysCall[PATH_MAX]; /* string containing lasti/o system call */
static volatile int
Received_signal= 0; /* number of signals
received */
static volatile intRec_signal;lib/tlibio.c +1
-1-#if defined(sgi) || (defined(__linux__) && !defined(__UCLIBC__)) +#ifdef HAVE_AIO_H static volatile int Received_callback =0 ;/* number of callbacks received */
static volatile intRec_callback;
#endiflib/tlibio.c +2
-2@@ -399,7 +401,7 @@ static void lio_async_signal_handler(int sig)return ; } -#if defined(sgi) || (defined(__linux__) && !defined(__UCLIBC__)) +#ifdef HAVE_AIO_H /*********************************************************************** * This is an internal callback handler. * If the handler is called, it will increment the Received_callback @@ -417,7 +419,7 @@ static void lio_async_callback_handler(union sigval sigval) return; } -#endif /* sgi */ +#endif /*********************************************************************** *
lio_random_methodslib/tlibio.c +0
-0@@ -515,9 +517,11 @@ int lio_write_buffer(int fd, /* openfile descriptor */
int omethod = method;
intlistio_cmd; /* Holds the listio/lio_listio cmd */
struct iovec iov; /* iovec for writev(2) */
+#ifdefHAVE_AIO_H
struct aiocb aiocbp; /* POSIX aio control block */
struct aiocb *aiolist[1]; /* list of aio control blocks forlio_listio*/
off64_tpoffset; /* pwrite(2) offset */lib/tlibio.c +1
-0+#endif /* * If LIO_RANDOM bit specified, get new method randomly. @@ -536,12 +540,15 @@ int lio_write_buffer(int fd, /* openfile descriptor */
*errmsg = Errormsg;
Rec_signal=Received_signal; /* get the current number of
signals received */
+#ifdefHAVE_AIO_H
Rec_callback=Received_callback; /* get the current number
of callbacks received */lib/tlibio.c +2
-0+#endif memset (&iov,0x00 ,sizeof (struct iovec )); iov.iov_base = buffer; iov.iov_len = size; +#ifdef HAVE_AIO_H memset (&aiocbp,0x00 ,sizeof (struct aiocb )); aiocbp.aio_fildes = fd;@@ -589,6 +596,7 @@ int lio_write_buffer(int fd, /* openfile descriptor */
poffset = (off64_t) ret; aiocbp.aio_offset = ret;lib/tlibio.c +1
-0+#endif /* * If the LIO_USE_SIGNAL bit is not set, only use the signal @@ -597,9 +605,9 @@ int lio_write_buffer(int fd, /* openfile descriptor */
* the signal. */ if (sig && !(method & LIO_USE_SIGNAL) && !(method &
LIO_WAIT_SIGTYPES)) {lib/tlibio.c +1
-1- sig =0 ;/* ignore signal parameter */ } +#ifdef HAVE_AIO_H if (sig && (method &LIO_WAIT_CBTYPES )) sig =0 ;/* ignore signal parameter */ @@ -626,6 +634,7 @@ int lio_write_buffer(int fd, /* openfile descriptor */
aiocbp.aio_sigevent.sigev_notify_attributes = (void *)(uintptr_t) size; }lib/tlibio.c +1
-0+#endif /* * Determine the system call that will be called and produce @@ -684,6 +693,7 @@ int lio_write_buffer(int fd, /* openfile descriptor */
} else if (method & LIO_IO_ASYNC) { +#ifdef HAVE_AIO_H sprintf(Lio_SysCall, "aio_write(fildes=%d, buf, nbytes=%d, signo=%d)", fd, size, sig);lib/tlibio.c +0
-0@@ -705,9 +715,11 @@ int lio_write_buffer(int fd, /* openfile descriptor */
sigrelse(sig); return -errno; }lib/tlibio.c +2
-0+#endif }/* LIO_IO_ASYNC */ else if (method &LIO_IO_SLISTIO ) { +#ifdef HAVE_AIO_H aiocbp.aio_lio_opcode =LIO_WRITE ; listio_cmd =LIO_WAIT ; io_type ="lio_listio(3) sync write" ;@@ -739,9 +751,11 @@ int lio_write_buffer(int fd, /* openfile descriptor */
ret = lio_check_asyncio(io_type, size, &aiocbp, method); return ret;lib/tlibio.c +2
-0+#endif }/* LIO_IO_SLISTIO */ else if (method &LIO_IO_ALISTIO ) { +#ifdef HAVE_AIO_H aiocbp.aio_lio_opcode =LIO_WRITE ; listio_cmd =LIO_NOWAIT ; io_type ="lio_listio(3) async write" ;@@ -766,6 +780,7 @@ int lio_write_buffer(int fd, /* openfile descriptor */
sigrelse(sig); return -errno; }lib/tlibio.c +1
-0+#endif }/* LIO_IO_ALISTIO */ else if (method &LIO_IO_SYNCV ) {@@ -796,6 +811,7 @@ int lio_write_buffer(int fd, /* openfile descriptor */
return ret; } /* LIO_IO_SYNCV */lib/tlibio.c +1
-0+#ifdef HAVE_AIO_H else if (method & LIO_IO_SYNCP) { io_type ="pwrite(2)" ;@@ -827,6 +843,7 @@ int lio_write_buffer(int fd, /* openfile descriptor */
return ret; } /* LIO_IO_SYNCP */lib/tlibio.c +1
-0+#endif else {printf ("DEBUG %s/%d: No I/O method chosen\n" , __FILE__, __LINE__);@@ -836,7 +853,9 @@ int lio_write_buffer(int fd, /* openfile descriptor */
/* * wait for async io to complete. */lib/tlibio.c +2
-0+#ifdef HAVE_AIO_H ret =lio_wait4asyncio (method, fd, &aiocbp); +#endif /* * If there was an error waiting for async i/o to complete, @@ -862,7 +881,9 @@ int lio_write_buffer(int fd, /* openfile descriptor */
* have been updated but the actual i/o size if returned. */lib/tlibio.c +2
-0+#ifdef HAVE_AIO_H ret =lio_check_asyncio (io_type, size, &aiocbp, method); +#endif return ret; }/* end of lio_write_buffer */ @@ -924,9 +945,11 @@ int lio_read_buffer(int fd, /* open filedescriptor */
intlistio_cmd; /* Holds the listio/lio_listio cmd */
int omethod = method;
struct iovec iov; /* iovec for readv(2) */
+#ifdefHAVE_AIO_H
struct aiocb aiocbp; /* POSIX aio control block */
struct aiocb *aiolist[1]; /* list of aio control blocks forlio_listio*/
off64_tpoffset; /* pread(2) offset */lib/tlibio.c +1
-0+#endif /* * If LIO_RANDOM bit specified, get new method randomly. @@ -945,12 +968,15 @@ int lio_read_buffer(int fd, /* open filedescriptor */
*errmsg = Errormsg;
Rec_signal=Received_signal; /* get the current number of
signals received */
+#ifdefHAVE_AIO_H
Rec_callback=Received_callback; /* get the current number
of callbacks received */lib/tlibio.c +2
-0+#endif memset (&iov,0x00 ,sizeof (struct iovec )); iov.iov_base = buffer; iov.iov_len = size; +#ifdef HAVE_AIO_H memset (&aiocbp,0x00 ,sizeof (struct aiocb )); aiocbp.aio_fildes = fd;@@ -998,6 +1024,7 @@ int lio_read_buffer(int fd, /* open filedescriptor */
} poffset = (off64_t) ret; aiocbp.aio_offset = ret;lib/tlibio.c +1
-0+#endif /* * If the LIO_USE_SIGNAL bit is not set, only use the signal @@ -1010,6 +1037,7 @@ int lio_read_buffer(int fd, /* open filedescriptor */
sig = 0; /* ignore signal parameter */
}lib/tlibio.c +1
-0+#ifdef HAVE_AIO_H if (sig && (method &LIO_WAIT_CBTYPES )) sig =0 ;/* ignore signal parameter */ @@ -1020,7 +1048,6 @@ int lio_read_buffer(int fd, /* open filedescriptor */
* old signal handler will not be restored. *** restoring the signal handler could be added *** */lib/tlibio.c +0
-1-if (sig && (method &LIO_WAIT_SIGTYPES )) { aiocbp.aio_sigevent.sigev_notify =SIGEV_SIGNAL ; aiocbp.aio_sigevent.sigev_signo = sig;@@ -1035,6 +1062,7 @@ int lio_read_buffer(int fd, /* open filedescriptor */
aiocbp.aio_sigevent.sigev_notify_attributes = (void *)(uintptr_t) size; }lib/tlibio.c +1
-0+#endif /* * Determine the system call that will be called and produce @@ -1093,6 +1121,7 @@ int lio_read_buffer(int fd, /* open filedescriptor */
wait4sync_io(fd, 1); }+#ifdef
HAVE_AIO_H} else if (method & LIO_IO_ASYNC) { sprintf(Lio_SysCall, "aio_read(fildes=%d, buf, nbytes=%d, signo=%d)",fd,
lib/tlibio.c +0
-0@@ -1236,7 +1265,8 @@ int lio_read_buffer(int fd, /* open filedescriptor */
__FILE__, __LINE__, ret); return ret;lib/tlibio.c +2
-1- }/* LIO_IO_SYNCP */ +#endif + }else { printf("DEBUG %s/%d: No I/O method chosen\n", __FILE__,@@ -1248,7 +1278,9 @@ int lio_read_buffer(int fd, /* open filedescriptor */
* wait for async io to complete.
* Note: Sync io should have returned prior to getting here. */lib/tlibio.c +2
-0+#ifdef HAVE_AIO_H ret =lio_wait4asyncio (method, fd, &aiocbp); +#endif /* * If there was an error waiting for async i/o to complete, @@ -1274,12 +1306,14 @@ int lio_read_buffer(int fd, /* open filedescriptor */
* have been updated but the actual i/o size if returned. */lib/tlibio.c +3
-2+#ifdef HAVE_AIO_H ret =lio_check_asyncio (io_type, size, &aiocbp, method); +#endif return ret; }/* end of lio_read_buffer */ -#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) +#ifdef HAVE_AIO_H /*********************************************************************** * This function will check that async io was successful. * It can also be used to check sync listio since it uses the -- 2.50.0
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
This one looks good.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
Li, Cyril, thanks for your review, merged.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp