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