|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
Cursor byte-copy helpers shared by the frame codecs. More...
Go to the source code of this file.
Functions | |
| static int | bytes_put (wired_mspan buf, usz *off, wired_span src) |
| Append src into buf at *off. | |
| static int | bytes_take (wired_span buf, usz *off, wired_mspan dst) |
| Copy dst.n bytes into dst from *off (buf total). | |
| static void * | bytes_memcpy (void *dst, const void *src, usz n) |
| Freestanding byte copy. | |
| static void * | bytes_move_down (void *dst, const void *src, usz n) |
| Byte copy toward lower addresses: dst may overlap src as long as dst <= src (a forward copy then never reads a byte it already overwrote), e.g. | |
| static void * | bytes_memset (void *dst, int c, usz n) |
| Freestanding byte fill. | |
| static usz | wired_cstr_len (const char *s) |
| Freestanding NUL-terminated string length. | |
| static u8 | ascii_lower (u8 c) |
| ASCII lowercase of one octet (A-Z -> a-z, everything else unchanged). | |
| static int | ascii_dns_eq (wired_span a, wired_span b) |
| RFC 6125 6.4.1: ASCII case-insensitive equality of two DNS-name-shaped byte spans (host names, SNI values). | |
Cursor byte-copy helpers shared by the frame codecs.
Inline so multiple codec translation units can use them without redefining a static helper.
|
inlinestatic |
RFC 6125 6.4.1: ASCII case-insensitive equality of two DNS-name-shaped byte spans (host names, SNI values).
Non-ASCII bytes compare bytewise (no folding applied outside A-Z).
| a | first span |
| b | second span |
ASCII lowercase of one octet (A-Z -> a-z, everything else unchanged).
| c | input octet |
|
inlinestatic |
Freestanding byte copy.
Even under -ffreestanding -fno-builtin the compiler still emits memcpy/memset calls for struct and array copies/zeroing (e.g. modexp.c, ed25519_sign.c, respond.c), and with -nostdlib no libc supplies them. The SDK owns these primitives; each freestanding binary's mandatory libc-named memcpy/memset shim (the symbol names the compiler hard-codes) just forwards to these.
| dst | destination buffer (must not overlap src) |
| src | source buffer |
| n | number of bytes to copy |
|
inlinestatic |
Freestanding byte fill.
See bytes_memcpy() for why the SDK owns this.
| dst | buffer to fill |
| c | fill byte (truncated to u8) |
| n | number of bytes to fill |
|
inlinestatic |
Byte copy toward lower addresses: dst may overlap src as long as dst <= src (a forward copy then never reads a byte it already overwrote), e.g.
sliding a buffer's tail down to its front.
The loop is the same as bytes_memcpy's today, but only this contract promises forward order: bytes_memcpy stays free to copy in any order.
| dst | destination, at or below src |
| src | source buffer |
| n | number of bytes to copy |
|
inlinestatic |
Append src into buf at *off.
Both buf and src are borrowed views: no ownership transfers and nothing is copied into new storage, so buf and src must stay alive (and unmoved) only for the duration of this call.
| buf | destination buffer (its .n is the total capacity) |
| off | write cursor into buf; advanced by src.n on success |
| src | bytes to append |
|
inlinestatic |
Copy dst.n bytes into dst from *off (buf total).
Both buf and dst are borrowed views: no ownership transfers, and each must stay alive (and unmoved) only for the duration of this call.
| buf | source buffer to read from |
| off | read cursor into buf; advanced by dst.n on success |
| dst | destination; exactly dst.n bytes are copied |
|
inlinestatic |
Freestanding NUL-terminated string length.
src/ has no libc strlen.
| s | NUL-terminated string |