You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/06/29 15:25:39 UTC

[nuttx] branch master updated: libs/libc/aio: fix aio_cancel compatible issue

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new d5f45dc33b libs/libc/aio: fix aio_cancel compatible issue
d5f45dc33b is described below

commit d5f45dc33b262f6da0fe8724499f0fd8f5e596f1
Author: guoshichao <gu...@xiaomi.com>
AuthorDate: Fri Jun 9 21:04:16 2023 +0800

    libs/libc/aio: fix aio_cancel compatible issue
    
    1. make the aio_cancel implementation can pass the
    ltp/open_posix_testsuite/aio_cancel testcases
    2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_cancel.html
    
    Signed-off-by: guoshichao <gu...@xiaomi.com>
---
 fs/aio/aio_cancel.c            | 8 +++++++-
 include/unistd.h               | 7 ++++---
 libs/libc/unistd/lib_sysconf.c | 8 ++++++++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/fs/aio/aio_cancel.c b/fs/aio/aio_cancel.c
index 8337149f51..ac8b4119a9 100644
--- a/fs/aio/aio_cancel.c
+++ b/fs/aio/aio_cancel.c
@@ -81,6 +81,12 @@
 
 int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
 {
+  if (fildes < 0)
+    {
+      set_errno(EBADF);
+      return ERROR;
+    }
+
   FAR struct aio_container_s *aioc;
   FAR struct aio_container_s *next;
   pid_t pid;
@@ -95,7 +101,7 @@ int aio_cancel(int fildes, FAR struct aiocb *aiocbp)
 
   ret = AIO_ALLDONE;
   sched_lock();
-  ret = aio_lock();
+  aio_lock();
 
   if (aiocbp)
     {
diff --git a/include/unistd.h b/include/unistd.h
index 5bd2dfe762..5d7eefcd57 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -61,14 +61,15 @@
 #undef  _POSIX_FSYNC
 #define _POSIX_SYNCHRONIZED_IO 1
 
+#define _POSIX_VERSION 201712L
+#define _POSIX_PRIORITIZED_IO _POSIX_VERSION
+
 #ifdef CONFIG_FS_AIO
-#  define _POSIX_ASYNCHRONOUS_IO 1
+#  define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
 #else
 #  undef  _POSIX_ASYNCHRONOUS_IO
 #endif
 
-#undef  _POSIX_PRIORITIZED_IO
-
 #ifdef CONFIG_SCHED_SPORADIC
 #  define _POSIX_SPORADIC_SERVER 1
 #  define _POSIX_THREAD_SPORADIC_SERVER 1
diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c
index 8246a2eb17..4890a7290b 100644
--- a/libs/libc/unistd/lib_sysconf.c
+++ b/libs/libc/unistd/lib_sysconf.c
@@ -215,6 +215,14 @@ long sysconf(int name)
 
   switch (name)
     {
+#ifdef CONFIG_FS_AIO
+      case _SC_ASYNCHRONOUS_IO:
+        return _POSIX_ASYNCHRONOUS_IO;
+#endif
+      case _SC_PRIORITIZED_IO:
+        return _POSIX_PRIORITIZED_IO;
+      case _SC_AIO_MAX:
+        return _POSIX_AIO_MAX;
       case _SC_CLK_TCK:
         return CLOCKS_PER_SEC;