posix: add stubs for asynchronous io
Add stubs for POSIX asynchronous io that return -1 and set errno to ENOTSUP. The functions and structures in aio.h are required by the _POSIX_ASYNCHRONOUS_IO Option as detailed in Section E.1 of IEEE-1003.1-2017. The _POSIX_ASYNCHRONOUS_IO interface is required for PSE51, PSE52, PSE53, and PSE54 conformance, and is otherwise mandatory for any POSIX conforming system as per Section A.2.1.3 of IEEE-1003-1.2017. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
83f090a710
commit
cdb1193f3e
46
include/zephyr/posix/aio.h
Normal file
46
include/zephyr/posix/aio.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2024 Tenstorrent AI ULC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_
|
||||
#define ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct aiocb {
|
||||
int aio_fildes;
|
||||
off_t aio_offset;
|
||||
volatile void *aio_buf;
|
||||
size_t aio_nbytes;
|
||||
int aio_reqprio;
|
||||
struct sigevent aio_sigevent;
|
||||
int aio_lio_opcode;
|
||||
};
|
||||
|
||||
#if _POSIX_C_SOURCE >= 200112L
|
||||
|
||||
int aio_cancel(int fildes, struct aiocb *aiocbp);
|
||||
int aio_error(const struct aiocb *aiocbp);
|
||||
int aio_fsync(int filedes, struct aiocb *aiocbp);
|
||||
int aio_read(struct aiocb *aiocbp);
|
||||
ssize_t aio_return(struct aiocb *aiocbp);
|
||||
int aio_suspend(const struct aiocb *const list[], int nent, const struct timespec *timeout);
|
||||
int aio_write(struct aiocb *aiocbp);
|
||||
int lio_listio(int mode, struct aiocb *const ZRESTRICT list[], int nent,
|
||||
struct sigevent *ZRESTRICT sig);
|
||||
|
||||
#endif /* _POSIX_C_SOURCE >= 200112L */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_ */
|
|
@ -37,7 +37,7 @@ extern "C" {
|
|||
|
||||
/* Constants for Options and Option Groups */
|
||||
#define _POSIX_ADVISORY_INFO (-1L)
|
||||
#define _POSIX_ASYNCHRONOUS_IO (-1L)
|
||||
#define _POSIX_ASYNCHRONOUS_IO Z_SC_VAL_IFDEF(CONFIG_POSIX_ASYNCHRONOUS_IO, _POSIX_VERSION)
|
||||
#define _POSIX_BARRIERS Z_SC_VAL_IFDEF(CONFIG_PTHREAD_IPC, _POSIX_VERSION)
|
||||
#define _POSIX_CHOWN_RESTRICTED (-1L)
|
||||
#define _POSIX_CLOCK_SELECTION Z_SC_VAL_IFDEF(CONFIG_POSIX_CLOCK, _POSIX_VERSION)
|
||||
|
|
|
@ -37,6 +37,7 @@ add_subdirectory_ifdef(CONFIG_GETOPT getopt)
|
|||
zephyr_library_sources_ifdef(CONFIG_EVENTFD eventfd.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POSIX_API perror.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POSIX_ASYNCHRONOUS_IO aio.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK nanosleep.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c)
|
||||
|
|
|
@ -25,6 +25,7 @@ config PTHREAD_IPC
|
|||
|
||||
endif # POSIX_CLOCK
|
||||
|
||||
rsource "Kconfig.aio"
|
||||
rsource "Kconfig.barrier"
|
||||
rsource "Kconfig.clock"
|
||||
rsource "Kconfig.cond"
|
||||
|
|
10
lib/posix/options/Kconfig.aio
Normal file
10
lib/posix/options/Kconfig.aio
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Copyright (c) 2024 Tenstorrent AI ULC
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config POSIX_ASYNCHRONOUS_IO
|
||||
bool "Asynchronous IO"
|
||||
default y if POSIX_API
|
||||
help
|
||||
Enable this option for asynchronous I/O. This option is present for conformance purposes
|
||||
only. All functions listed in <aio.h> return -1 and set errno to ENOSYS.
|
82
lib/posix/options/aio.c
Normal file
82
lib/posix/options/aio.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright 2024 Tenstorrent AI ULC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <zephyr/posix/aio.h>
|
||||
|
||||
int aio_cancel(int fildes, struct aiocb *aiocbp)
|
||||
{
|
||||
ARG_UNUSED(fildes);
|
||||
ARG_UNUSED(aiocbp);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int aio_error(const struct aiocb *aiocbp)
|
||||
{
|
||||
ARG_UNUSED(aiocbp);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int aio_fsync(int fildes, struct aiocb *aiocbp)
|
||||
{
|
||||
ARG_UNUSED(fildes);
|
||||
ARG_UNUSED(aiocbp);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int aio_read(struct aiocb *aiocbp)
|
||||
{
|
||||
ARG_UNUSED(aiocbp);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t aio_return(struct aiocb *aiocbp)
|
||||
{
|
||||
ARG_UNUSED(aiocbp);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int aio_suspend(const struct aiocb *const list[], int nent, const struct timespec *timeout)
|
||||
{
|
||||
ARG_UNUSED(list);
|
||||
ARG_UNUSED(nent);
|
||||
ARG_UNUSED(timeout);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int aio_write(struct aiocb *aiocbp)
|
||||
{
|
||||
ARG_UNUSED(aiocbp);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lio_listio(int mode, struct aiocb *const ZRESTRICT list[], int nent,
|
||||
struct sigevent *ZRESTRICT sig)
|
||||
{
|
||||
ARG_UNUSED(mode);
|
||||
ARG_UNUSED(list);
|
||||
ARG_UNUSED(nent);
|
||||
ARG_UNUSED(sig);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
Loading…
Reference in a new issue