ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
emu_host_io.c File Reference

Bounded raw-descriptor host-I/O implementation. More...

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "emu_host_io_internal.h"
Include dependency graph for emu_host_io.c:

Go to the source code of this file.

Typedefs

typedef ssize_t(* internal_transfer_fn_t) (int fd, void *buf, size_t count, off_t offset)

Enumerations

enum  : size_t {
  k_emu_io_format_cap = 1024U ,
  k_emu_io_eintr_max = 8U
}

Functions

static RA8_INTERNAL ssize_t internal_read (int fd, void *buf, size_t count)
 Call the default sequential input primitive.
static RA8_INTERNAL ssize_t internal_write (int fd, const void *buf, size_t count)
 Call the default sequential output primitive.
static RA8_INTERNAL ssize_t internal_pread (int fd, void *buf, size_t count, off_t offset)
 Call the default positioned input primitive.
static RA8_INTERNAL ssize_t internal_pwrite (int fd, const void *buf, size_t count, off_t offset)
 Call the default positioned output primitive.
static RA8_INTERNAL emu_io_result_t internal_result (emu_io_status_t status, size_t transferred, int os_error)
 Construct one complete public operation result.
void priv_emu_io_configure (int out_fd, int err_fd, const emu_io_ops_t *ops)
 Inject process output descriptors and optional raw transfer hooks.
static RA8_INTERNAL emu_io_result_t internal_transfer (int fd, void *buf, size_t count, off_t offset, internal_transfer_fn_t fn, bool input)
 Complete one exact raw transfer with bounded EINTR retries.
static RA8_INTERNAL ssize_t internal_read_adapter (int fd, void *buf, size_t count, off_t offset)
 Adapt sequential input to the common positioned callback shape.
static RA8_INTERNAL ssize_t internal_write_adapter (int fd, void *buf, size_t count, off_t offset)
 Adapt sequential output to the common positioned callback shape.
static RA8_INTERNAL ssize_t internal_pread_adapter (int fd, void *buf, size_t count, off_t offset)
 Dispatch positioned input through the configured operation table.
static RA8_INTERNAL ssize_t internal_pwrite_adapter (int fd, void *buf, size_t count, off_t offset)
 Dispatch positioned output through the configured operation table.
emu_io_result_t priv_emu_io_read_exact (int fd, void *buf, size_t count)
 Read exactly count sequential bytes or report EOF/fault progress.
emu_io_result_t priv_emu_io_write_exact (int fd, const void *buf, size_t count)
 Write exactly count sequential bytes or report fault progress.
emu_io_result_t priv_emu_io_pread_exact (int fd, void *buf, size_t count, off_t offset)
 Read exactly count bytes at offset without changing the cursor.
emu_io_result_t priv_emu_io_pwrite_exact (int fd, const void *buf, size_t count, off_t offset)
 Write exactly count bytes at offset without changing the cursor.
static RA8_INTERNAL emu_io_result_t internal_vformat (int fd, const char *format, va_list args)
 Render one bounded format operation and write it exactly.
emu_io_result_t priv_emu_io_out_text (const char *text)
 Write a NUL-terminated literal to the injected output descriptor.
emu_io_result_t priv_emu_io_err_text (const char *text)
 Write a NUL-terminated literal to the injected error descriptor.
emu_io_result_t priv_emu_io_err_bytes (const void *bytes, size_t length)
 Write an exact non-NUL-terminated byte fragment to the error sink.
emu_io_result_t priv_emu_io_outf (const char *format,...)
 Format bounded text and write it to the injected output descriptor.
emu_io_result_t priv_emu_io_errf (const char *format,...)
 Format bounded text and write it to the injected error descriptor.
emu_io_result_t priv_emu_io_file_text (int fd, const char *text)
 Write a NUL-terminated literal to an explicit raw descriptor.
emu_io_result_t priv_emu_io_file_char (int fd, char value)
 Write one byte to an explicit raw descriptor.
emu_io_result_t priv_emu_io_filef (int fd, const char *format,...)
 Format bounded text and write it to an explicit raw descriptor.
emu_io_result_t priv_emu_io_open_read (const char *path, emu_io_file_t *file)
 Open and stat a regular file for bounded raw reading.
