1 /*
2  * Copyright 2019 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #pragma once
10 
11 #include "hf/arch/std.h"
12 
13 typedef size_t rsize_t;
14 
15 /**
16  * Restrict the maximum range for range checked functions so as to be more
17  * likely to catch errors. This may need to be relaxed if it proves to be overly
18  * restrictive.
19  */
20 #define RSIZE_MAX (128 * 1024 * 1024)
21 
22 /*
23  * Only the safer versions of these functions are exposed to reduce the chance
24  * of misusing the versions without bounds checking or null pointer checks.
25  *
26  * These functions don't return errno_t as per the specification and implicitly
27  * have a constraint handler that panics.
28  */
29 void memset_s(void *dest, rsize_t destsz, int ch, rsize_t count);
30 void memcpy_s(void *dest, rsize_t destsz, const void *src, rsize_t count);
31 void memmove_s(void *dest, rsize_t destsz, const void *src, rsize_t count);
32 
33 void *memchr(const void *ptr, int ch, size_t count);
34 
35 size_t strnlen_s(const char *str, size_t strsz);
36