8 size_t mbsrtowcs(wchar_t *restrict ws
, const char **restrict src
, size_t wn
, mbstate_t *restrict st
)
10 const unsigned char *s
= (const void *)*src
;
14 if (st
&& (c
= *(unsigned *)st
)) {
24 if (!ws
) return strlen((const char *)s
);
27 *src
= (const void *)s
;
41 if (*s
-1u < 0x7f && (uintptr_t)s
%4 == 0) {
42 while (!(( *(uint32_t*)s
| *(uint32_t*)s
-0x01010101) & 0x80808080)) {
52 if (*s
-SA
> SB
-SA
) break;
55 if (OOB(c
,*s
)) { s
--; break; }
58 if (*s
-0x80u
>= 0x40) { s
-=2; break; }
61 if (*s
-0x80u
>= 0x40) { s
-=3; break; }
69 *src
= (const void *)s
;
72 if (*s
-1u < 0x7f && (uintptr_t)s
%4 == 0) {
73 while (wn
>=5 && !(( *(uint32_t*)s
| *(uint32_t*)s
-0x01010101) & 0x80808080)) {
86 if (*s
-SA
> SB
-SA
) break;
89 if (OOB(c
,*s
)) { s
--; break; }
90 c
= (c
<<6) | *s
++-0x80;
92 if (*s
-0x80u
>= 0x40) { s
-=2; break; }
93 c
= (c
<<6) | *s
++-0x80;
95 if (*s
-0x80u
>= 0x40) { s
-=3; break; }
96 c
= (c
<<6) | *s
++-0x80;
112 if (ws
) *src
= (const void *)s
;