Skip to content

Commit

Permalink
libs/libc/aio: fix aio_cancel compatible issue
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
guoshichao authored and xiaoxiang781216 committed Jun 29, 2023
1 parent cf6a134 commit d5f45dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion fs/aio/aio_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
7 changes: 4 additions & 3 deletions include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions libs/libc/unistd/lib_sysconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d5f45dc

Please sign in to comment.