blob: f17e30a646ed5a81ab864d850fe0b274c63fbb76 [file] [log] [blame]
// Copyright Microsoft and CHERIoT Contributors.
// SPDX-License-Identifier: MIT
#pragma once
/**
* Minimal wchar.h This exists because libc++ doesn't support platforms that
* don't have it. We don't expect anything to actually use the template
* instantiations that would require anything in this file but the identifiers
* must exist.
*/
#include <string.h>
/**
* libc++ headers require wchar.h to exist with a definition of an mbstate_t
* structure. We don't use this with anything, so this is just a stub.
*/
struct mbstate_t
{
};
/**
* `string_view` requires `wmemcpy` to exist. Forward to `memcpy`.
*/
static inline wchar_t *wmemcpy(wchar_t *s1, const wchar_t *s2, size_t n)
{
return (wchar_t *)memcpy(s1, s2, n / sizeof(wchar_t));
}
/**
* `string_view` requires `wmemmove` to exist. Forward to `memmove`.
*/
static inline wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n)
{
return (wchar_t *)memmove(s1, s2, n / sizeof(wchar_t));
}
/**
* `string_view` requires `wmemset` to exist. Provide a trivial
* implementation.
*/
static inline wchar_t *wmemset(wchar_t *dest, wchar_t ch, size_t count)
{
for (size_t i = 0; i < count; i++)
{
dest[i] = ch;
}
return dest;
}