]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/string/wmemmove.c
Use bulk memory opcodes when possible
[wasi-libc.git] / libc-top-half / musl / src / string / wmemmove.c
1 #include <wchar.h>
2 #include <stdint.h>
3
4 wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
5 {
6 #if defined(__wasm_bulk_memory__)
7 return __builtin_wmemmove(d, s, n);
8 #else
9 wchar_t *d0 = d;
10 if (d == s) return d;
11 if ((uintptr_t)d-(uintptr_t)s < n * sizeof *d)
12 while (n--) d[n] = s[n];
13 else
14 while (n--) *d++ = *s++;
15 return d0;
16 #endif // __wasm_bulk_memory__
17 }