diff --git a/include/aio.h b/include/aio.h index 61965789e3..0e0d18994f 100644 --- a/include/aio.h +++ b/include/aio.h @@ -137,7 +137,9 @@ struct aiocb int aio_reqprio; /* Request priority offset */ int aio_lio_opcode; /* Operation to be performed */ - /* Non-standard, implementation-dependent data */ + /* Non-standard, implementation-dependent data. For portability reasons, + * application code should never reference these elements. + */ struct work_s aio_work; /* Used to defer I/O to the work thread */ pid_t aio_pid; /* ID of client to be notify at completion */ diff --git a/include/signal.h b/include/signal.h index 5d3c4654b2..2589881dc1 100644 --- a/include/signal.h +++ b/include/signal.h @@ -108,7 +108,6 @@ # define SIGPOLL CONFIG_SIG_POLL # endif #endif -#endif /* The following are non-standard signal definitions */ diff --git a/libc/aio/Make.defs b/libc/aio/Make.defs index 667490d1fd..2ec441a3af 100644 --- a/libc/aio/Make.defs +++ b/libc/aio/Make.defs @@ -38,6 +38,7 @@ ifeq ($(CONFIG_LIBC_AIO),y) # Add the asynchronous I/O C files to the build CSRCS += aio_read.c aio_write.c aio_return.c aio_error.c +CSRCS += aio_signal.c ifneq ($(CONFIG_PTHREAD_DISABLE),y) CSRCS += lio_listio.c diff --git a/libc/aio/aio.h b/libc/aio/aio.h index 9a103a4207..7b6e800d6a 100644 --- a/libc/aio/aio.h +++ b/libc/aio/aio.h @@ -77,4 +77,22 @@ extern "C" * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: aio_signal + * + * Description: + * Signal the client that an I/O has completed. + * + * Input Parameters: + * aiocbp - Pointer to the asynchronous I/O state structure that includes + * information about how to signal the client + * + * Returned Value: + * Zero (OK) if the client was successfully signalled. Otherwise, a + * negated errno value is returned. + * + ****************************************************************************/ + +int aio_signal(FAR struct aiocb *aiocbp); + #endif /* __LIBC_AIO_AIO_H */ diff --git a/libc/aio/aio_read.c b/libc/aio/aio_read.c index b1c4637ff7..366b7cb055 100644 --- a/libc/aio/aio_read.c +++ b/libc/aio/aio_read.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include #include @@ -120,17 +120,7 @@ static void aio_read_worker(FAR void *arg) /* Signal the client */ - if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL) - { - int ret; -#ifdef CONFIG_CAN_PASS_STRUCTS - ret = sigqueue(aiocbp->aio_pid, aiocbp->aio_sigevent.sigev_signo, - aiocbp->aio_sigevent.sigev_value); -#else - ret = sigqueue(aiocbp->aio_pid, aiocbp->aio_sigevent.sigev_sign, - aiocbp->aio_sigevent.sigev_value.sival_ptr); -#endif - } + (void)aio_signal(aiocbp); } /**************************************************************************** @@ -253,7 +243,7 @@ static void aio_read_worker(FAR void *arg) * ****************************************************************************/ -int aio_read(FAR struct aiocb *aiocbp); +int aio_read(FAR struct aiocb *aiocbp) { int ret; diff --git a/libc/aio/aio_write.c b/libc/aio/aio_write.c index 5576bec74b..84372c27d9 100644 --- a/libc/aio/aio_write.c +++ b/libc/aio/aio_write.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include #include @@ -151,17 +151,7 @@ static void aio_write_worker(FAR void *arg) /* Signal the client */ - if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL) - { - int ret; -#ifdef CONFIG_CAN_PASS_STRUCTS - ret = sigqueue(aiocbp->aio_pid, aiocbp->aio_sigevent.sigev_signo, - aiocbp->aio_sigevent.sigev_value); -#else - ret = sigqueue(aiocbp->aio_pid, aiocbp->aio_sigevent.sigev_sign, - aiocbp->aio_sigevent.sigev_value.sival_ptr); -#endif - } + (void)aio_signal(aiocbp); } /**************************************************************************** @@ -286,7 +276,7 @@ static void aio_write_worker(FAR void *arg) * ****************************************************************************/ -int aio_write(FAR struct aiocb *aiocbp); +int aio_write(FAR struct aiocb *aiocbp) { int ret;