CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
string.h
1// Copyright Microsoft and CHERIoT Contributors.
2// SPDX-License-Identifier: MIT
3
4#pragma once
5#include <cdefs.h>
6#include <stddef.h>
7#include <stdint.h>
8
9CHERIOT_DECLARE_STANDARD_LIBCALL(memcmp,
10 int,
11 const void *str1,
12 const void *str2,
13 size_t count)
14CHERIOT_DECLARE_STANDARD_LIBCALL(memcmp,
15 int,
16 const void *str1,
17 const void *str2,
18 size_t count)
19CHERIOT_DECLARE_STANDARD_LIBCALL(memcpy,
20 void *,
21 void *dest,
22 const void *src,
23 size_t n)
24CHERIOT_DECLARE_STANDARD_LIBCALL(memccpy,
25 void *,
26 void *dest,
27 const void *src,
28 int c,
29 size_t n)
30CHERIOT_DECLARE_STANDARD_LIBCALL(memset, void *, void *, int, size_t)
31CHERIOT_DECLARE_STANDARD_LIBCALL(memmove,
32 void *,
33 void *dest,
34 const void *src,
35 size_t n)
36CHERIOT_DECLARE_STANDARD_LIBCALL(memchr, void *, const void *, int, size_t)
37CHERIOT_DECLARE_STANDARD_LIBCALL(memrchr, void *, const void *, int, size_t)
38CHERIOT_DECLARE_STANDARD_LIBCALL(strlen, size_t, const char *str)
39CHERIOT_DECLARE_STANDARD_LIBCALL(strnlen,
40 size_t,
41 const char *str,
42 size_t maxlen)
43CHERIOT_DECLARE_STANDARD_LIBCALL(strncmp,
44 int,
45 const char *s1,
46 const char *s2,
47 size_t n)
48CHERIOT_DECLARE_STANDARD_LIBCALL(strncpy,
49 char *,
50 char *dest,
51 const char *src,
52 size_t n)
53CHERIOT_DECLARE_STANDARD_LIBCALL(strcmp, int, const char *s1, const char *s2)
54CHERIOT_DECLARE_STANDARD_LIBCALL(strnstr,
55 char *,
56 const char *haystack,
57 const char *needle,
58 size_t haystackLength)
59CHERIOT_DECLARE_STANDARD_LIBCALL(strchr, char *, const char *s, int c)
60CHERIOT_DECLARE_STANDARD_LIBCALL(strlcpy,
61 size_t,
62 char *dest,
63 const char *src,
64 size_t n)
65
66/**
67 * Explicit bzero is a memset variant that the compiler is not permitted to
68 * remove. Our implementation simply wraps memset and is safe from removal
69 * because it is provided by a different shared library.
70 */
71void __cheri_libcall explicit_bzero(void *s, size_t n);
72
73__always_inline static inline char *strcpy(char *dst, const char *src)
74{
75 return dst + strlcpy(dst, src, SIZE_MAX);
76}
77
78__always_inline static inline char *strstr(const char *haystack,
79 const char *needle)
80{
81 return strnstr(haystack, needle, SIZE_MAX);
82}