1 /* 2 * Copyright (c) 2019 The DragonFly Project. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 14 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 16 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 21 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 23 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27 #ifndef _CPU_WCHAR_H_ 28 #define _CPU_WCHAR_H_ 29 30 #include <machine/stdint.h> 31 32 /* 33 * wchar_t, wint_t and rune_t are signed so that EOF (-1) can be naturally 34 * assigned to it and used. The rune_t is meant for internal use only 35 * (see <ctype.h>). 36 */ 37 38 /* 39 * wchar_t and rune_t have to be of the same type. However there are some 40 * issues with language binding (c++ specifically where it is a keyword). 41 * Also "clang -fms-extensions" has a reserved keyword __wchar_t. Use 42 * ___wchar_t type only to declare wchar_t to avoid conflicts in headers. 43 * 44 * ANSI specifies ``int'' as argument for the is*() and to*() routines. 45 * Keeping wchar_t and rune_t as ``int'' instead of the more natural 46 * ``long'' helps ANSI conformance. ISO 10646 will most likely end up as 47 * 31 bit standard and all supported architectures have sizeof(int) >= 4. 48 * 49 * Allow compiler to override wchar_t with -fshort-wchar. 50 */ 51 #ifndef __cplusplus 52 #if defined(__SIZEOF_WCHAR_T__) && __SIZEOF_WCHAR_T__ == 2 53 #if defined(__WCHAR_TYPE__) 54 typedef __WCHAR_TYPE__ ___wchar_t; /* compiler short wchar type */ 55 #else 56 typedef unsigned short ___wchar_t; 57 #endif 58 #else 59 typedef int ___wchar_t; /* same as __ct_rune_t */ 60 #endif 61 #endif 62 63 /* 64 * wint_t and rune_t must be the same type. Also, wint_t should be able to 65 * hold all members of the largest character set plus one extra value (WEOF), 66 * and must be at least 16 bits. 67 */ 68 typedef int __wint_t; 69 70 /* 71 * mbstate_t is an opaque object to keep conversion state, during multibyte 72 * stream conversions. The content must not be referenced by user programs. 73 */ 74 typedef union { 75 __uint8_t __mbstate8[128]; 76 __int64_t __mbstateL; /* for alignment */ 77 } __mbstate_t; 78 79 #endif /* !_CPU_WCHAR_H_ */ 80