Initial commit
[o-du/l2.git] / src / cm / envind.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /********************************************************************20**
20   
21      Name:     environment independent
22   
23      Type:     C include file
24   
25      Desc:     Environment independent defines required by the
26                by TRILLIUM software. The defines in this file should
27                not change regardless of the processor family
28                under which the TRILLIUM software will run.
29   
30      File:     envind.h
31   
32 *********************************************************************21*/
33   
34 #ifndef __ENVINDH__
35 #define __ENVINDH__
36
37 \f 
38 /* defines */
39 /*envind_h_001.main_20*/
40 #ifndef SS_RMIOS
41 #ifdef FALSE
42 #undef FALSE
43 #define FALSE          0         /* for booleans */
44 #else
45 #define FALSE          0         /* for booleans */
46 #endif
47
48 #ifdef TRUE
49 #undef TRUE
50 #define TRUE           1         /* for booleans */
51 #else
52 #define TRUE           1         /* for booleans */
53 #endif /* TRUE */
54 #endif
55   
56 #define NO             0         /* for booleans */
57 #define YES            1         /* for booleans */
58
59 #define OFF            0         /* for booleans */
60 #define ON             1         /* for booleans */
61    
62 #define OK             0         /* for function returns */
63 #define FAIL           (-1)      /* for function returns */
64
65 #define BASE10         10        /* Base 10 */
66 #define BASE16         16        /* Base 16 */
67
68 \f
69 /* ASCII character set */
70   
71 #define A_NULL       0x00        /* null */
72 #define A_SOH        0x01        /* start of header */
73 #define A_STX        0x02        /* start of text */
74 #define A_ETX        0x03        /* end of text */
75 #define A_EOT        0x04        /* end of transmission */
76 #define A_ENQ        0x05        /* enquiry */
77 #define A_ACK        0x06        /* acknowledge */
78 #define A_BELL       0x07        /* bell */
79 #define A_BS         0x08        /* backspace */
80 #define A_HT         0x09        /* horizontal tab */
81 #define A_LF         0x0a        /* line feed */
82 #define A_VT         0x0b        /* vertical tab */
83 #define A_FF         0x0c        /* form feed */
84 #define A_CR         0x0d        /* carriage return */
85 #define A_SO         0x0e        /* SO */
86 #define A_SI         0x0f        /* SI */
87 #define A_DLE        0x10        /* data link escape */
88 #define A_DC1        0x11        /* data control 1 */
89 #define A_DC2        0x12        /* data control 2 */
90 #define A_DC3        0x13        /* data control 3 */
91 #define A_DC4        0x14        /* data control 4 */
92 #define A_NAK        0x15        /* negative acknowledge */
93 #define A_SYN        0x16        /* synchronize */
94 #define A_ETB        0x17        /* end of text block */
95 #define A_CAN        0x18        /* cancel */
96 #define A_EM         0x19        /* EM */
97 #define A_SUB        0x1A        /* SUB */
98 #define A_ESC        0x1B        /* escape */
99 #define A_FS         0x1C        /* FS */
100 #define A_GS         0x1D        /* GS */
101 #define A_RS         0x1E        /* RS */
102 #define A_US         0x1F        /* US */
103 #define A_SP         0x20        /* space */
104 #define A_EXCLAIM    0x21        /* ! */
105 #define A_DBLQUO     0x22        /* " */
106 #define A_POUND      0x23        /* # */
107 #define A_DOLLAR     0x24        /* $ */
108 #define A_PERCENT    0x25        /* % */
109 #define A_AND        0x26        /* & */
110 #define A_SNGQUO     0x27        /* ' */
111 #define A_LTPARENT   0x28        /* ( */
112 #define A_RTPARENT   0x29        /* ) */
113 #define A_ASTERISK   0x2A        /* * */
114 #define A_PLUS       0x2B        /* + */
115 #define A_COMMA      0x2C        /* , */
116 #define A_HYPHEN     0x2D        /* - */
117 #define A_PERIOD     0x2E        /* . */
118 #define A_FWDSL      0x2F        /* forward slash */
119 #define A_0          0x30        /* 0 */
120 #define A_1          0x31        /* 1 */
121 #define A_2          0x32        /* 2 */
122 #define A_3          0x33        /* 3 */
123 #define A_4          0x34        /* 4 */
124 #define A_5          0x35        /* 5 */
125 #define A_6          0x36        /* 6 */
126 #define A_7          0x37        /* 7 */
127 #define A_8          0x38        /* 8 */
128 #define A_9          0x39        /* 9 */
129 #define A_COLON      0x3A        /* : */
130 #define A_SCOLON     0x3B        /*;*/
131 #define A_LT         0x3C        /* < */
132 #define A_EQUAL      0x3D        /* = */
133 #define A_GT         0x3E        /* > */
134 #define A_QMARK      0x3F        /* ? */
135 #define A_AMPER      0x40        /* @ */
136 #define A_UP_A       0x41        /* A - upper case */
137 #define A_UP_B       0x42        /* B - upper case */
138 #define A_UP_C       0x43        /* C - upper case */
139 #define A_UP_D       0x44        /* D - upper case */
140 #define A_UP_E       0x45        /* E - upper case */
141 #define A_UP_F       0x46        /* F - upper case */
142 #define A_UP_G       0x47        /* G - upper case */
143 #define A_UP_H       0x48        /* H - upper case */
144 #define A_UP_I       0x49        /* I - upper case */
145 #define A_UP_J       0x4A        /* J - upper case */
146 #define A_UP_K       0x4B        /* K - upper case */
147 #define A_UP_L       0x4C        /* L - upper case */
148 #define A_UP_M       0x4D        /* M - upper case */
149 #define A_UP_N       0x4E        /* N - upper case */
150 #define A_UP_O       0x4F        /* O - upper case */
151 #define A_UP_P       0x50        /* P - upper case */
152 #define A_UP_Q       0x51        /* Q - upper case */
153 #define A_UP_R       0x52        /* R - upper case */
154 #define A_UP_S       0x53        /* S - upper case */
155 #define A_UP_T       0x54        /* T - upper case */
156 #define A_UP_U       0x55        /* U - upper case */
157 #define A_UP_V       0x56        /* V - upper case */
158 #define A_UP_W       0x57        /* W - upper case */
159 #define A_UP_X       0x58        /* X - upper case */
160 #define A_UP_Y       0x59        /* Y - upper case */
161 #define A_UP_Z       0x5A        /* Z - upper case */
162 #define A_BKSL       0x5C        /* backslash */
163 #define A_LW_A       0x61        /* a - lower case */
164 #define A_LW_B       0x62        /* b - lower case */
165 #define A_LW_C       0x63        /* c - lower case */
166 #define A_LW_D       0x64        /* d - lower case */
167 #define A_LW_E       0x65        /* e - lower case */
168 #define A_LW_F       0x66        /* f - lower case */
169 #define A_LW_G       0x67        /* g - lower case */
170 #define A_LW_H       0x68        /* h - lower case */
171 #define A_LW_I       0x69        /* i - lower case */
172 #define A_LW_J       0x6A        /* j - lower case */
173 #define A_LW_K       0x6B        /* k - lower case */
174 #define A_LW_L       0x6C        /* l - lower case */
175 #define A_LW_M       0x6D        /* m - lower case */
176 #define A_LW_N       0x6E        /* n - lower case */
177 #define A_LW_O       0x6F        /* o - lower case */
178 #define A_LW_P       0x70        /* p - lower case */
179 #define A_LW_Q       0x71        /* q - lower case */
180 #define A_LW_R       0x72        /* r - lower case */
181 #define A_LW_S       0x73        /* s - lower case */
182 #define A_LW_T       0x74        /* t - lower case */
183 #define A_LW_U       0x75        /* u - lower case */
184 #define A_LW_V       0x76        /* v - lower case */
185 #define A_LW_W       0x77        /* w - lower case */
186 #define A_LW_X       0x78        /* x - lower case */
187 #define A_LW_Y       0x79        /* y - lower case */
188 #define A_LW_Z       0x7A        /* z - lower case */
189 #define A_DEL        0x7F        /* delete */
190 #define A_INVCHR     0xFF        /* invalid */
191
192 #define IA5MAX       128         /* maximum number of ASCII characters */
193  
194 \f  
195 /* general macros */
196
197 /* Moved macros MIN and MAX to envdep.h */
198
199 #ifdef ABS
200 #undef ABS
201 #define ABS(x) ((x) < 0 ? -(x) : x)                  /* absolute value */
202 #else
203 #define ABS(x) ((x) < 0 ? -(x) : x)                  /* absolute value */
204 #endif /* ABS */
205
206 /* RG: changed the order of parentheses to make the casts more accurate */
207
208 #define GetHiByte(w)   (((U16)(w) >> 8) & 0xff)      /* get hi byte from word */
209 #define GetLoByte(w)   ((U16)(w) & 0xff)             /* get lo byte from word */
210 #define GetHiWord(l)   (((U32)(l) >> 16) & 0xffffL)  /* get hi word of long */
211 #define GetLoWord(l)   ((U32)(l) & 0xffffL)          /* get lo word of long */
212
213 /* envind_h_001_102: add 64 bit support */
214 #if (defined(ALPHA) || defined(BIT_64))
215 #define GetLo32Bit(l) ((U64)(l) & 0xffffffffL) /*get lo 32 bits */
216 #define GetHi32Bit(l) (((U64)(l) >> 32) & 0xffffffffL) /*get hi 32 bits */
217 #endif
218
219 /* RG: changed put macros so the target does not have to be cleared before use */
220
221 #define PutHiByte(w,b) (U16) (((U16)(b) << 8) | ((U16)(w) & 0x00ff))      /* put hi byte to word */
222 #define PutLoByte(w,b) (U16) (((U16)(b) & 0xff) | ((U16)(w) & 0xff00))             /* put lo byte to word */
223 #define PutHiWord(l,w) (U32) (((U32)(w) << 16) | ((U32)(l) & (U32)0x0000ffff)) /* put hi word to long */
224 #define PutLoWord(l,w) (U32) (((U32)(w) & 0xffff) | ((U32)(l) & (U32)0xffff0000))         /* put lo word to long */
225
226 /* envind_h_001_102: add 64 bit support */
227 #if (defined(ALPHA) || defined(BIT_64))
228 #define PutLo32Bit(l,w) (U64) (((U64)(w) & 0xffffffff) | ((U64)(l) & (U64)0xffffffff00000000))  /* put lo 32 bits */
229 #define PutHi32Bit(l,w) (U64) (((U64)(w) << 32) | ((U64)(l) & (U64)0x00000000ffffffff))         /* put hi 32 bits */
230 #endif
231
232 #define Char(c)        ((c) & 0x7f)             /* truncate to 7 bits */
233 #define Byte(c)        ((c) & 0xff)             /* truncate to 8 bits */
234 #define Word(c)        ((c) & 0xffffL)          /* truncate to 16 bits */
235   
236 #define IsOdd(c)   (((c % 2) == 1) ? TRUE:FALSE)
237 #define IsEven(c)  (((c % 2) == 0) ? TRUE:FALSE)
238
239 #define StripPar(c)    ((c) & 0x7f)
240
241 \f 
242 /* ASCII character set macros */
243   
244 #define AIsUpper(c)    ((c>=A_UP_A) && (c<=A_UP_Z))
245 #define AIsLower(c)    ((c>=A_LW_A) && (c<=A_LW_Z))
246 #define AIsAlpha(c)    (AIsUpper(c) || AIsLower(c))
247 #define AIsDigit(c)    ((c>=A_0) && (c<=A_9))
248 #define AIsSpace(c)    ((c==A_SP) || (c==A_HT) || (c==A_LF))
249 #define AIsWhite(c)    ((c==A_SP) || (c==A_HT) || (c==A_LF))
250 #define AToUpper(c)    (AIsLower(c) ? (c+A_UP_A-A_LW_A):(c))
251 #define AToLower(c)    (AIsUpper(c) ? (c+A_LW_A-A_UP_A):(c))
252   
253 #define AIsAscii(c)    ((c>=A_SP) && (c<A_DEL))
254 #define AIsXupper(c)   ((c>=A_UP_A) && (c<=A_UP_F))
255 #define AIsXlower(c)   ((c>=A_LW_A) && (c<=A_LW_F))
256 #define AIsXdigit(c)   (AIsDigit(c) || AIsXupper(c) || AIsXlower(c))
257 #define AIsCntrl(c)    (((c>=A_NULL) && (c<A_SP)) || (c==A_DEL))
258   
259 #define ACmdDelim(c)   ((c == A_CR) || (c == A_PLUS))
260
261 #endif
262 \f  
263 /********************************************************************30**
264   
265          End of file
266 **********************************************************************/