|
SafeAPI Backend POSIX
POSIX/Linux OAL backend for safeAPIFreamwork
|
POSIX sapi_ipc backend: one pipe() per channel (ADR-018 section 2.2/2.3 - a mutex+condvar ring buffer would not fit sapi_ipc's 64-byte opaque storage on glibc; a pipe lets the kernel own the queue instead). More...
#include "safeapi/posix_backend/sapi_posix_backend.h"#include <errno.h>#include <fcntl.h>#include <poll.h>#include <time.h>#include <unistd.h>Go to the source code of this file.
Data Structures | |
| struct | posix_ipc_state_t |
Typedefs | |
| typedef char | posix_ipc_storage_fits_[(sizeof(posix_ipc_state_t)<=sizeof(sapi_ipc_storage_t)) ? 1 :-1] |
Functions | |
| static int | remaining_ms (const struct timespec *deadline) |
| static void | compute_deadline (sapi_duration_ms_t timeout_ms, struct timespec *out_deadline) |
| static sapi_status_t | transfer_all (int fd, const void *write_src, void *read_dst, size_t size, sapi_duration_ms_t timeout_ms, bool read_not_write) |
| static sapi_status_t | backend_create (sapi_ipc_storage_t *storage, const sapi_ipc_config_t *config, sapi_ipc_handle_t *out_handle) |
| static sapi_status_t | backend_send (sapi_ipc_handle_t handle, const void *message, size_t message_size, sapi_duration_ms_t timeout_ms) |
| static sapi_status_t | backend_receive (sapi_ipc_handle_t handle, void *out_message, size_t buffer_size, sapi_duration_ms_t timeout_ms) |
| static sapi_status_t | backend_destroy (sapi_ipc_handle_t handle) |
| const sapi_ipc_backend_t * | sapi_posix_backend_ipc (void) |
| The POSIX sapi_ipc backend (pipe() per channel). | |
Variables | |
| static const sapi_ipc_backend_t | s_posix_ipc_backend |
POSIX sapi_ipc backend: one pipe() per channel (ADR-018 section 2.2/2.3 - a mutex+condvar ring buffer would not fit sapi_ipc's 64-byte opaque storage on glibc; a pipe lets the kernel own the queue instead).
Known simplification (stated in ADR-018): a message larger than the pipe's remaining buffer that partially transfers before timeout_ms expires leaves a partial message in the pipe for the next receive() - acceptable for a first cut, not hardened for production.
Definition in file sapi_posix_backend_ipc.c.
| #define _GNU_SOURCE |
Definition at line 5 of file sapi_posix_backend_ipc.c.
| typedef char posix_ipc_storage_fits_[(sizeof(posix_ipc_state_t)<=sizeof(sapi_ipc_storage_t)) ? 1 :-1] |
Definition at line 34 of file sapi_posix_backend_ipc.c.
|
static |
Definition at line 132 of file sapi_posix_backend_ipc.c.
|
static |
Definition at line 195 of file sapi_posix_backend_ipc.c.
|
static |
Definition at line 183 of file sapi_posix_backend_ipc.c.
|
static |
Definition at line 171 of file sapi_posix_backend_ipc.c.
|
static |
Definition at line 56 of file sapi_posix_backend_ipc.c.
|
static |
Milliseconds remaining until deadline, clamped to >= 0; -1 if now() itself fails (caller treats that as "no time left").
Definition at line 38 of file sapi_posix_backend_ipc.c.
| const sapi_ipc_backend_t * sapi_posix_backend_ipc | ( | void | ) |
The POSIX sapi_ipc backend (pipe() per channel).
Definition at line 211 of file sapi_posix_backend_ipc.c.
|
static |
Shared poll-then-transfer loop. read_not_write selects direction; write_src/read_dst are mutually exclusive (only the one matching read_not_write's value is dereferenced) - kept as two parameters rather than one non-const void* so neither caller has to cast away const to use this helper.
Definition at line 73 of file sapi_posix_backend_ipc.c.
|
static |
Definition at line 208 of file sapi_posix_backend_ipc.c.