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

Project-owned freestanding C runtime ABI primitives. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for ra8_freestanding.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * memset (void *dst, int value, size_t n)
 Fill memory with a constant byte value.
void * memcpy (void *dst, const void *src, size_t n)
 Copy memory area between non-overlapping regions.
void * memmove (void *dst, const void *src, size_t n)
 Copy memory area between potentially overlapping regions.
int memcmp (const void *a, const void *b, size_t n)
 Compare bytes in two memory areas.
void * memchr (const void *s, int c, size_t n)
 Locate a byte in a memory area.
size_t strlen (const char *s)
 Calculate string length.
size_t strnlen (const char *s, size_t maxlen)
 Calculate bounded string length.
int strcmp (const char *s1, const char *s2)
 Compare two null-terminated strings.
int strncmp (const char *s1, const char *s2, size_t n)
 Compare two strings up to a specified length.
char * strchr (const char *s, int c)
 Locate first occurrence of character in string.
char * strrchr (const char *s, int c)
 Locate last occurrence of character in string.
char * strstr (const char *haystack, const char *needle)
 Locate substring in string.
char * strcpy (char *dst, const char *src)
 Copy string to destination buffer.
char * strncpy (char *dst, const char *src, size_t n)
 Copy bounded string to destination buffer.
int abs (int j)
 Compute absolute value of integer.

Detailed Description

Project-owned freestanding C runtime ABI primitives.

Tag
[Ring 0 / Foundation] {World: Dual}

Declares standard compiler-required memory, string, and integer primitives implemented directly in target firmware without libc or newlib dependencies. Satisfies standard ABI contracts required by GCC and clang codegen while ensuring all implementations are bounded, deterministic, and heap-free.

Since
0.1.0

Definition in file ra8_freestanding.h.

Function Documentation

◆ abs()

int abs ( int j)

Compute absolute value of integer.

Returns the absolute value of j.

Parameters
[in]jSigned integer value.
Returns
Absolute value of j.
Return values
valueNon-negative absolute value.
Precondition
j is not INT_MIN (which cannot be represented as positive int).
Standard integer evaluation context.
Postcondition
Returned value is non-negative.
Input j is unmodified.
Note
Pure arithmetic function; never allocates; reentrant and thread-safe.
Since
0.1.0

Returns the non-negative magnitude of j.

Parameters
[in]jSigned integer value.
Returns
Absolute value of j.
Return values
valueNon-negative integer.
Precondition
j is not INT_MIN.
Standard two's complement integer environment.
Postcondition
Returned value is non-negative.
Input j is unmodified.
Note
Pure arithmetic function; never allocates; reentrant and thread-safe.
Since
0.1.0

Definition at line 34 of file ra8_freestanding_math.c.

Referenced by internal_emit_hit(), internal_emit_tag_url(), and sh_src_string().

◆ memchr()

void * memchr ( const void * s,
int c,
size_t n )

Locate a byte in a memory area.

Scans the initial n bytes of s for the first instance of c.

Parameters
[in]sPointer to memory buffer.
[in]cByte value to search for (interpreted as unsigned char).
[in]nMaximum bytes to examine.
Returns
Pointer to matching byte, or nullptr if not found.
Return values
non-nullPointer to matching byte within s.
nullptrByte not found within first n bytes, or n is zero.
Precondition
s points to at least n readable bytes if n > 0.
s is valid and addressable.
Postcondition
Memory buffer is unmodified.
Returned pointer is within [s, s + n) on success.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory is not concurrently modified.
Since
0.1.0

Scans the initial n bytes of s for the first instance of c.

Parameters
[in]sPointer to memory buffer.
[in]cByte value to search for.
[in]nMaximum bytes to examine.
Returns
Pointer to matching byte, or nullptr if not found.
Return values
non-nullPointer to matching byte within s.
nullptrByte not found within first n bytes, or n is zero.
Precondition
s points to at least n readable bytes if n > 0.
s is addressable and valid.
Postcondition
Memory buffer is unmodified.
Returned pointer is within [s, s + n) on success.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory is not concurrently modified.
Since
0.1.0

Definition at line 164 of file ra8_freestanding_mem.c.

Referenced by elf_string_foreach(), internal_extract_class(), internal_extract_label(), internal_extract_meta(), internal_rtt_match_stage(), internal_scan_tags(), internal_urlname_path_start(), and mdl_extract_hits().

◆ memcmp()

int memcmp ( const void * a,
const void * b,
size_t n )

Compare bytes in two memory areas.

Compares the first n bytes of memory areas a and b as unsigned char values.

Parameters
[in]aFirst memory area pointer.
[in]bSecond memory area pointer.
[in]nMaximum number of bytes to compare.
Returns
Difference between first differing bytes, or 0 if all equal.
Return values
0All n bytes match or n is zero.
<0First differing byte in a is less than in b.
>0First differing byte in a is greater than in b.
Precondition
a points to at least n readable bytes if n > 0.
b points to at least n readable bytes if n > 0.
Postcondition
Input buffers are unmodified.
Comparison is based on unsigned byte values per ISO C standard.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Compares the first n bytes of a and b as unsigned char.

