8#ifndef MMGR_STRING_SHIM_H
9#define MMGR_STRING_SHIM_H
15#include "config/mmgr_config.h"
26#define MMGR_STR_MAX MMGR_CARCER_MAX
44#ifndef _STRING_H_INCLUDED
45#define _STRING_H_INCLUDED 1
62EMBED_HOST_DEVICE EMBED_INLINE
void *
mmgr_shim_cpy(
void *dest,
const void *source,
size_t bytes)
64 EMBED_CALL(memor.cpy,
MemoriaCfg, .
dst = dest, .src = source, .bytes = bytes);
78EMBED_HOST_DEVICE EMBED_INLINE
void *
mmgr_shim_move(
void *dest,
const void *source,
size_t bytes)
80 if ((
const uint8_t *)dest <= (
const uint8_t *)source)
82 EMBED_CALL(memor.move_down,
MemoriaCfg, .
dst = dest, .src = source, .bytes = bytes);
86 EMBED_CALL(memor.move_up,
MemoriaCfg, .
dst = dest, .src = source, .bytes = bytes);
100EMBED_HOST_DEVICE EMBED_INLINE
void *
mmgr_shim_set(
void *dest, embed_iword value,
size_t bytes)
102 EMBED_CALL(memor.set,
MemoriaCfg, .
dst = dest, .bytes = bytes, .val = (uint8_t)value);
115EMBED_HOST_DEVICE EMBED_INLINE embed_iword
mmgr_shim_cmp(
const void *left,
const void *right,
size_t bytes)
117 return EMBED_CALL(memor.cmp,
MemoriaCfg, .
src = left, .other = right, .bytes = bytes);
129EMBED_HOST_DEVICE EMBED_INLINE
void *
mmgr_shim_chr(
const void *region, embed_iword value,
size_t bytes)
131 return (
void *)(size_t)EMBED_CALL(memor.chr,
MemoriaCfg, .
src = region, .bytes = bytes, .val = (uint8_t)value);
139#define memcpy(dest, source, bytes) mmgr_shim_cpy((dest), (source), (bytes))
144#define memmove(dest, source, bytes) mmgr_shim_move((dest), (source), (bytes))
149#define memset(dest, value, bytes) mmgr_shim_set((dest), (value), (bytes))
156#define memcmp(left, right, bytes) mmgr_shim_cmp((left), (right), (bytes))
161#define memchr(region, value, bytes) mmgr_shim_chr((region), (value), (bytes))
168#define strlen(text) EMBED_CALL(cellul.len, CatenaFinitaCfg, .src = (text), .cap = MMGR_STR_MAX)
175#define strnlen(text, limit) EMBED_CALL(cellul.len, CatenaFinitaCfg, .src = (text), .cap = (limit))
183#define strstr(haystack, needle) \
184 ((char *)(size_t)EMBED_CALL(cellul.find, CatenaFinitaCfg, .src = (haystack), .cap = MMGR_STR_MAX, \
185 .other = (needle), .other_cap = MMGR_STR_MAX, .ci = EMBED_FALSE))
193#define strcasestr(haystack, needle) \
194 ((char *)(size_t)EMBED_CALL(cellul.find, CatenaFinitaCfg, .src = (haystack), .cap = MMGR_STR_MAX, \
195 .other = (needle), .other_cap = MMGR_STR_MAX, .ci = EMBED_TRUE))
203#define strcmp(left, right) \
204 (!EMBED_CALL(cellul.eq, CatenaFinitaCfg, .src = (left), .other = (right), .cap = MMGR_STR_MAX, .ci = EMBED_FALSE))
212#define strcasecmp(left, right) \
213 (!EMBED_CALL(cellul.eq, CatenaFinitaCfg, .src = (left), .other = (right), .cap = MMGR_STR_MAX, .ci = EMBED_TRUE))
222#define strncmp(left, right, limit) \
223 (EMBED_CALL(cellul.diff, CatenaFinitaCfg, .src = (left), .other = (right), .cap = (limit), .ci = EMBED_FALSE) < \
233#define strncasecmp(left, right, limit) \
234 (EMBED_CALL(cellul.diff, CatenaFinitaCfg, .src = (left), .other = (right), .cap = (limit), .ci = EMBED_TRUE) < \
242#define strlcpy(dest, source, limit) \
243 EMBED_CALL(cellul.copy, CatenaFinitaCfg, .dst = (dest), .src = (source), .cap = (limit))
252#define strchr(text, value) \
253 ((char *)(size_t)EMBED_CALL(cellul.chr, CatenaFinitaCfg, .src = (text), .cap = MMGR_STR_MAX, \
254 .byte = (uint8_t)(value)))
Bounded string work: the three argument types, the calls, and the cellul dispatch table.
static EMBED_HOST_DEVICE embed_iword mmgr_shim_cmp(const void *left, const void *right, size_t bytes)
Compares bytes of left against right.
static EMBED_HOST_DEVICE void * mmgr_shim_chr(const void *region, embed_iword value, size_t bytes)
Finds the first byte in region equal to the low byte of value.
static EMBED_HOST_DEVICE void * mmgr_shim_set(void *dest, embed_iword value, size_t bytes)
Fills bytes of dest with the low byte of value and returns dest.
static EMBED_HOST_DEVICE void * mmgr_shim_move(void *dest, const void *source, size_t bytes)
Copies bytes from source to dest, with overlap allowed, and returns dest.
static EMBED_HOST_DEVICE void * mmgr_shim_cpy(void *dest, const void *source, size_t bytes)
Copies bytes from source to dest and returns dest.
Byte-level memory work: its arguments, the calls, and the memor dispatch table.
Arguments for the memor calls.