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 /*
23  * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef UCS4_H
28 #define UCS4_H
29 #include <sys/isa_defs.h>
30 #include <sys/types.h>
31 #include "ucs2.h"
32 #include "gentypes.h"
33 
34 #define UCS4_NBYTE  4
35 #define UCS4_MAXVAL 0x7fffffff
36 #define UCS4_PPRC_MAXVAL 0xfffd	/* PPRC: Per Plane Row Column */
37 
38 #define room_for_ucs4_cnv(p1,p2) 	(((p1)+sizeof(ucs4_t))<=(p2))
39 #define no_room_for_ucs4_cnv(p1,p2) 	(((p1)+sizeof(ucs4_t))>(p2))
40 #define incomplete_ucs4_seq(p1,p2) 	(((p1)+sizeof(ucs4_t))>(p2))
41 
42 #define valid_ucs4_value(n) (_valid_ucs4_value(n))
43 
44 #define ext_ucs4_lsw(n)	((ucs2_t)((((ucs4_t)(n))&((ucs4_t)0x0000ffff))))
45 #define ext_ucs4_msw(n)	((ucs2_t)((((ucs4_t)(n))&((ucs4_t)0xffff0000))>>16))
46 
47 #define get_ucs4_word(p)        (*((ucs4_t*)(p)))
48 #define set_ucs4_word(p,n)	((*((ucs4_t*)(p)))=n)
49 
50 #if defined(_BIG_ENDIAN)
51 #define get_ucs4_word_BB(p)	(((ucs4_t)(get_ucs2_word_BB((p))<<16))|\
52 				 ((ucs4_t)(get_ucs2_word_BB((p)+2))))
53 
54 #define set_ucs4_word_BB(p,n) 	(set_ucs2_word_BB((p),ext_ucs4_msw(n)),\
55 				 set_ucs2_word_BB((p)+2,ext_ucs4_lsw(n)))
56 #else
57 #define get_ucs4_word_BB(p)	(((ucs4_t)(get_ucs2_word_BB((p)+2)<<16))|\
58 				 ((ucs4_t)(get_ucs2_word_BB(p))))
59 
60 #define set_ucs4_word_BB(p,n) 	(set_ucs2_word_BB((p)+2,ext_ucs4_msw(n)),\
61 				 set_ucs2_word_BB((p),ext_ucs4_lsw(n)))
62 #endif
63 
64 int _valid_ucs4_value(ucs4_t);
65 #endif
66