1*91e1e26aSAlexander Pyhalov /* 2*91e1e26aSAlexander Pyhalov * CDDL HEADER START 3*91e1e26aSAlexander Pyhalov * 4*91e1e26aSAlexander Pyhalov * The contents of this file are subject to the terms of the 5*91e1e26aSAlexander Pyhalov * Common Development and Distribution License (the "License"). 6*91e1e26aSAlexander Pyhalov * You may not use this file except in compliance with the License. 7*91e1e26aSAlexander Pyhalov * 8*91e1e26aSAlexander Pyhalov * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE 9*91e1e26aSAlexander Pyhalov * or http://www.opensolaris.org/os/licensing. 10*91e1e26aSAlexander Pyhalov * See the License for the specific language governing permissions 11*91e1e26aSAlexander Pyhalov * and limitations under the License. 12*91e1e26aSAlexander Pyhalov * 13*91e1e26aSAlexander Pyhalov * When distributing Covered Code, include this CDDL HEADER in each 14*91e1e26aSAlexander Pyhalov * file and include the License file at src/OPENSOLARIS.LICENSE. 15*91e1e26aSAlexander Pyhalov * If applicable, add the following below this CDDL HEADER, with the 16*91e1e26aSAlexander Pyhalov * fields enclosed by brackets "[]" replaced with your own identifying 17*91e1e26aSAlexander Pyhalov * information: Portions Copyright [yyyy] [name of copyright owner] 18*91e1e26aSAlexander Pyhalov * 19*91e1e26aSAlexander Pyhalov * CDDL HEADER END 20*91e1e26aSAlexander Pyhalov */ 21*91e1e26aSAlexander Pyhalov 22*91e1e26aSAlexander Pyhalov /* 23*91e1e26aSAlexander Pyhalov * Copyright 1998 Sun Microsystems, Inc. All rights reserved. 24*91e1e26aSAlexander Pyhalov * Use is subject to license terms. 25*91e1e26aSAlexander Pyhalov */ 26*91e1e26aSAlexander Pyhalov 27*91e1e26aSAlexander Pyhalov #ifndef UCS2_H 28*91e1e26aSAlexander Pyhalov #define UCS2_H 29*91e1e26aSAlexander Pyhalov #include <sys/types.h> 30*91e1e26aSAlexander Pyhalov #include <sys/isa_defs.h> 31*91e1e26aSAlexander Pyhalov #include "gentypes.h" 32*91e1e26aSAlexander Pyhalov 33*91e1e26aSAlexander Pyhalov #define UCS2_NBYTE 2 34*91e1e26aSAlexander Pyhalov #define UCS2_MAXVAL 0xfffd 35*91e1e26aSAlexander Pyhalov 36*91e1e26aSAlexander Pyhalov #define valid_ucs2_value(n) (_valid_ucs2_value(n)) 37*91e1e26aSAlexander Pyhalov #define room_for_ucs2_cnv(p1,p2) (((p1)+sizeof(ucs2_t))<=(p2)) 38*91e1e26aSAlexander Pyhalov #define no_room_for_ucs2_cnv(p1,p2) (((p1)+sizeof(ucs2_t))>(p2)) 39*91e1e26aSAlexander Pyhalov #define incomplete_ucs2_seq(p1,p2) (((p1)+sizeof(ucs2_t))>(p2)) 40*91e1e26aSAlexander Pyhalov 41*91e1e26aSAlexander Pyhalov #define next_ucs2_ptr(p) (((uchar_t*)(p))+sizeof(ucs2_t)) 42*91e1e26aSAlexander Pyhalov #define ext_ucs2_lsb(n) ((uchar_t)(((ucs2_t)(n))&((ucs2_t)0x00ff))) 43*91e1e26aSAlexander Pyhalov #define ext_ucs2_msb(n) ((uchar_t)(((((ucs2_t)(n))&((ucs2_t)0xff00)))>>8)) 44*91e1e26aSAlexander Pyhalov 45*91e1e26aSAlexander Pyhalov #define get_ucs2_word(p) (*((ucs2_t*)(p))) 46*91e1e26aSAlexander Pyhalov #define set_ucs2_word(p,n) ((*((ucs2_t*)(p)))=(n)) 47*91e1e26aSAlexander Pyhalov 48*91e1e26aSAlexander Pyhalov #if defined(_BIG_ENDIAN) 49*91e1e26aSAlexander Pyhalov #define get_ucs2_word_BB(p) \ 50*91e1e26aSAlexander Pyhalov (((ucs2_t)((*(p))<<8))|((ucs2_t)(*((p)+1)))) 51*91e1e26aSAlexander Pyhalov 52*91e1e26aSAlexander Pyhalov #define set_ucs2_word_BB(p,n) \ 53*91e1e26aSAlexander Pyhalov (((*(p))=ext_ucs2_msb(n)),((*((p)+1))=ext_ucs2_lsb(n))) 54*91e1e26aSAlexander Pyhalov 55*91e1e26aSAlexander Pyhalov #else 56*91e1e26aSAlexander Pyhalov #define get_ucs2_word_BB(p) \ 57*91e1e26aSAlexander Pyhalov (((ucs2_t)(((*((p)+1)))<<8))|((ucs2_t)(*(p)))) 58*91e1e26aSAlexander Pyhalov 59*91e1e26aSAlexander Pyhalov #define set_ucs2_word_BB(p,n) \ 60*91e1e26aSAlexander Pyhalov ((*((p)+1))=ext_ucs2_msb(n),(*(p))=ext_ucs2_lsb(n)) 61*91e1e26aSAlexander Pyhalov #endif 62*91e1e26aSAlexander Pyhalov 63*91e1e26aSAlexander Pyhalov int _valid_ucs2_value(ucs4_t); 64*91e1e26aSAlexander Pyhalov #endif 65