[libc-commits] [PATCH] D74021: Created uChar implementation for libc

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Aug 10 15:02:43 PDT 2020


sivachandra added a comment.

In D74021#2204954 <https://reviews.llvm.org/D74021#2204954>, @MarcusJohnson91 wrote:

> Hey guys, I'm rebasing and starting work on this again, sorry for the wait I moved 2000 miles from Michigan to Oregon.
>
> I have a question tho.
>
> Uchar and wchar both rely on mbstate_t which is a global variable for their conversions.
>
> I'm currently using an enum to hold the valid states different conversions can be in, and I'm wondering how it should all be layered together?

The standard says `mbstate_t` should be of a struct type: https://en.cppreference.com/w/c/string/multibyte/mbstate_t

But, I didn't find anything which says the state is a libc maintained global state. So, other than the fact that we need to define that struct in a common place like this <https://github.com/llvm/llvm-project/blob/master/libc/include/__llvm-libc-stdc-types.h>, I do not see anything affecting the layering. Am I missing something?

> Should uchar depend on wchar, should wchar depend on uchar, should there be a private header that both of them use?
>
> and also what about namespaces, should the enum be in a private namespace and the mbstate_t global be in a public namespace?

Yes, you can choose to keep the "internals" of `mbstate_t` in an internal namespace.

> Any clarification would be great, thanks.




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74021/new/

https://reviews.llvm.org/D74021



More information about the libc-commits mailing list