summaryrefslogtreecommitdiff
path: root/apps/examples
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-05 13:57:55 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-05 13:57:55 -0600
commitcb1b0f39a06f94ef1c52996b742179ab125a4338 (patch)
treea2667d171ebc62d5904a490a6741bec330280547 /apps/examples
parent7effc6f22568ccf7adc0add4eb150698e49fd5d4 (diff)
downloadnuttx-cb1b0f39a06f94ef1c52996b742179ab125a4338.tar.gz
nuttx-cb1b0f39a06f94ef1c52996b742179ab125a4338.tar.bz2
nuttx-cb1b0f39a06f94ef1c52996b742179ab125a4338.zip
First round of changes fo AIO integration
Diffstat (limited to 'apps/examples')
-rw-r--r--apps/examples/ostest/Kconfig2
-rw-r--r--apps/examples/ostest/aio.c26
-rw-r--r--apps/examples/ostest/ostest.h6
3 files changed, 23 insertions, 11 deletions
diff --git a/apps/examples/ostest/Kconfig b/apps/examples/ostest/Kconfig
index d19650bd3..b40ee3311 100644
--- a/apps/examples/ostest/Kconfig
+++ b/apps/examples/ostest/Kconfig
@@ -43,7 +43,7 @@ config EXAMPLES_OSTEST_AIO
if EXAMPLES_OSTEST_AIO
config EXAMPLES_OSTEST_AIOPATH
- bool "Scratch file path"
+ string "Scratch file path"
default "/tmp"
---help---
This is the location of a directory in a mounted file system that
diff --git a/apps/examples/ostest/aio.c b/apps/examples/ostest/aio.c
index 9fb16c098..b98480840 100644
--- a/apps/examples/ostest/aio.c
+++ b/apps/examples/ostest/aio.c
@@ -42,8 +42,11 @@
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
+#include <signal.h>
+#include <string.h>
#include <fcntl.h>
#include <aio.h>
+#include <errno.h>
#include "ostest.h"
@@ -77,9 +80,9 @@ static struct aiocb g_aiocbs[AIO_NCTRLBLKS-1];
static struct aiocb *g_aiocb[AIO_NCTRLBLKS] =
{
&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 *)NULL,
@@ -123,11 +126,13 @@ static void init_aiocb(bool signal)
for (i = 0; i < AIO_NCTRLBLKS; i++)
{
- aiocbp = &g_aiocbp[i];
+ aiocbp = g_aiocb[i];
if (aiocbp)
{
- aiocbp->sigev_notify = signal ? SIGEV_SIGNAL : SIGEV_NONE;
- aiocbp->aio_buf = g_buffer[i];
+ aiocbp->aio_sigevent.sigev_notify = signal ? SIGEV_SIGNAL : SIGEV_NONE;
+ aiocbp->aio_sigevent.sigev_signo = SIGUSR1;
+
+ aiocbp->aio_buf = g_buffers[i];
aiocbp->aio_offset = (off_t)g_offsets[i];
aiocbp->aio_nbytes = (size_t)g_nbytes[i];
aiocbp->aio_fildes = g_fildes;
@@ -185,7 +190,7 @@ static int check_done(void)
* Public Functions
****************************************************************************/
-int aio_test(void)
+void aio_test(void)
{
int ret;
@@ -195,16 +200,16 @@ int aio_test(void)
g_fildes = open(AIO_FILEPATH, O_RDWR|O_CREAT|O_TRUNC);
if (g_fildes < 0)
{
- printf(aio_test: Failed to open %s: %d\n", AIO_FILEPATH, errno);
- return ERROR;
+ printf("aio_test: Failed to open %s: %d\n", AIO_FILEPATH, errno);
+ return;
}
init_aiocb(false);
ret = lio_listio(LIO_NOWAIT, g_aiocb, AIO_NCTRLBLKS, NULL);
if (ret < 0)
{
- printf(aio_test: lio_listio failed: %d\n", errno);
- return ERROR;
+ printf("aio_test: lio_listio failed: %d\n", errno);
+ return;
}
do
@@ -223,6 +228,7 @@ int aio_test(void)
/* Case 3: Use individual signals */
/* REVISIT: Not yet implemented */
+
}
#endif /* CONFIG_LIBC_AIO */
diff --git a/apps/examples/ostest/ostest.h b/apps/examples/ostest/ostest.h
index a14b4ff6e..b99bb15c7 100644
--- a/apps/examples/ostest/ostest.h
+++ b/apps/examples/ostest/ostest.h
@@ -111,6 +111,12 @@ int dev_null(void);
void fpu_test(void);
+/* aio.c ********************************************************************/
+
+#ifdef CONFIG_LIBC_AIO
+void aio_test(void);
+#endif
+
/* restart.c ****************************************************************/
void restart_test(void);