emu_io_result_t priv_emu_io_close (emu_io_file_t *file)
 Close and invalidate an owned raw file descriptor.
emu_io_result_t priv_emu_io_txn_begin (const char *path, emu_io_txn_t *txn)
 Create a sibling temporary output for failure-atomic publication.
emu_io_result_t priv_emu_io_txn_commit (emu_io_txn_t *txn)
 Sync, close, and atomically rename an active sibling transaction.
void priv_emu_io_txn_abort (emu_io_txn_t *txn)
 Close and unlink an active sibling transaction without publication.

Variables

static const emu_io_ops_t s_k_default_ops
static const emu_io_ops_ts_ops = &s_k_default_ops
static int s_out_fd = STDOUT_FILENO
static int s_err_fd = STDERR_FILENO

Detailed Description

Bounded raw-descriptor host-I/O implementation.

Implements bounded EINTR/short-I/O loops, memory-only formatting, descriptor-selected process sinks, regular-file reads, and atomic publication.

Since
0.1.0

Definition in file emu_host_io.c.

Typedef Documentation

◆ internal_transfer_fn_t

typedef ssize_t(* internal_transfer_fn_t) (int fd, void *buf, size_t count, off_t offset)

Definition at line 147 of file emu_host_io.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : size_t
Enumerator
k_emu_io_format_cap 

Per-call stack formatting capacity.

k_emu_io_eintr_max 

Consecutive EINTR retry bound.

Definition at line 22 of file emu_host_io.c.

Function Documentation

◆ internal_pread()

RA8_INTERNAL ssize_t internal_pread ( int fd,
void * buf,
size_t count,
off_t offset )
static

Call the default positioned input primitive.

Reads without changing the descriptor cursor.

Parameters
[in]fdRaw descriptor.
[out]bufDestination bytes.
[in]countRequested byte count.
[in]offsetStarting byte offset.
Returns
The host primitive result.
Return values
-1The host primitive failed.
Precondition
fd identifies an open seekable descriptor.
buf spans count writable bytes when count is nonzero.
Postcondition
The descriptor cursor is unchanged.
On failure errno contains the host error.
Note
Thread safety is inherited from the supplied descriptor.
Since
0.1.0

Definition at line 83 of file emu_host_io.c.

References RA8_INTERNAL.

Referenced by priv_fmt_host_source_open().

◆ internal_pread_adapter()

RA8_INTERNAL ssize_t internal_pread_adapter ( int fd,
void * buf,
size_t count,
off_t offset )
static

Dispatch positioned input through the configured operation table.

Preserves the exact offset passed by the transfer loop.

Parameters
[in]fdRaw descriptor.
[out]bufDestination bytes.
[in]countRequested byte count.
[in]offsetStarting byte offset.
Returns
Configured primitive result.
Return values
-1The configured primitive failed.
Precondition
The configured pread callback is non-null.
buf spans count writable bytes when nonzero.
Postcondition
Descriptor cursor state is controlled by the callback contract.
No other global state changes.
Note
Uses process-wide injected operations; not reconfiguration-safe.
Since
0.1.0

Definition at line 258 of file emu_host_io.c.

References RA8_INTERNAL, and s_ops.

Referenced by priv_emu_io_pread_exact().

◆ internal_pwrite()

RA8_INTERNAL ssize_t internal_pwrite ( int fd,
const void * buf,
size_t count,
off_t offset )
static

Call the default positioned output primitive.

Writes without changing the descriptor cursor.

Parameters
[in]fdRaw descriptor.
[in]bufSource bytes.
[in]countRequested byte count.
[in]offsetStarting byte offset.
Returns
The host primitive result.
Return values
-1The host primitive failed.
Precondition
fd identifies an open seekable descriptor.
buf spans count readable bytes when count is nonzero.
Postcondition
The descriptor cursor is unchanged.
On failure errno contains the host error.
Note
Thread safety is inherited from the supplied descriptor.
Since
0.1.0

Definition at line 104 of file emu_host_io.c.

References RA8_INTERNAL.

◆ internal_pwrite_adapter()

RA8_INTERNAL ssize_t internal_pwrite_adapter ( int fd,
void * buf,
size_t count,
off_t offset )
static

