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