Andrew Scull | 8d9e121 | 2019-04-05 13:52:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Hafnium Authors. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include "hf/arch/std.h" |
Andrew Scull | 2b5fbad | 2019-04-05 13:55:56 +0100 | [diff] [blame] | 20 | |
| 21 | typedef size_t rsize_t; |
| 22 | |
Andrew Scull | 2563552 | 2019-05-20 11:46:07 +0100 | [diff] [blame^] | 23 | /** |
| 24 | * Restrict the maximum range for range checked functions so as to be more |
| 25 | * likely to catch errors. This may need to be relaxed if it proves to be overly |
| 26 | * restrictive. |
| 27 | */ |
| 28 | #define RSIZE_MAX (128 * 1024 * 1024) |
Andrew Scull | 2b5fbad | 2019-04-05 13:55:56 +0100 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * Only the safer versions of these functions are exposed to reduce the chance |
| 32 | * of misusing the versions without bounds checking or null pointer checks. |
| 33 | * |
| 34 | * These functions don't return errno_t as per the specification and implicity |
| 35 | * have a constraint handler that panics. |
| 36 | */ |
| 37 | void memset_s(void *dest, rsize_t destsz, int ch, rsize_t count); |
Andrew Scull | a1aa2ba | 2019-04-05 11:49:02 +0100 | [diff] [blame] | 38 | void memcpy_s(void *dest, rsize_t destsz, const void *src, rsize_t count); |
Andrew Scull | 8fbd7ee | 2019-04-05 14:36:34 +0100 | [diff] [blame] | 39 | void memmove_s(void *dest, rsize_t destsz, const void *src, rsize_t count); |
Andrew Scull | 55baca6 | 2019-04-05 14:56:20 +0100 | [diff] [blame] | 40 | |
| 41 | size_t strnlen_s(const char *str, size_t strsz); |