Dispatch positioned output through the configured operation table.

Preserves the exact offset passed by the transfer loop.

Parameters
[in]fdRaw descriptor.
[in,out]bufSource bytes carried in the common mutable callback shape.
[in]countRequested byte count.
[in]offsetStarting byte offset.
Returns
Configured primitive result.
Return values
-1The configured primitive failed.
Precondition
The configured pwrite callback is non-null.
buf spans count readable bytes when nonzero.
Postcondition
Descriptor cursor state is controlled by the callback contract.
No other global state changes.
Note
Uses process-wide injected operations; not reconfiguration-safe.
Since
0.1.0

Definition at line 279 of file emu_host_io.c.

References RA8_INTERNAL, and s_ops.

Referenced by priv_emu_io_pwrite_exact().

◆ internal_read()

RA8_INTERNAL ssize_t internal_read ( int fd,
void * buf,
size_t count )
static

Call the default sequential input primitive.

Thin hook target keeping production and injected operations shape-compatible.

Parameters
[in]fdRaw descriptor.
[out]bufDestination bytes.
[in]countRequested byte count.
Returns
The host primitive result.
Return values
-1The host primitive failed.
Precondition
fd identifies an open descriptor.
buf spans count writable bytes when count is nonzero.
Postcondition
The descriptor cursor advances by the returned positive count.
On failure errno contains the host error.
Note
Thread safety is inherited from the supplied descriptor.
Since
0.1.0

Definition at line 42 of file emu_host_io.c.

References RA8_INTERNAL.

◆ internal_read_adapter()

RA8_INTERNAL ssize_t internal_read_adapter ( int fd,
void * buf,
size_t count,
off_t offset )
static

Adapt sequential input to the common positioned callback shape.

Ignores offset and dispatches through the configured operation table.

Parameters
[in]fdRaw descriptor.
[out]bufDestination bytes.
[in]countRequested byte count.
[in]offsetIgnored compatibility offset.
Returns
Configured primitive result.
Return values
-1The configured primitive failed.
Precondition
The configured read callback is non-null.
buf spans count writable bytes when nonzero.
Postcondition
Sequential cursor effects come only from the configured callback.
No other global state changes.
Note
Uses process-wide injected operations; not reconfiguration-safe.
Since
0.1.0

Definition at line 214 of file emu_host_io.c.

References RA8_INTERNAL, and s_ops.

Referenced by priv_emu_io_read_exact().

◆ internal_result()

RA8_INTERNAL emu_io_result_t internal_result ( emu_io_status_t status,
size_t transferred,
int os_error )
static

Construct one complete public operation result.

Centralises field initialisation for every result path.

Parameters
[in]statusSemantic operation status.
[in]transferredCompleted byte count.
[in]os_errorCaptured host error.
Returns
Fully initialised result value.
Return values
emu_io_result_tThe supplied fields in their corresponding members.
Precondition
status is a valid emu_io_status_t value.
transferred reflects only completed bytes.
Postcondition
Every result member is initialised.
No global or host state changes.
Note
Pure value constructor; thread-safe.
Since
0.1.0

Definition at line 135 of file emu_host_io.c.

Referenced by internal_transfer(), internal_vformat(), priv_emu_io_close(), priv_emu_io_err_text(), priv_emu_io_file_text(), priv_emu_io_open_read(), priv_emu_io_out_text(), priv_emu_io_txn_begin(), and priv_emu_io_txn_commit().

◆ internal_transfer()

RA8_INTERNAL emu_io_result_t internal_transfer ( int fd,
void * buf,
size_t count,
off_t offset,
internal_transfer_fn_t fn,
bool input )
static

Complete one exact raw transfer with bounded EINTR retries.

Repeats partial operations, resets the retry budget after progress, and reports EOF.

Parameters
[in]fdRaw descriptor.
[in,out]bufTransfer buffer.
[in]countExact requested byte count.
[in]offsetInitial positioned-I/O offset.
[in]fnInjected transfer primitive.
[in]inputTrue for EOF semantics, false for zero-write error semantics.
Returns
Complete status, progress, and captured errno.
Return values
emu_io_result_tThe exact transfer outcome.
Precondition
fn is non-null for a valid request.
buf spans count bytes when count is nonzero.
Postcondition
Success reports exactly count transferred bytes.
Failure reports only bytes completed before the fault.
Note
At most eight consecutive EINTR responses are retried.
Since
0.1.0

