xref: /illumos-gate/usr/src/head/uchar.h (revision aadb5ba0)
1eda3ef2dSRobert Mustacchi /*
2eda3ef2dSRobert Mustacchi  * This file and its contents are supplied under the terms of the
3eda3ef2dSRobert Mustacchi  * Common Development and Distribution License ("CDDL"), version 1.0.
4eda3ef2dSRobert Mustacchi  * You may only use this file in accordance with the terms of version
5eda3ef2dSRobert Mustacchi  * 1.0 of the CDDL.
6eda3ef2dSRobert Mustacchi  *
7eda3ef2dSRobert Mustacchi  * A full copy of the text of the CDDL should have accompanied this
8eda3ef2dSRobert Mustacchi  * source.  A copy of the CDDL is also available via the Internet at
9eda3ef2dSRobert Mustacchi  * http://www.illumos.org/license/CDDL.
10eda3ef2dSRobert Mustacchi  */
11eda3ef2dSRobert Mustacchi 
12eda3ef2dSRobert Mustacchi /*
13eda3ef2dSRobert Mustacchi  * Copyright 2020 Robert Mustacchi
14eda3ef2dSRobert Mustacchi  */
15eda3ef2dSRobert Mustacchi 
16eda3ef2dSRobert Mustacchi #ifndef _UCHAR_H
17eda3ef2dSRobert Mustacchi #define	_UCHAR_H
18eda3ef2dSRobert Mustacchi 
19eda3ef2dSRobert Mustacchi /*
20eda3ef2dSRobert Mustacchi  * C11 Unicode utilities support.
21eda3ef2dSRobert Mustacchi  *
22eda3ef2dSRobert Mustacchi  * Note, we do not define either __STDC_UTF_16__ or __STDC_UTF_32__. While the
23eda3ef2dSRobert Mustacchi  * functions that are implemented work in that fashion, the ability to represent
24eda3ef2dSRobert Mustacchi  * any UTF-16 or UTF-32 code point depends on the current locale. Though in
25eda3ef2dSRobert Mustacchi  * practice they function that way.
26eda3ef2dSRobert Mustacchi  */
27eda3ef2dSRobert Mustacchi 
28eda3ef2dSRobert Mustacchi #include <sys/isa_defs.h>
29eda3ef2dSRobert Mustacchi #include <sys/feature_tests.h>
30eda3ef2dSRobert Mustacchi #include <wchar_impl.h>
31eda3ef2dSRobert Mustacchi 
32eda3ef2dSRobert Mustacchi #ifdef __cplusplus
33eda3ef2dSRobert Mustacchi extern "C" {
34eda3ef2dSRobert Mustacchi #endif
35eda3ef2dSRobert Mustacchi 
36eda3ef2dSRobert Mustacchi #if !defined(_SIZE_T) || __cplusplus >= 199711L
37eda3ef2dSRobert Mustacchi #define	_SIZE_T
38eda3ef2dSRobert Mustacchi #if defined(_LP64) || defined(_I32LPx)
39eda3ef2dSRobert Mustacchi typedef	unsigned long size_t;	/* size of something in bytes */
40eda3ef2dSRobert Mustacchi #else
41eda3ef2dSRobert Mustacchi typedef	unsigned int size_t;	/* (historical version) */
42eda3ef2dSRobert Mustacchi #endif
43eda3ef2dSRobert Mustacchi #endif	/* _SIZE_T */
44eda3ef2dSRobert Mustacchi 
45eda3ef2dSRobert Mustacchi #if !defined(_MBSTATE_T) || __cplusplus >= 199711L
46eda3ef2dSRobert Mustacchi #define	_MBSTATE_T
47eda3ef2dSRobert Mustacchi typedef __mbstate_t	mbstate_t;
48eda3ef2dSRobert Mustacchi #endif	/* _MBSTATE_T */
49eda3ef2dSRobert Mustacchi 
50eda3ef2dSRobert Mustacchi /*
51eda3ef2dSRobert Mustacchi  * These types must match the uint_least16_t and uint_least32_t. They are
52eda3ef2dSRobert Mustacchi  * defined in terms of the same type so as to minimize the needed includes.
53eda3ef2dSRobert Mustacchi  * C++11 also defines these types and they are considered built in, so we should
54eda3ef2dSRobert Mustacchi  * not define them in that context.
55eda3ef2dSRobert Mustacchi  */
56*aadb5ba0SRobert Mustacchi #if __cplusplus < 201103L
57eda3ef2dSRobert Mustacchi typedef unsigned short	char16_t;
58eda3ef2dSRobert Mustacchi typedef unsigned int	char32_t;
59eda3ef2dSRobert Mustacchi #endif
60eda3ef2dSRobert Mustacchi 
61eda3ef2dSRobert Mustacchi extern size_t mbrtoc16(char16_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
62eda3ef2dSRobert Mustacchi     size_t, mbstate_t *_RESTRICT_KYWD);
63eda3ef2dSRobert Mustacchi extern size_t mbrtoc32(char32_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
64eda3ef2dSRobert Mustacchi     size_t, mbstate_t *_RESTRICT_KYWD);
65eda3ef2dSRobert Mustacchi extern size_t c16rtomb(char *_RESTRICT_KYWD, char16_t,
66eda3ef2dSRobert Mustacchi     mbstate_t *_RESTRICT_KYWD);
67eda3ef2dSRobert Mustacchi extern size_t c32rtomb(char *_RESTRICT_KYWD, char32_t,
68eda3ef2dSRobert Mustacchi     mbstate_t *_RESTRICT_KYWD);
69eda3ef2dSRobert Mustacchi 
70eda3ef2dSRobert Mustacchi #ifdef __cplusplus
71eda3ef2dSRobert Mustacchi }
72eda3ef2dSRobert Mustacchi #endif
73eda3ef2dSRobert Mustacchi 
74eda3ef2dSRobert Mustacchi #endif /* _UCHAR_H */
75