Parameters
[in]aFirst memory area pointer.
[in]bSecond memory area pointer.
[in]nMaximum number of bytes to compare.
Returns
Negative if a < b, positive if a > b, 0 if equal.
Return values
0All n bytes match or n is zero.
<0First differing byte in a is less than in b.
>0First differing byte in a is greater than in b.
Precondition
a points to at least n readable bytes if n > 0.
b points to at least n readable bytes if n > 0.
Postcondition
Input buffers are unmodified.
Comparison semantics follow unsigned byte order.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Definition at line 136 of file ra8_freestanding_mem.c.

Referenced by cdc_echo_round(), demo_read_verify(), demo_restore(), demo_write_verify(), dfu_upload_verify(), er_image_loader(), er_nav_chapter(), fs_fmt_create_and_verify(), fs_fmt_rename_and_verify(), gcm_dec_ok(), gcm_enc_ok(), hid_read_round(), hid_read_round(), internal_attr_duplicate(), internal_bpp(), internal_bytes_equal(), internal_c6_cam_request_is(), internal_cache_decode(), internal_compare(), internal_cookie_field_is(), internal_data_offset(), internal_decode_entity(), internal_demo_read_once(), internal_demo_roundtrip(), internal_demo_roundtrip(), internal_demo_verify_cert_pin(), internal_dispatch(), internal_drive(), internal_end(), internal_format(), internal_is_webp(), internal_is_webp(), internal_jof_is_webp(), internal_kat_one(), internal_key_eq(), internal_mdl_state_decode_header(), internal_mdl_state_scan_slot(), internal_mdl_transfer_commit(), internal_name_chunk(), internal_net_tcp_on_estab(), internal_one_round_trip(), internal_parse_header_region(), internal_probe(), internal_probe_sniff(), internal_program_table(), internal_ra8_io_roundtrip_read_verify(), internal_rtt_drain(), internal_rtt_match_stage(), internal_section_table(), internal_swap_vfs_read_verify(), internal_tc_blob_roundtrip(), internal_upload_verify(), internal_urlname_last_path_marker(), internal_verify_book(), internal_zip_scan_window_for_eocd(), jof_parse(), kat_sha256(), microsd_verify_one(), mlun_verify_one(), ns_host_echo_round(), ospirw_verify_one(), priv_jof_png_prologue(), ra8_io_roundtrip_read_verify(), sdhi_card_block_roundtrip(), sdhi_demo_read_and_verify(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_ospi_raw(), sh_paged_hdr_ok(), verify_blob(), wlun_verify_one(), and worker_is_webp().

◆ memcpy()

void * memcpy ( void * dst,
const void * src,
size_t n )

Copy memory area between non-overlapping regions.

Copies n bytes from memory area src to memory area dst. The memory areas must not overlap.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource buffer pointer.
[in]nNumber of bytes to copy.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst and src do not overlap.
dst and src point to at least n valid bytes if n > 0.
Postcondition
The n bytes at dst match the n bytes at src.
Source memory is unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Copies n bytes from src to dst sequentially.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource buffer pointer.
[in]nNumber of bytes to copy.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst and src do not overlap.
dst and src point to at least n valid bytes if n > 0.
Postcondition
The n bytes at dst match the n bytes at src.
Source memory is unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Definition at line 70 of file ra8_freestanding_mem.c.

Referenced by app_flash_readback(), app_make_cfg(), app_make_manifest(), app_net_read(), board_net_poll_rx(), board_sd_read_block(), board_usb_bridge_bulk_in_take(), board_usb_bridge_bulk_out(), board_usb_bridge_dcp_in_take(), board_usb_bridge_dcp_out(), board_usb_feed_bulk_in(), board_usb_loop_bulk_out(), board_usb_loop_ctrl_out(), board_usbhs_host_shadow_handoff(), board_view_read_rgb888_fd(), book_src_read(), book_src_resident(), cb_host_output_open(), cb_trace_bind(), cm_ct_read(), cm_read(), comic_page_info(), demo_fat_fill_boot(), demo_fat_fill_boot(), demo_fat_fill_root(), demo_fat_fill_root(), demo_fat_fill_sector(), demo_msc_read(), demo_msc_write(), dfu_read(), dfu_write(), emulate_mve(), epub_miniz_realloc(), internal_apply_cookie_line(), internal_arena_realloc(), internal_arena_valid(), internal_authority_of(), internal_backing_read(), internal_bd_copy_slice(), internal_bdsink_fill_chunk(), internal_board_sd_stage_block(), internal_body_buffer_prefix(), internal_book_src_read_paged(), internal_c6_cam_audio_write_header(), internal_c6_get(), internal_c6_output_write(), internal_c6link_op_get_ap(), internal_c6link_op_get_mac(), internal_cache_body_leaf(), internal_cache_copy(), internal_cache_host_leaf(), internal_cache_read_block(), internal_cache_write_block(), internal_cli_artifact_url(), internal_compress_put(), internal_config_set_str(), internal_copy(), internal_copy_fits(), internal_copy_name(), internal_copy_object(), internal_copy_object(), internal_copy_object(), internal_cover_copy(), internal_cursor_entry(), internal_decode_header(), internal_decode_one(), internal_demo_bio_send(), internal_demo_http_get(), internal_demo_roundtrip(), internal_derive_stem(), internal_devcfg_deserialize(), internal_devcfg_serialize(), internal_devcfg_xm_read(), internal_devcfg_xm_write(), internal_dir_next(), internal_dir_pack_sector(), internal_dir_unpack_sector(), internal_download_all(), internal_download_manifest(), internal_drain_rx_slot(), internal_dump_row(), internal_emit(), internal_event_cb(), internal_exfat_list_emit(), internal_fat16_write_bpb(), internal_fat32_write_bpb(), internal_fat_dir_scan_sector(), internal_filter_prefix(), internal_float_to_u32(), internal_flush_band(), internal_h_memcpy(), internal_h_realloc(), internal_handle_init(), internal_hdr_read(), internal_host_echo_send_out(), internal_intern_name(), internal_jof_pull(), internal_json_str(), internal_library_act_on_node(), internal_library_remove_root(), internal_list_pages(), internal_make_header(), internal_make_name(), internal_make_span(), internal_mdl_accept_chunk(), internal_mdl_copy_field(), internal_mdl_http_field_copy(), internal_mdl_stage_headers(), internal_mdl_state_emit_chapters(), internal_mdl_state_encode(), internal_mdl_state_encode_header(), internal_mdl_state_parse_binary64(), internal_mdl_state_paths(), internal_mdl_transfer_commit(), internal_memory_capture(), internal_memory_capture(), internal_memory_read(), internal_memory_write(), internal_meta_candidate_path(), internal_meta_consume(), internal_miss(), internal_mram_read(), internal_mve_mem_exec(), internal_name(), internal_net_eth_hdr(), internal_net_queue(), internal_net_rx_arp(), internal_net_send_arp_reply(), internal_net_send_arp_request(), internal_net_send_tcp(), internal_packet_to_buffer(), internal_packet_to_buffer(), internal_panel_set_name(), internal_parent(), internal_parse_xml_tag(), internal_pax_apply(), internal_pdm_stream_data(), internal_png_consume_rows(), internal_png_translate(), internal_pointer_address(), internal_prof_decimate(), internal_ra8_esp_hosted_c6link_transfer(), internal_ram_read(), internal_ram_write(), internal_ram_write(), internal_ram_write(), internal_rbkc_header(), internal_read_at(), internal_read_block(), internal_render_svg(), internal_resolve_descriptor_path(), internal_resolve_one_leaf(), internal_resolve_path_rel(), internal_resolve_scheme_rel(), internal_sd_boot_frame(), internal_select_window(), internal_slab_next(), internal_slab_set_next(), internal_sort_pages(), internal_spans_overlap(), internal_split_output(), internal_split_output(), internal_split_output(), internal_split_path(), internal_split_path(), internal_stage_name(), internal_str_copy_trimmed(), internal_stub_read(), internal_submit_consume_orphan(), internal_super_read(), internal_swap_rows(), internal_tar_feed(), internal_tar_header(), internal_tar_member(), internal_temp_leaf(), internal_temp_name(), internal_temp_name(), internal_temp_name(), internal_temp_name(), internal_u32_to_float(), internal_urlname_copy(), internal_ustar_name(), internal_vmsc_fill_boot(), internal_vmsc_fill_root(), internal_vmsc_overlay_get(), internal_vmsc_overlay_put(), internal_write_block(), internal_write_entry(), internal_write_eth_header(), internal_write_one_sector(), internal_zip_workspace_realloc(), jof_memstore_pread(), jof_memstore_sink(), main(), mdl_export_workspace_take(), mdl_meta_parse(), mdl_path_join(), mdl_rabook_vfs_validate(), mdl_search_build_url(), mdl_state_set_series_metadata(), mdl_xml_escape(), mg_png_pull(), microsd_msc_read(), mkbookimg_dest_name(), nx_ether_driver_c6_rx(), nx_ether_driver_c6_set_mac(), prep_mailbox(), priv_alphabet_soup_split_path(), priv_bridge_pump_device(), priv_c6link_frame_classify(), priv_c6link_frame_filler(), priv_c6link_frame_seal(), priv_cache_store_super_write(), priv_comic_page_add(), priv_fs_posix_dir_next(), priv_fs_posix_parent_open(), priv_jof_on_rows(), priv_jof_prefix_pull(), priv_mdl_cache_save(), priv_mdl_epub_str_cat(), priv_mdl_export_jof(), priv_mdl_net_curl_buf_write(), priv_mdl_rabook_flat_read(), priv_mdl_state_decimal_to_binary64(), priv_mdl_verify_workspace_take(), priv_media_download_memory_read(), priv_media_download_memory_write_at(), priv_ra8_esp_hosted_rtos_alloc(), priv_ra8_esp_hosted_rtos_block_size(), priv_ra8_esp_hosted_rtos_release(), priv_rar5_filter_delta(), priv_reflow_tok_capture_attr(), priv_rv_trace_reference(), ra8_c6link_mdl_start_request(), ra8_dfu_read_header(), ra8_eth_gwca_default_send(), ra8_eth_gwca_tx_frame(), ra8_img_arena_realloc_sized(), ra8_ota_check_for_update(), ra8_ota_init(), ra8_power_profile_get_stats(), ra8_psa_key_import(), ra8_psa_sign_hash(), ra8_psa_verify_hash(), ra8_rabook_add_image(), ra8_rabook_gray8_encode(), ra8_rabook_intern(), ra8_vmem_stream_read(), ra8_vsource_loader(), rot_tamper_rejected(), sb_tampered_rejected(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), sh_comic_blob_read(), sh_fit(), sh_paged_mram_read(), sh_reader_render(), sh_shelf_build_thumbs(), strchr(), strrchr(), strstr(), unarch_mem_read(), wlun_msc_read(), wlun_msc_write(), and worker_pull().

◆ memmove()

void * memmove ( void * dst,
const void * src,
size_t n )

Copy memory area between potentially overlapping regions.

Copies n bytes from src to dst with correct overlap handling by determining forward vs backward copy order.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource buffer pointer.
[in]nNumber of bytes to copy.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n writable bytes if n > 0.
src points to at least n readable bytes if n > 0.
Postcondition
The n bytes at dst match the initial n bytes at src.
Safe against any degree of overlap between dst and src.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Copies n bytes from src to dst handling overlaps safely.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource buffer pointer.
[in]nNumber of bytes to copy.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n writable bytes if n > 0.
src points to at least n readable bytes if n > 0.
Postcondition
The n bytes at dst match the initial n bytes at src.
Handles any overlap between dst and src correctly.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Definition at line 95 of file ra8_freestanding_mem.c.

Referenced by internal_chunk_flat_read(), internal_js_slide(), and internal_prepend_underscore().

◆ memset()

void * memset ( void * dst,
int value,
size_t n )

Fill memory with a constant byte value.

Sets the first n bytes of the memory area pointed to by dst to the specified value (converted to an unsigned char).

Parameters
[out]dstPointer to the destination memory block to fill.
[in]valueByte value to write (passed as int, converted to uint8_t).
[in]nNumber of bytes to set.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n contiguous writable bytes if n > 0.
The destination memory region is addressable and valid.
Postcondition
The first n bytes of dst contain (uint8_t)value.
Bytes beyond n are unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when destination memory is not concurrently modified.
Since
0.1.0

Sets the first n bytes of dst to value converted to uint8_t.

Parameters
[out]dstDestination buffer to fill.
[in]valueByte value to write.
[in]nNumber of bytes to write.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n writable bytes if n > 0.
The destination memory region is addressable and valid.
Postcondition
The first n bytes of dst contain (uint8_t)value.
Bytes beyond n are unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when destination memory is not concurrently modified.
Since
0.1.0

Definition at line 45 of file ra8_freestanding_mem.c.

Referenced by app_make_cfg(), app_make_manifest(), ble_npl_callout_init(), ble_npl_event_init(), ble_npl_eventq_init(), board_net_init(), compile_fixture(), demo_calloc(), demo_fat_fill_sector(), demo_jiggle_send(), demo_msc_class_register(), demo_reopen_naive(), epub_entry_open(), fs_fmt_create_and_verify(), fs_fmt_rename_and_verify(), fw_fs_ra8_vfs_init(), fw_fs_space(), fw_fs_stat(), hid_send_iter(), hid_send_iter(), internal_allocate_pipeline(), internal_bdsink_flush(), internal_board_sd_cmd_send_csd(), internal_board_sd_fill_block(), internal_cache_encode_record(), internal_cache_storage(), internal_canfd_reset(), internal_copy_name(), internal_demo_calloc(), internal_demo_get_and_verify(), internal_demo_phase_remount(), internal_demo_put_and_verify(), internal_devcfg_serialize(), internal_dir_pack_sector(), internal_extract_series_metadata(), internal_fill_565(), internal_fill_slot(), internal_fill_strip(), internal_gb_render(), internal_h_calloc(), internal_h_memset(), internal_handle_send(), internal_handle_send(), internal_init_state(), internal_js_begin(), internal_library_workspace_reset(), internal_make_tables(), internal_mdl_next_capacity(), internal_mdl_state_big_init(), internal_mdl_state_big_shift(), internal_mdl_state_encode_header(), internal_mram_reset(), internal_native_window(), internal_net_ip_hdr(), internal_net_send_arp_reply(), internal_net_send_arp_request(), internal_net_send_ping(), internal_net_send_tcp(), internal_png_bind_geometry(), internal_pool_reset(), internal_ra8_io_roundtrip_read_verify(), internal_ram_erase(), internal_rbkc_pack(), internal_read_block(), internal_read_one(), internal_replay_open(), internal_resp_reset(), internal_run_budget(), internal_run_prepared(), internal_sdhi_begin_write(), internal_sdhi_load_block(), internal_sdhi_reset(), internal_seed_cells(), internal_session_mbedtls_setup(), internal_solve_words(), internal_super_read(), internal_swap_vfs_read_verify(), internal_tar_header(), internal_tx_ext_init(), internal_txn_begin(), internal_txn_begin(), internal_validate_body(), internal_vmsc_fill_sector(), internal_wire_window(), internal_write_entry(), internal_xspi_do_erase(), internal_xspi_reset(), load_panel(), long_shift_seam_install(), main(), mdl_extract_hits(), mdl_fetch_run(), mdl_governor_init_clock(), mdl_meta_init(), mdl_rabook_vfs_validate(), mdl_state_add_chapter_numbered(), mdl_state_init(), mem_tile_decode(), microsd_class_register(), mlun_class_register(), ospirw_class_register(), priv_cache_store_super_write(), priv_comic_cbz_open(), priv_dfu_write_secure(), priv_host_deliver_setup(), priv_jof_png_rows(), priv_mdl_export_prepare_cover(), priv_mdl_zip_workspace_bind(), priv_ota_manifest_decode(), priv_ra8_esp_hosted_rtos_deinit(), priv_ra8_esp_hosted_rtos_init(), priv_ra8_esp_hosted_rtos_pool_deinit(), priv_ra8_esp_hosted_rtos_pool_init(), priv_ra8_esp_hosted_rtos_sync_deinit(), priv_ra8_esp_hosted_rtos_sync_init(), priv_viewer_render_jof(), priv_viewer_tile_jof(), ra8_eth_gwca_init_ring(), ra8_eth_gwca_install_linkfix(), ra8_fs_dir_open(), ra8_glyph_atlas_init(), ra8_io_blockdev_vsource_init(), ra8_io_roundtrip_read_verify(), ra8_jpeg_sw_decode(), ra8_jpeg_sw_encode(), ra8_ota_deinit(), ra8_psa_crypto_deinit(), ra8_psa_key_destroy(), ra8_rabook_gray4_downscale(), ra8_rabook_gray4_encode(), ra8_tile_cache_init(), ra8_tls_session_close(), ra8_vmem_init(), ra8_vsource_loader(), ra8_wdt_supervisor_deinit(), ra8_wdt_supervisor_init(), ra8_webp_arena_calloc(), sdhi_card_block_roundtrip(), sdhi_demo_read_and_verify(), sdmsc_class_register(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_msc_class_register(), selftest_msc_class_register(), selftest_msc_class_register(), soup_init(), and wlun_class_register().

◆ strchr()

char * strchr ( const char * s,
int c )

Locate first occurrence of character in string.

Scans s for the first instance of character c (including null).

Parameters
[in]sNull-terminated string to search.
[in]cCharacter value to locate (converted to char).
Returns
Pointer to first occurrence in s, or nullptr if not found.
Return values
non-nullPointer to first matching character in s.
nullptrCharacter not found in s.
Precondition
s points to a valid null-terminated string.
s is readable.
Postcondition
String content is unmodified.
Returned pointer (if non-null) is within s.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Scans s for the first instance of character c (including null).

Parameters
[in]sNull-terminated string to search.
[in]cCharacter value to locate.
Returns
Pointer to first occurrence in s, or nullptr if not found.
Return values
non-nullPointer to first matching character in s.
nullptrCharacter not found in s.
Precondition
s points to a valid null-terminated string.
s is readable.
Postcondition
String content is unmodified.
Returned pointer (if non-null) is within s.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Definition at line 157 of file ra8_freestanding_str.c.

References memcpy().

Referenced by internal_args_attach_blank_sd(), internal_authority_of(), internal_config_apply_line(), internal_cookie_name_valid(), internal_has_separator(), internal_json_str(), internal_mdl_state_split_tabs(), internal_next_line(), internal_panel_split_kv(), internal_parse_kv_line(), internal_parse_panel(), internal_parse_xml_tag(), internal_pubid_byte(), internal_split_field(), mdl_extract_selector(), mdl_meta_parse(), mdl_url_host(), and mdl_url_path().

◆ strcmp()

int strcmp ( const char * s1,
const char * s2 )

Compare two null-terminated strings.

Compares s1 and s2 lexicographically as unsigned char values.

Parameters
[in]s1First null-terminated string.
[in]s2Second null-terminated string.
Returns
Difference between first differing characters, or 0 if identical.
Return values
0Strings are identical up to null terminator.
<0First non-matching character in s1 is less than in s2.
>0First non-matching character in s1 is greater than in s2.
Precondition
Both s1 and s2 are valid null-terminated strings.
String buffers are readable.
Postcondition
Both input strings are unmodified.
Comparison semantics follow unsigned byte values.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input strings are not concurrently modified.
Since
0.1.0

Definition at line 93 of file ra8_freestanding_str.c.

Referenced by internal_add_manifest_image(), internal_agent_spec(), internal_already_have(), internal_apply_semantic_key(), internal_cache_find(), internal_cache_find(), internal_compile_images(), internal_compile_stylesheets(), internal_config_apply_pair(), internal_config_apply_string(), internal_config_apply_u32(), internal_config_parse_order(), internal_config_valid(), internal_demo_probe_fat(), internal_demo_probe_foreign(), internal_duplicate_name(), internal_epub_media_type_from_sniff(), internal_epub_media_type_from_suffix(), internal_epub_page_is_cover(), internal_extract_meta(), internal_extract_series_metadata(), internal_find_row(), internal_format(), internal_gov_find(), internal_hit_index_of(), internal_is_dot_segment(), internal_is_option_value(), internal_is_reserved_base(), internal_is_void(), internal_key_is(), internal_library_leaf(), internal_mdl_fetch_discard_stale_page(), internal_mdl_fetch_try_reuse(), internal_modem_answer_line(), internal_parse(), internal_parse(), internal_parse(), internal_parse_arguments(), internal_parse_verify_opt(), internal_parse_xml_semantics(), internal_redirect_host_ok(), internal_remove_stale_page_variants(), internal_resolve_one_leaf(), internal_resolve_removal_target(), internal_root_walk_step(), internal_snapshot_prior_metadata(), internal_sort_pages(), internal_split_output(), internal_split_output(), internal_split_output(), internal_split_path(), internal_stub_listdir(), internal_stub_open(), internal_stub_stat(), internal_take_flag(), internal_take_opt(), internal_tar_member(), internal_urlname_is_known_ext(), internal_validate_network_args(), internal_zip_member(), main(), mdl_extract_images(), mdl_format_from_str(), mdl_governor_peek(), mdl_robots_cache_consult(), mdl_search_filter_series_hits(), mdl_state_chapter_complete(), mdl_state_chapter_pages(), mdl_state_find_chapter(), mdl_storage_copy_atomic(), priv_book_is_block(), priv_fmt_try_portable_convert(), priv_fmt_try_portable_inspect(), priv_fmt_try_portable_verify(), priv_fs_posix_dir_next(), priv_fs_posix_root_alias_classify(), priv_mdl_export_path_join(), priv_mdl_export_prepare_cover(), priv_reflow_tok_classify(), and prof_load().

◆ strcpy()

char * strcpy ( char * dst,
const char * src )

Copy string to destination buffer.

Copies string src (including terminating null) to dst.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource null-terminated string pointer.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst has sufficient capacity to hold src and terminating null.
dst and src do not overlap.
Postcondition
The copied string at dst matches src.
Source string is unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when strings are not concurrently modified.
Since
0.1.0

Definition at line 261 of file ra8_freestanding_str.c.

◆ strlen()

size_t strlen ( const char * s)

Calculate string length.

Computes the length of null-terminated string s.

Parameters
[in]sNull-terminated character string.
Returns
Number of characters preceding the terminating null character.
Return values
lengthNumber of characters before null terminator.
Precondition
s points to a valid null-terminated string.
String is readable up to the null terminator.
Postcondition
String content is unmodified.
Result is bounded by string length.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Computes number of characters before terminating null byte.

Parameters
[in]sNull-terminated character string.
Returns
String length in characters.
Return values
lengthNumber of characters before null terminator.
Precondition
s points to a valid null-terminated string.
s is readable.
Postcondition
String content is unmodified.
Never negative.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Definition at line 42 of file ra8_freestanding_str.c.

Referenced by cb_host_output_open(), demo_file_ops(), demo_print(), demo_puts(), demo_read_verify(), demo_write_test_file(), elf_sym_addr(), epub_toc_entry_to_chapter(), er_draw_key_label(), internal_add_manifest_image(), internal_add_rule(), internal_agent_spec(), internal_attr_at(), internal_authority_of(), internal_build_export_metadata(), internal_build_tar(), internal_cache_copy(), internal_cache_encode_record(), internal_cbz_add_metadata(), internal_ci_contains(), internal_class_has_token(), internal_cli_ends_ci(), internal_config_set_str(), internal_config_trim(), internal_config_valid(), internal_cookie_field_is(), internal_copy_fits(), internal_cover_copy(), internal_decode_entity(), internal_demo_http_get(), internal_demo_log(), internal_demo_print(), internal_elem_at(), internal_emit_cstr(), internal_ends_ci(), internal_ends_with(), internal_ends_with_ci(), internal_entity(), internal_epub_render_meta(), internal_exfat_list_emit(), internal_extract_label(), internal_extract_meta(), internal_fat_dir_scan_sector(), internal_filter_prefix(), internal_find_attr_value(), internal_find_ci(), internal_handle_cdata(), internal_handle_raw_text(), internal_hex_decode(), internal_intern_span(), internal_is_reserved_base(), internal_json_str(), internal_keyword(), internal_library_act_on_node(), internal_log(), internal_make_name(), internal_mdl_stage_headers(), internal_mdl_state_append_gaps(), internal_mdl_state_parse_binary64(), internal_mdl_state_paths(), internal_panel_rstrip(), internal_panel_set_name(), internal_parent(), internal_parse_panel(), internal_parse_xml_tag(), internal_prepare_filter_chapters(), internal_rcs_print(), internal_resolve_config_path(), internal_resolve_descriptor_path(), internal_resolve_one_leaf(), internal_resolve_pack_path(), internal_resolve_path_rel(), internal_resolve_scheme_rel(), internal_scan_tags(), internal_split_output(), internal_split_output(), internal_split_output(), internal_split_path(), internal_split_path(), internal_stage_name(), internal_stderr_write(), internal_str_copy_trimmed(), internal_tag_is(), internal_tar_header(), internal_terminator(), internal_text(), internal_text(), internal_text(), internal_text(), internal_text(), internal_text(), internal_trim_ws(), internal_url_slug(), internal_urlname_last_path_marker(), internal_urlname_path_end(), internal_urlname_path_start(), internal_validate_mode_fields(), internal_xml_unescape(), mdl_hash_str(), mdl_meta_parse(), mdl_path_contained(), mdl_path_join(), mdl_search_build_url(), mdl_urlname_chapter_parse(), mdl_xml_escape(), mkbookimg_dest_name(), priv_alphabet_soup_split_path(), priv_emu_io_err_text(), priv_emu_io_file_text(), priv_emu_io_out_text(), priv_match_grad(), priv_mdl_epub_add_str(), priv_mdl_epub_str_cat(), priv_mdl_state_relative_path_valid(), priv_mkbookimg_diag(), priv_mkfontimg_diag(), priv_ota_json_u32(), priv_ra8_svgp_attr(), priv_ra8_svgp_find_ci(), priv_ra8_svgp_starts_ci(), priv_reflow_tok_decode_entity(), priv_reflow_tok_find_lit(), priv_reflow_tok_skip_past(), priv_reflow_tok_starts_with(), priv_rv_diag(), ra8_rabook_intern(), rabook_import_open(), sh_center_x(), sh_comic_center_x(), sh_decode_entity(), sh_ext_match(), sh_fit(), sh_sd_listdir_cb(), sh_titlebar(), sh_xhtml_is_block(), sh_xhtml_is_suppress(), and xml_span_equal().

◆ strncmp()

int strncmp ( const char * s1,
const char * s2,
size_t n )

Compare two strings up to a specified length.

Compares at most n characters of s1 and s2.

Parameters
[in]s1First string.
[in]s2Second string.
[in]nMaximum characters to compare.
Returns
Difference between first differing characters, or 0 if identical.
Return values
0Strings match for first n characters or up to null terminator.
<0First non-matching character in s1 is less than in s2.
>0First non-matching character in s1 is greater than in s2.
Precondition
s1 and s2 are readable up to n bytes or null-terminated.
Both pointers are addressable.
Postcondition
Both input strings are unmodified.
Bounded by n characters.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input strings are not concurrently modified.
Since
0.1.0

Definition at line 124 of file ra8_freestanding_str.c.

Referenced by epub_toc_entry_to_chapter(), internal_add_manifest_image(), internal_args_try_control(), internal_args_try_display(), internal_args_try_input(), internal_args_try_mode(), internal_args_try_sd(), internal_args_try_sym(), internal_config_valid(), internal_filter_prefix(), internal_init_site_identity(), internal_is_reserved_base(), internal_load_argv_traces(), internal_mdl_http_begin(), internal_mdl_start_request_valid(), internal_mdl_start_valid(), internal_output_path(), internal_panel_apply_kv(), internal_validate_mode_fields(), internal_xml_unescape(), mdl_extract_resolve_url(), mdl_extract_selector(), mdl_path_contained(), mdl_search_build_url(), priv_mdl_app_storage_publish_site(), priv_reflow_tok_decode_entity(), sh_decode_entity(), sh_xhtml_is_block(), and sh_xhtml_is_suppress().

◆ strncpy()

char * strncpy ( char * dst,
const char * src,
size_t n )

Copy bounded string to destination buffer.

Copies at most n characters from src to dst, padding with null bytes if src is shorter than n.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource string pointer.
[in]nMaximum number of bytes to write.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n writable bytes.
dst and src do not overlap.
Postcondition
Exactly n bytes are written to dst.
Source string is unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when strings are not concurrently modified.
Since
0.1.0

Definition at line 288 of file ra8_freestanding_str.c.

Referenced by sh_copy_str(), sh_sd_listdir_cb(), and sh_seed_baked().

◆ strnlen()

size_t strnlen ( const char * s,
size_t maxlen )

Calculate bounded string length.

Computes length of string s, up to a maximum of maxlen.

Parameters
[in]sCharacter string to measure.
[in]maxlenMaximum characters to examine.
Returns
Length of string up to maxlen.
Return values
lengthMin of characters before null terminator and maxlen.
Precondition
s points to readable memory of at least maxlen bytes or null-terminated.
s is addressable.
Postcondition
String content is unmodified.
Return value is never greater than maxlen.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Computes length of string s up to a maximum of maxlen.

Parameters
[in]sCharacter string to measure.
[in]maxlenMaximum characters to examine.
Returns
Length of string up to maxlen.
Return values
lengthMin of characters before null terminator and maxlen.
Precondition
s points to readable memory of at least maxlen bytes or null-terminated.
s is addressable.
Postcondition
String content is unmodified.
Return value is at most maxlen.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Definition at line 65 of file ra8_freestanding_str.c.

Referenced by internal_add_rule(), internal_cursor_entry(), internal_demo_roundtrip(), internal_library_leaf(), internal_library_remove_root(), internal_mdl_copy_field(), internal_mdl_http_field_copy(), internal_mdl_http_field_valid(), internal_mdl_request_field_valid(), internal_mdl_start_request_valid(), internal_mdl_start_valid(), internal_meta_candidate_path(), internal_urlname_copy(), mdl_robots_cache_consult(), mdl_urlname_chapter_parse(), mdl_urlname_chapter_text_parse(), priv_mdl_export_prepare_cover(), priv_mdl_export_validate_source_url(), and priv_mdl_state_field_valid().

◆ strrchr()

char * strrchr ( const char * s,
int c )

Locate last occurrence of character in string.

Scans s for the last instance of character c (including null).

Parameters
[in]sNull-terminated string to search.
[in]cCharacter value to locate (converted to char).
Returns
Pointer to last occurrence in s, or nullptr if not found.
Return values
non-nullPointer to last matching character in s.
nullptrCharacter not found in s.
Precondition
s points to a valid null-terminated string.
s is readable.
Postcondition
String content is unmodified.
Returned pointer (if non-null) is within s.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Scans s for the last instance of character c (including null).

Parameters
[in]sNull-terminated string to search.
[in]cCharacter value to locate.
Returns
Pointer to last occurrence in s, or nullptr if not found.
Return values
non-nullPointer to last matching character in s.
nullptrCharacter not found in s.
Precondition
s points to a valid null-terminated string.
s is readable.
Postcondition
String content is unmodified.
Returned pointer (if non-null) is within s.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input string is not concurrently modified.
Since
0.1.0

Definition at line 190 of file ra8_freestanding_str.c.

References memcpy().

Referenced by internal_body_paths(), internal_epub_media_type_from_suffix(), internal_mdl_fetch_try_reuse(), internal_parent(), internal_publish_page_image(), internal_resolve_one_leaf(), internal_split_path(), internal_split_path(), priv_alphabet_soup_split_path(), and priv_mdl_export_jof().

◆ strstr()

char * strstr ( const char * haystack,
const char * needle )

Locate substring in string.

Finds the first occurrence of needle in haystack.

Parameters
[in]haystackNull-terminated string to search.
[in]needleNull-terminated substring to locate.
Returns
Pointer to beginning of substring in haystack, or nullptr if not found.
Return values
non-nullPointer to substring occurrence in haystack.
nullptrSubstring not found in haystack.
Precondition
Both haystack and needle are valid null-terminated strings.
Both buffers are readable.
Postcondition
Both input strings are unmodified.
Returns haystack if needle is empty.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when input strings are not concurrently modified.
Since
0.1.0

Definition at line 222 of file ra8_freestanding_str.c.

References memcpy().

Referenced by internal_args_attach_blank_sd(), internal_authority_of(), internal_class_has_token(), internal_contains_ok(), internal_decode_fail(), internal_json_str(), internal_mve_exec_one(), internal_parse_xml_tag(), internal_resolve_scheme_rel(), internal_robots_target(), internal_run_stop_banner(), internal_sniff_content_type(), internal_urlname_path_start(), mdl_meta_parse(), mdl_search_filter_series_hits(), mdl_url_host(), mdl_url_path(), priv_epub_xml_attr_contains(), and priv_ota_json_u32().