Definition at line 167 of file emu_host_io.c.

References internal_result(), k_emu_io_eintr_max, k_emu_io_eof, k_emu_io_error, k_emu_io_invalid, k_emu_io_ok, and RA8_INTERNAL.

Referenced by priv_emu_io_pread_exact(), priv_emu_io_pwrite_exact(), priv_emu_io_read_exact(), and priv_emu_io_write_exact().

◆ internal_vformat()

RA8_INTERNAL emu_io_result_t internal_vformat ( int fd,
const char * format,
va_list args )
static

Render one bounded format operation and write it exactly.

Uses memory-only formatting and emits no partial text when truncation is detected.

Parameters
[in]fdDestination raw descriptor.
[in]formatFormat string.
[in]argsFormat arguments.
Returns
Complete formatting/write result.
Return values
emu_io_result_tSuccess, truncation, invalid input, or host failure.
Precondition
fd is non-negative.
format is non-null and matches args.
Postcondition
Truncation writes zero bytes.
Success writes the complete formatted payload exactly once in order.
Note
The fixed 1024-byte scratch buffer lives on the caller stack.
Since
0.1.0

Definition at line 319 of file emu_host_io.c.

References internal_result(), k_emu_io_error, k_emu_io_format_cap, k_emu_io_invalid, k_emu_io_truncated, priv_emu_io_write_exact(), and RA8_INTERNAL.

Referenced by priv_emu_io_errf(), priv_emu_io_filef(), and priv_emu_io_outf().

◆ internal_write()

RA8_INTERNAL ssize_t internal_write ( int fd,
const void * buf,
size_t count )
static

Call the default sequential output primitive.

Thin hook target keeping production and injected operations shape-compatible.

Parameters
[in]fdRaw descriptor.
[in]bufSource bytes.
[in]countRequested byte count.
Returns
The host primitive result.
Return values
-1The host primitive failed.
Precondition
fd identifies an open descriptor.
buf spans count readable bytes when count is nonzero.
Postcondition
The descriptor cursor advances by the returned positive count.
On failure errno contains the host error.
Note
Thread safety is inherited from the supplied descriptor.
Since
0.1.0

Definition at line 62 of file emu_host_io.c.

References RA8_INTERNAL.

◆ internal_write_adapter()

RA8_INTERNAL ssize_t internal_write_adapter ( int fd,
void * buf,
size_t count,
off_t offset )
static

Adapt sequential output to the common positioned callback shape.

Ignores offset and dispatches through the configured operation table.

Parameters
[in]fdRaw descriptor.
[in,out]bufSource bytes carried in the common mutable callback shape.
[in]countRequested byte count.
[in]offsetIgnored compatibility offset.
Returns
Configured primitive result.
Return values
-1The configured primitive failed.
Precondition
The configured write callback is non-null.
buf spans count readable bytes when nonzero.
Postcondition
Sequential cursor effects come only from the configured callback.
No other global state changes.
Note
Uses process-wide injected operations; not reconfiguration-safe.
Since
0.1.0

Definition at line 236 of file emu_host_io.c.

References RA8_INTERNAL, and s_ops.

Referenced by priv_emu_io_write_exact().

◆ priv_emu_io_close()

emu_io_result_t priv_emu_io_close ( emu_io_file_t * file)
nodiscard

Close and invalidate an owned raw file descriptor.

Definition at line 415 of file emu_host_io.c.

References internal_result(), k_emu_io_error, k_emu_io_invalid, and k_emu_io_ok.

Referenced by board_sd_attach(), load_panel(), and priv_emu_elf_source_close().

◆ priv_emu_io_configure()

void priv_emu_io_configure ( int out_fd,
int err_fd,
const emu_io_ops_t * ops )

Inject process output descriptors and optional raw transfer hooks.

Selects composition-owned destinations and production or test raw operations.

