27#ifndef MMGR_STRING_SHIM_H
28#define MMGR_STRING_SHIM_H
50#ifndef _STRING_H_INCLUDED
51#define _STRING_H_INCLUDED 1
69EMBED_INLINE
void *
mmgr_shim_cpy(
void *dest,
const void *source,
size_t bytes)
71 EMBED_CALL(memor.cpy,
MemoriaCfg, .
dst = dest, .src = source, .bytes = bytes);
86EMBED_INLINE
void *
mmgr_shim_move(
void *dest,
const void *source,
size_t bytes)
90 if ((
const uint8_t *)dest <= (
const uint8_t *)source)
92 EMBED_CALL(memor.move_down,
MemoriaCfg, .
dst = dest, .src = source, .bytes = bytes);
96 EMBED_CALL(memor.move_up,
MemoriaCfg, .
dst = dest, .src = source, .bytes = bytes);
111EMBED_INLINE
void *
mmgr_shim_set(
void *dest, embed_iword value,
size_t bytes)
113 EMBED_CALL(memor.set,
MemoriaCfg, .
dst = dest, .val = (uint8_t)value, .bytes = bytes);
127EMBED_INLINE embed_iword
mmgr_shim_cmp(
const void *left,
const void *right,
size_t bytes)
129 return EMBED_CALL(memor.cmp,
MemoriaCfg, .
src = left, .other = right, .bytes = bytes);
142EMBED_INLINE
void *
mmgr_shim_chr(
const void *region, embed_iword value,
size_t bytes)
144 return (
void *)(size_t)EMBED_CALL(memor.chr,
MemoriaCfg, .
src = region, .bytes = bytes, .val = (uint8_t)value);
152#define memcpy(dest, source, bytes) mmgr_shim_cpy((dest), (source), (bytes))
159#define memmove(dest, source, bytes) mmgr_shim_move((dest), (source), (bytes))
167#define memset(dest, value, bytes) mmgr_shim_set((dest), (value), (bytes))
174#define memcmp(left, right, bytes) mmgr_shim_cmp((left), (right), (bytes))
182#define memchr(region, value, bytes) mmgr_shim_chr((region), (value), (bytes))
192#define strlen(text) EMBED_CALL(cellul.len, CatenaFinitaCfg, .src = (text), .cap = MMGR_STR_MAX)
202#define strnlen(text, limit) EMBED_CALL(cellul.len, CatenaFinitaCfg, .src = (text), .cap = (limit))
212#define strstr(haystack, needle) \
213 ((char *)(size_t)EMBED_CALL(cellul.find, CatenaFinitaCfg, .src = (haystack), .cap = MMGR_STR_MAX, \
214 .other = (needle), .other_cap = MMGR_STR_MAX, .ci = EMBED_FALSE))
224#define strcasestr(haystack, needle) \
225 ((char *)(size_t)EMBED_CALL(cellul.find, CatenaFinitaCfg, .src = (haystack), .cap = MMGR_STR_MAX, \
226 .other = (needle), .other_cap = MMGR_STR_MAX, .ci = EMBED_TRUE))
237#define strcmp(left, right) \
238 (!EMBED_CALL(cellul.eq, CatenaFinitaCfg, .src = (left), .other = (right), .cap = MMGR_STR_MAX, .ci = EMBED_FALSE))
248#define strcasecmp(left, right) \
249 (!EMBED_CALL(cellul.eq, CatenaFinitaCfg, .src = (left), .other = (right), .cap = MMGR_STR_MAX, .ci = EMBED_TRUE))
260#define strncmp(left, right, limit) \
261 (EMBED_CALL(cellul.diff, CatenaFinitaCfg, .src = (left), .other = (right), .cap = (limit), .ci = EMBED_FALSE) < \
273#define strncasecmp(left, right, limit) \
274 (EMBED_CALL(cellul.diff, CatenaFinitaCfg, .src = (left), .other = (right), .cap = (limit), .ci = EMBED_TRUE) < \
285#define strlcpy(dest, source, limit) \
286 EMBED_CALL(cellul.copy, CatenaFinitaCfg, .dst = (dest), .src = (source), .cap = (limit))
298#define strchr(text, value) \
299 ((char *)(size_t)EMBED_CALL(cellul.chr, CatenaFinitaCfg, .src = (text), .cap = MMGR_STR_MAX, \
300 .byte = (uint8_t)(value)))
Bounded string work: the three argument types, the calls, and the cellul dispatch table.
static 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 void * mmgr_shim_move(void *dest, const void *source, size_t bytes)
Copies bytes from source to dest, tolerating overlap, and returns dest.
static 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_iword mmgr_shim_cmp(const void *left, const void *right, size_t bytes)
Compares bytes of left against right.
static 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.
The embedded_types headers every module builds on.
Arguments for the memor calls.