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