diff --git a/lib/libc/newlib/include/string.h b/lib/libc/newlib/include/string.h new file mode 100644 index 00000000000..74ba3ccdd9e --- /dev/null +++ b/lib/libc/newlib/include/string.h @@ -0,0 +1,37 @@ +/* + * Copyright © 2024 Keith Packard + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STRING_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STRING_H_ + +/* This should work on GCC and clang. + * + * If we need to support a toolchain without #include_next the CMake + * infrastructure should be used to identify it and provide an + * alternative solution. + */ +#include_next + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define these two Zephyr APIs when _POSIX_C_SOURCE is not set to expose + * them from newlib + */ +#if !__MISC_VISIBLE && !__POSIX_VISIBLE +char *strtok_r(char *__restrict, const char *__restrict, char **__restrict); +#endif +#if __POSIX_VISIBLE < 200809L +size_t strnlen(const char *, size_t); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STRING_H_ */