Parameters
[in]out_fdDescriptor used by output-sink calls.
[in]err_fdDescriptor used by error-sink calls.
[in]opsComplete operation table, or nullptr for production syscalls.
Precondition
out_fd and err_fd are valid for their intended calls.
Non-null ops supplies all four callbacks.
Postcondition
Subsequent sink calls use the supplied descriptors.
Subsequent transfer calls use ops or the production table.
Note
Process-wide composition step; not thread-safe with active transfers.
Since
0.1.0

Definition at line 140 of file emu_host_io.c.

References s_err_fd, s_k_default_ops, s_ops, and s_out_fd.

Referenced by main().

◆ priv_emu_io_err_bytes()

emu_io_result_t priv_emu_io_err_bytes ( const void * bytes,
size_t length )
nodiscard

Write an exact non-NUL-terminated byte fragment to the error sink.

Definition at line 350 of file emu_host_io.c.

References priv_emu_io_write_exact(), and s_err_fd.

Referenced by internal_prof_name_chunk().

◆ priv_emu_io_err_text()

emu_io_result_t priv_emu_io_err_text ( const char * text)
nodiscard

Write a NUL-terminated literal to the injected error descriptor.

Definition at line 344 of file emu_host_io.c.

References internal_result(), k_emu_io_invalid, priv_emu_io_write_exact(), s_err_fd, and strlen().

Referenced by internal_args_print_usage(), internal_prof_print_incl_self_table(), internal_prof_print_phase(), and prof_report().

◆ priv_emu_io_errf()

emu_io_result_t priv_emu_io_errf ( const char * format,
... )
nodiscard

Format bounded text and write it to the injected error descriptor.

Definition at line 364 of file emu_host_io.c.

References internal_vformat(), and s_err_fd.

Referenced by board_eink_report(), board_modem_report(), board_net_on_tx(), board_net_report(), board_periph_icu_raise_event(), board_periph_note_irq_taken(), board_periph_register_block(), board_periph_sci_feed_rx(), board_sd_attach(), board_sd_attach_blank(), board_sd_save(), board_usb_bridge_dcp_in_take(), board_usb_host_report(), board_usb_host_write(), board_usb_report(), div0_patch_sites(), div0_seam_install(), emu_mmio_print_bgc_and_table(), emu_mmio_print_counts(), emu_tz_install(), fast_sd_seam_install(), internal_adc_report(), internal_adc_write(), internal_args_attach_blank_sd(), internal_bkup_report(), internal_cac_report(), internal_canfd_loopback_deliver(), internal_canfd_report(), internal_ceu_do_capture(), internal_ceu_report(), internal_cpu1_engine_init(), internal_crc_report(), internal_dac_report(), internal_dac_write(), internal_div0_scan_segment(), internal_dmac_report(), internal_dmac_run_transfer(), internal_doc_report(), internal_drw_report(), internal_dtc_report(), internal_eth_report(), internal_glcdc_report(), internal_gptp_report(), internal_guard_setup_record(), internal_i3c_report(), internal_install_seg_hooks(), internal_ipc_report(), internal_ipc_write(), internal_lvd_report(), internal_main_apply_button_battery(), internal_main_arm_touch_seq(), internal_main_feed_inputs(), internal_main_load_ns(), internal_main_load_primary(), internal_main_open_engine(), internal_main_open_memory(), internal_main_open_presentation(), internal_main_reset_vector(), internal_main_resolve_symbols(), internal_map_periph_mmio(), internal_map_regions(), internal_mram_report(), internal_mstp_report(), internal_net_rx_icmp(), internal_net_rx_tcp(), internal_net_tcp_on_estab(), internal_npu_report(), internal_on_sym_trace(), internal_on_unmapped(), internal_pdctr_report(), internal_pdm_report(), internal_poeg_report(), internal_port_report(), internal_port_trace_leds(), internal_prcr_report(), internal_prof_print_boot_timeline(), internal_prof_print_incl_self_table(), internal_prof_print_phase(), internal_report_created(), internal_report_irqs(), internal_report_unhandled_insn(), internal_reset_report(), internal_riic_report(), internal_rtc_raise_events(), internal_rtc_report(), internal_rtt_report(), internal_run_classify_click(), internal_run_open_view(), internal_run_print_dump_syms(), internal_run_print_sd_summary(), internal_run_print_stop_summary(), internal_run_print_verdict(), internal_sci_report(), internal_sdhi_report(), internal_spi_report(), internal_sram_report(), internal_ssie_report(), internal_stream_segment(), internal_timer_report(), internal_ulpt_report(), internal_ulpt_tick_channel(), internal_usb_hid_decode_report(), internal_usbhs_do_setup(), internal_usbhs_report(), internal_wdt_report(), internal_xspi_report(), load_elf(), load_panel(), long_shift_seam_install(), priv_riic_devices_report(), priv_run_hold_view(), priv_run_write_outputs(), priv_usb_log_line(), prof_load(), prof_report(), sym_trace_install(), usbh_seam_install(), and warm_reboot().

