First round of changes fo AIO integration

This commit is contained in:
Gregory Nutt 2014-10-05 13:57:55 -06:00
parent 8a805d05f9
commit 52c7880c67
3 changed files with 23 additions and 11 deletions

View File

@ -43,7 +43,7 @@ config EXAMPLES_OSTEST_AIO
if EXAMPLES_OSTEST_AIO if EXAMPLES_OSTEST_AIO
config EXAMPLES_OSTEST_AIOPATH config EXAMPLES_OSTEST_AIOPATH
bool "Scratch file path" string "Scratch file path"
default "/tmp" default "/tmp"
---help--- ---help---
This is the location of a directory in a mounted file system that This is the location of a directory in a mounted file system that

View File

@ -42,8 +42,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h>
#include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <aio.h> #include <aio.h>
#include <errno.h>
#include "ostest.h" #include "ostest.h"
@ -77,9 +80,9 @@ static struct aiocb g_aiocbs[AIO_NCTRLBLKS-1];
static struct aiocb *g_aiocb[AIO_NCTRLBLKS] = static struct aiocb *g_aiocb[AIO_NCTRLBLKS] =
{ {
&g_aiocbs[0], &g_aiocbs[1], &g_aiocbs[2], NULL, &g_aiocbs[3] &g_aiocbs[0], &g_aiocbs[1], &g_aiocbs[2], NULL, &g_aiocbs[3]
} };
static const FAR void *g_buffers[AIO_NCTRLBLKS] = static FAR void * const g_buffers[AIO_NCTRLBLKS] =
{ {
(FAR void *)g_wrbuffer1, (FAR void *)g_wrbuffer1,
(FAR void *)NULL, (FAR void *)NULL,
@ -123,11 +126,13 @@ static void init_aiocb(bool signal)
for (i = 0; i < AIO_NCTRLBLKS; i++) for (i = 0; i < AIO_NCTRLBLKS; i++)
{ {
aiocbp = &g_aiocbp[i]; aiocbp = g_aiocb[i];
if (aiocbp) if (aiocbp)
{ {
aiocbp->sigev_notify = signal ? SIGEV_SIGNAL : SIGEV_NONE; aiocbp->aio_sigevent.sigev_notify = signal ? SIGEV_SIGNAL : SIGEV_NONE;
aiocbp->aio_buf = g_buffer[i]; aiocbp->aio_sigevent.sigev_signo = SIGUSR1;
aiocbp->aio_buf = g_buffers[i];
aiocbp->aio_offset = (off_t)g_offsets[i]; aiocbp->aio_offset = (off_t)g_offsets[i];
aiocbp->aio_nbytes = (size_t)g_nbytes[i]; aiocbp->aio_nbytes = (size_t)g_nbytes[i];
aiocbp->aio_fildes = g_fildes; aiocbp->aio_fildes = g_fildes;
@ -185,7 +190,7 @@ static int check_done(void)
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
int aio_test(void) void aio_test(void)
{ {
int ret; int ret;
@ -195,16 +200,16 @@ int aio_test(void)
g_fildes = open(AIO_FILEPATH, O_RDWR|O_CREAT|O_TRUNC); g_fildes = open(AIO_FILEPATH, O_RDWR|O_CREAT|O_TRUNC);
if (g_fildes < 0) if (g_fildes < 0)
{ {
printf(aio_test: Failed to open %s: %d\n", AIO_FILEPATH, errno); printf("aio_test: Failed to open %s: %d\n", AIO_FILEPATH, errno);
return ERROR; return;
} }
init_aiocb(false); init_aiocb(false);
ret = lio_listio(LIO_NOWAIT, g_aiocb, AIO_NCTRLBLKS, NULL); ret = lio_listio(LIO_NOWAIT, g_aiocb, AIO_NCTRLBLKS, NULL);
if (ret < 0) if (ret < 0)
{ {
printf(aio_test: lio_listio failed: %d\n", errno); printf("aio_test: lio_listio failed: %d\n", errno);
return ERROR; return;
} }
do do
@ -223,6 +228,7 @@ int aio_test(void)
/* Case 3: Use individual signals */ /* Case 3: Use individual signals */
/* REVISIT: Not yet implemented */ /* REVISIT: Not yet implemented */
} }
#endif /* CONFIG_LIBC_AIO */ #endif /* CONFIG_LIBC_AIO */

View File

@ -111,6 +111,12 @@ int dev_null(void);
void fpu_test(void); void fpu_test(void);
/* aio.c ********************************************************************/
#ifdef CONFIG_LIBC_AIO
void aio_test(void);
#endif
/* restart.c ****************************************************************/ /* restart.c ****************************************************************/
void restart_test(void); void restart_test(void);