xref: /illumos-gate/usr/src/lib/iconv_modules/ko/common/common_han.h (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1996 by Sun Microsystems, Inc.
23  */
24 
25 
26 #ifndef _COMMON_HAN_H_
27 #define	_COMMON_HAN_H_
28 
29 #include <sys/isa_defs.h>
30 
31 #ifdef	_BIG_ENDIAN
32 
33 typedef union {
34         unsigned int code;
35         struct {
36                 unsigned short high;
37                 unsigned short low;
38         } word;
39         struct {
40                 unsigned char byte1;
41                 unsigned char byte2;
42                 unsigned char byte3;
43                 unsigned char byte4;
44         } byte;
45         struct {
46                 unsigned int    high16bits:     16;	/* should be 0x00 */
47                 unsigned int    msb1:           1;	/* should be 0x01 */
48                 unsigned int    data1:       	7;
49                 unsigned int    msb2:           1;	/* should be 0x01 */
50                 unsigned int    data2:       	7;
51         } wansung;
52         struct {
53                 unsigned int    high16bits:     16;	/* should be 0x00 */
54                 unsigned int    msb:            1;	/* should be 0x01 */
55                 unsigned int    chosung:        5;
56                 unsigned int    joongsung:      5;
57                 unsigned int    jongsung:       5;
58         } johap;
59         struct {
60                 unsigned int    high16bits:     16;	/* should be 0x00 */
61                 unsigned int    data1:          4;
62                 unsigned int    data2:          6;
63                 unsigned int    data3:          6;
64         } unicode;
65         struct {
66                 unsigned int    high8bits:      8;	/* should be 0x00 */
67                 unsigned int    sign1:          4;	/* should be 0x0E */
68                 unsigned int    data1:          4;
69                 unsigned int    sign2:          2;	/* should be 0x02 */
70                 unsigned int    data2:          6;
71                 unsigned int    sign3:          2;	/* should be 0x02 */
72                 unsigned int    data3:          6;
73         } utf8;
74 } hcode_type;
75 
76 #else /* _BIG_ENDIAN */
77 
78 typedef union {
79         unsigned int code;
80         struct {
81                 unsigned short low;
82                 unsigned short high;
83         } word;
84         struct {
85                 unsigned char byte4;
86                 unsigned char byte3;
87                 unsigned char byte2;
88                 unsigned char byte1;
89         } byte;
90         struct {
91                 unsigned int    data2:       	7;
92                 unsigned int    msb2:           1;	/* should be 0x01 */
93                 unsigned int    data1:       	7;
94                 unsigned int    msb1:           1;	/* should be 0x01 */
95                 unsigned int    high16bits:     16;	/* should be 0x00 */
96         } wansung;
97         struct {
98                 unsigned int    jongsung:       5;
99                 unsigned int    joongsung:      5;
100                 unsigned int    chosung:        5;
101                 unsigned int    msb:            1;	/* should be 0x01 */
102                 unsigned int    high16bits:     16;	/* should be 0x00 */
103         } johap;
104         struct {
105                 unsigned int    data3:          6;
106                 unsigned int    data2:          6;
107                 unsigned int    data1:          4;
108                 unsigned int    high16bits:     16;	/* should be 0x00 */
109         } unicode;
110         struct {
111                 unsigned int    data3:          6;
112                 unsigned int    sign3:          2;	/* should be 0x02 */
113                 unsigned int    data2:          6;
114                 unsigned int    sign2:          2;	/* should be 0x02 */
115                 unsigned int    data1:          4;
116                 unsigned int    sign1:          4;	/* should be 0x0E */
117                 unsigned int    high8bits:      8;	/* should be 0x00 */
118         } utf8;
119 } hcode_type;
120 
121 #endif /* _BIG_ENDIAN */
122 
123 #endif	/* _COMMON_HAN_H_ */
124