◆ priv_emu_io_file_char()

emu_io_result_t priv_emu_io_file_char ( int fd,
char value )
nodiscard

Write one byte to an explicit raw descriptor.

Definition at line 379 of file emu_host_io.c.

References priv_emu_io_write_exact().

Referenced by internal_prof_js_frames(), internal_prof_json_samples(), and internal_prof_name_chunk().

◆ priv_emu_io_file_text()

emu_io_result_t priv_emu_io_file_text ( int fd,
const char * text )
nodiscard

Write a NUL-terminated literal to an explicit raw descriptor.

Definition at line 373 of file emu_host_io.c.

References internal_result(), k_emu_io_invalid, priv_emu_io_write_exact(), and strlen().

Referenced by internal_prof_js_frames(), internal_prof_json_frames(), internal_prof_write_html(), and internal_prof_write_speedscope().

◆ priv_emu_io_filef()

emu_io_result_t priv_emu_io_filef ( int fd,
const char * format,
... )
nodiscard

Format bounded text and write it to an explicit raw descriptor.

Definition at line 384 of file emu_host_io.c.

References internal_vformat().

Referenced by internal_prof_json_samples(), internal_prof_json_weights(), internal_prof_write_html(), internal_prof_write_speedscope(), and write_ppm().

◆ priv_emu_io_open_read()

emu_io_result_t priv_emu_io_open_read ( const char * path,
emu_io_file_t * file )
nodiscard

Open and stat a regular file for bounded raw reading.

Definition at line 393 of file emu_host_io.c.

References internal_result(), k_emu_io_error, k_emu_io_invalid, k_emu_io_ok, and O_CLOEXEC.

Referenced by board_sd_attach(), load_panel(), and priv_emu_elf_source_open().

◆ priv_emu_io_out_text()

emu_io_result_t priv_emu_io_out_text ( const char * text)
nodiscard

Write a NUL-terminated literal to the injected output descriptor.

Definition at line 338 of file emu_host_io.c.

References internal_result(), k_emu_io_invalid, priv_emu_io_write_exact(), s_out_fd, and strlen().

◆ priv_emu_io_outf()

emu_io_result_t priv_emu_io_outf ( const char * format,
... )
nodiscard

Format bounded text and write it to the injected output descriptor.

Definition at line 355 of file emu_host_io.c.

References internal_vformat(), and s_out_fd.

Referenced by console_flush_line(), internal_on_itm_stim_write(), and internal_rtt_line_feed().

◆ priv_emu_io_pread_exact()

emu_io_result_t priv_emu_io_pread_exact ( int fd,
void * buf,
size_t count,
off_t offset )
nodiscard

Read exactly count bytes at offset without changing the cursor.

Definition at line 294 of file emu_host_io.c.

References internal_pread_adapter(), and internal_transfer().

Referenced by board_view_read_rgb888_fd(), emu_presentation_read(), internal_copy_bytes(), priv_board_sd_storage_read(), and priv_emu_elf_read().

◆ priv_emu_io_pwrite_exact()

emu_io_result_t priv_emu_io_pwrite_exact ( int fd,
const void * buf,
size_t count,
off_t offset )
nodiscard

Write exactly count bytes at offset without changing the cursor.

Definition at line 299 of file emu_host_io.c.

References internal_pwrite_adapter(), and internal_transfer().

Referenced by emu_presentation_snapshot(), emu_presentation_write(), internal_copy_bytes(), internal_write_sector(), and priv_board_sd_storage_write().

◆ priv_emu_io_read_exact()

emu_io_result_t priv_emu_io_read_exact ( int fd,
void * buf,
size_t count )
nodiscard

Read exactly count sequential bytes or report EOF/fault progress.

Definition at line 284 of file emu_host_io.c.

References internal_read_adapter(), and internal_transfer().

Referenced by load_panel().

◆ priv_emu_io_txn_abort()

void priv_emu_io_txn_abort ( emu_io_txn_t * txn)

Close and unlink an active sibling transaction without publication.

Releases any temporary descriptor/path while preserving the final target.

Parameters
[in,out]txnTransaction to abandon; nullptr is accepted.
Precondition
Non-null txn was zero-initialised or passed to priv_emu_io_txn_begin().
The caller no longer intends to commit txn.
Postcondition
Any owned descriptor is closed and set to -1.
Any named sibling temporary is unlinked and cleared.
Note
Does not modify the final target path.
Since
0.1.0

Definition at line 467 of file emu_host_io.c.

References emu_io_txn_t::fd, and emu_io_txn_t::temp.

Referenced by board_sd_save(), internal_prof_write_html(), internal_prof_write_speedscope(), and write_ppm().

◆ priv_emu_io_txn_begin()

emu_io_result_t priv_emu_io_txn_begin ( const char * path,
emu_io_txn_t * txn )
nodiscard

Create a sibling temporary output for failure-atomic publication.

Definition at line 427 of file emu_host_io.c.

References emu_io_txn_t::fd, emu_io_txn_t::final, internal_result(), k_emu_io_error, k_emu_io_invalid, k_emu_io_ok, k_emu_io_truncated, and emu_io_txn_t::temp.

Referenced by board_sd_save(), internal_prof_write_html(), internal_prof_write_speedscope(), and write_ppm().

◆ priv_emu_io_txn_commit()

emu_io_result_t priv_emu_io_txn_commit ( emu_io_txn_t * txn)
nodiscard

Sync, close, and atomically rename an active sibling transaction.

Definition at line 447 of file emu_host_io.c.

References emu_io_txn_t::fd, emu_io_txn_t::final, internal_result(), k_emu_io_error, k_emu_io_invalid, k_emu_io_ok, and emu_io_txn_t::temp.

Referenced by board_sd_save(), internal_prof_write_html(), internal_prof_write_speedscope(), and write_ppm().

◆ priv_emu_io_write_exact()

emu_io_result_t priv_emu_io_write_exact ( int fd,
const void * buf,
size_t count )
nodiscard

Write exactly count sequential bytes or report fault progress.

Definition at line 289 of file emu_host_io.c.

References internal_transfer(), and internal_write_adapter().

Referenced by internal_vformat(), internal_write_ppm_pixels(), priv_emu_io_err_bytes(), priv_emu_io_err_text(), priv_emu_io_file_char(), priv_emu_io_file_text(), and priv_emu_io_out_text().

Variable Documentation

◆ s_err_fd

int s_err_fd = STDERR_FILENO
static

◆ s_k_default_ops

const emu_io_ops_t s_k_default_ops
static
Initial value:
= {
.read_fn = internal_read,
.write_fn = internal_write,
.pread_fn = internal_pread,
.pwrite_fn = internal_pwrite,
}
static RA8_INTERNAL ssize_t internal_pread(int fd, void *buf, size_t count, off_t offset)
Call the default positioned input primitive.
Definition emu_host_io.c:83
static RA8_INTERNAL ssize_t internal_pwrite(int fd, const void *buf, size_t count, off_t offset)
Call the default positioned output primitive.
static ra8_err_t internal_write(void *ctx, void *file_state, const uint8_t *src, uint32_t len, uint32_t *out_written)
static ra8_err_t internal_read(void *ctx, void *file_state, uint8_t *dst, uint32_t cap, uint32_t *out_read)

Definition at line 109 of file emu_host_io.c.

Referenced by priv_emu_io_configure().

◆ s_ops

◆ s_out_fd

int s_out_fd = STDOUT_FILENO
static

Definition at line 116 of file emu_host_io.c.

Referenced by priv_emu_io_configure(), priv_emu_io_out_text(), and priv_emu_io_outf().