cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
gf_mul_lo.h
Go to the documentation of this file.
1 /*
2  ---------------------------------------------------------------------------
3  Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
4 
5  LICENSE TERMS
6 
7  The redistribution and use of this software (with or without changes)
8  is allowed without the payment of fees or royalties provided that:
9 
10  1. source code distributions include the above copyright notice, this
11  list of conditions and the following disclaimer;
12 
13  2. binary distributions include the above copyright notice, this list
14  of conditions and the following disclaimer in their documentation;
15 
16  3. the name of the copyright holder is not used to endorse products
17  built using this software without specific written permission.
18 
19  DISCLAIMER
20 
21  This software is provided 'as is' with no explicit or implied warranties
22  in respect of its properties, including, but not limited to, correctness
23  and/or fitness for purpose.
24  ---------------------------------------------------------------------------
25  Issue Date: 20/12/2007
26 
27  This file provides the low level primitives needed for Galois Field
28  operations in GF(2^128) for the four most likely field representations.
29 */
30 
31 #ifndef _GF_MUL_LO_H
32 #define _GF_MUL_LO_H
33 
34 #if defined( USE_INLINING )
35 # if defined( _MSC_VER )
36 # define gf_decl __inline
37 # elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
38 # define gf_decl static inline
39 # else
40 # define gf_decl static
41 # endif
42 #endif
43 
44 #if 0 /* used for testing only: t1(UNIT_BITS), t2(UNIT_BITS) */
45 # define _t1(n) bswap ## n ## _block(x, x)
46 # define t1(n) _t1(n)
47 # define _t2(n) bswap ## n ## _block(x, x); bswap ## n ## _block(r, r)
48 # define t2(n) _t2(n)
49 #endif
50 
51 #define gf_m(n,x) gf_mulx ## n ## x
52 #define gf_mulx1(x) gf_m(1,x)
53 #define gf_mulx4(x) gf_m(4,x)
54 #define gf_mulx8(x) gf_m(8,x)
55 
56 #define MASK(x) ((x) * (UNIT_CAST(-1,UNIT_BITS) / 0xff))
57 
58 #define DATA_256(q) {\
59  q(0x00), q(0x01), q(0x02), q(0x03), q(0x04), q(0x05), q(0x06), q(0x07),\
60  q(0x08), q(0x09), q(0x0a), q(0x0b), q(0x0c), q(0x0d), q(0x0e), q(0x0f),\
61  q(0x10), q(0x11), q(0x12), q(0x13), q(0x14), q(0x15), q(0x16), q(0x17),\
62  q(0x18), q(0x19), q(0x1a), q(0x1b), q(0x1c), q(0x1d), q(0x1e), q(0x1f),\
63  q(0x20), q(0x21), q(0x22), q(0x23), q(0x24), q(0x25), q(0x26), q(0x27),\
64  q(0x28), q(0x29), q(0x2a), q(0x2b), q(0x2c), q(0x2d), q(0x2e), q(0x2f),\
65  q(0x30), q(0x31), q(0x32), q(0x33), q(0x34), q(0x35), q(0x36), q(0x37),\
66  q(0x38), q(0x39), q(0x3a), q(0x3b), q(0x3c), q(0x3d), q(0x3e), q(0x3f),\
67  q(0x40), q(0x41), q(0x42), q(0x43), q(0x44), q(0x45), q(0x46), q(0x47),\
68  q(0x48), q(0x49), q(0x4a), q(0x4b), q(0x4c), q(0x4d), q(0x4e), q(0x4f),\
69  q(0x50), q(0x51), q(0x52), q(0x53), q(0x54), q(0x55), q(0x56), q(0x57),\
70  q(0x58), q(0x59), q(0x5a), q(0x5b), q(0x5c), q(0x5d), q(0x5e), q(0x5f),\
71  q(0x60), q(0x61), q(0x62), q(0x63), q(0x64), q(0x65), q(0x66), q(0x67),\
72  q(0x68), q(0x69), q(0x6a), q(0x6b), q(0x6c), q(0x6d), q(0x6e), q(0x6f),\
73  q(0x70), q(0x71), q(0x72), q(0x73), q(0x74), q(0x75), q(0x76), q(0x77),\
74  q(0x78), q(0x79), q(0x7a), q(0x7b), q(0x7c), q(0x7d), q(0x7e), q(0x7f),\
75  q(0x80), q(0x81), q(0x82), q(0x83), q(0x84), q(0x85), q(0x86), q(0x87),\
76  q(0x88), q(0x89), q(0x8a), q(0x8b), q(0x8c), q(0x8d), q(0x8e), q(0x8f),\
77  q(0x90), q(0x91), q(0x92), q(0x93), q(0x94), q(0x95), q(0x96), q(0x97),\
78  q(0x98), q(0x99), q(0x9a), q(0x9b), q(0x9c), q(0x9d), q(0x9e), q(0x9f),\
79  q(0xa0), q(0xa1), q(0xa2), q(0xa3), q(0xa4), q(0xa5), q(0xa6), q(0xa7),\
80  q(0xa8), q(0xa9), q(0xaa), q(0xab), q(0xac), q(0xad), q(0xae), q(0xaf),\
81  q(0xb0), q(0xb1), q(0xb2), q(0xb3), q(0xb4), q(0xb5), q(0xb6), q(0xb7),\
82  q(0xb8), q(0xb9), q(0xba), q(0xbb), q(0xbc), q(0xbd), q(0xbe), q(0xbf),\
83  q(0xc0), q(0xc1), q(0xc2), q(0xc3), q(0xc4), q(0xc5), q(0xc6), q(0xc7),\
84  q(0xc8), q(0xc9), q(0xca), q(0xcb), q(0xcc), q(0xcd), q(0xce), q(0xcf),\
85  q(0xd0), q(0xd1), q(0xd2), q(0xd3), q(0xd4), q(0xd5), q(0xd6), q(0xd7),\
86  q(0xd8), q(0xd9), q(0xda), q(0xdb), q(0xdc), q(0xdd), q(0xde), q(0xdf),\
87  q(0xe0), q(0xe1), q(0xe2), q(0xe3), q(0xe4), q(0xe5), q(0xe6), q(0xe7),\
88  q(0xe8), q(0xe9), q(0xea), q(0xeb), q(0xec), q(0xed), q(0xee), q(0xef),\
89  q(0xf0), q(0xf1), q(0xf2), q(0xf3), q(0xf4), q(0xf5), q(0xf6), q(0xf7),\
90  q(0xf8), q(0xf9), q(0xfa), q(0xfb), q(0xfc), q(0xfd), q(0xfe), q(0xff) }
91 
92 /* Given the value i in 0..255 as the byte overflow when a field element
93  in GHASH is multipled by x^8, this function will return the values that
94  are generated in the lo 16-bit word of the field value by applying the
95  modular polynomial. The values lo_byte and hi_byte are returned via the
96  macro xp_fun(lo_byte, hi_byte) so that the values can be assembled into
97  memory as required by a suitable definition of this macro operating on
98  the table above
99 */
100 
101 #if defined( GF_MODE_BL ) || defined( GF_MODE_LL )
102 
103 #define gf_uint16_xor(i) ( \
104  (i & 0x01 ? xx(00,87) : 0) ^ (i & 0x02 ? xx(01,0e) : 0) ^ \
105  (i & 0x04 ? xx(02,1c) : 0) ^ (i & 0x08 ? xx(04,38) : 0) ^ \
106  (i & 0x10 ? xx(08,70) : 0) ^ (i & 0x20 ? xx(10,e0) : 0) ^ \
107  (i & 0x40 ? xx(21,c0) : 0) ^ (i & 0x80 ? xx(43,80) : 0) )
108 
109 enum x_bit
110 {
111  X_0 = 0x01, X_1 = 0x02, X_2 = 0x04, X_3 = 0x08, X_4 = 0x10, X_5 = 0x20, X_6 = 0x40, X_7 = 0x80
112 };
113 
114 #elif defined( GF_MODE_BB ) || defined( GF_MODE_LB )
115 
116 #define gf_uint16_xor(i) ( \
117  (i & 0x80 ? xx(e1,00) : 0) ^ (i & 0x40 ? xx(70,80) : 0) ^ \
118  (i & 0x20 ? xx(38,40) : 0) ^ (i & 0x10 ? xx(1c,20) : 0) ^ \
119  (i & 0x08 ? xx(0e,10) : 0) ^ (i & 0x04 ? xx(07,08) : 0) ^ \
120  (i & 0x02 ? xx(03,84) : 0) ^ (i & 0x01 ? xx(01,c2) : 0) )
121 
122 enum x_bit
123 {
124  X_0 = 0x80, X_1 = 0x40, X_2 = 0x20, X_3 = 0x10, X_4 = 0x08, X_5 = 0x04, X_6 = 0x02, X_7 = 0x01
125 };
126 
127 #else
128 #error Galois Field representation has not been set
129 #endif
130 
131 #if defined( GF_MODE_BL ) || defined( GF_MODE_LB )
132 
133 #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
134 # define xx(p,q) 0x##q##p
135 #else
136 # define xx(p,q) 0x##p##q
137 #endif
138 
139 #elif defined( GF_MODE_BB ) || defined( GF_MODE_LL )
140 
141 #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
142 # define xx(p,q) 0x##p##q
143 #else
144 # define xx(p,q) 0x##q##p
145 #endif
146 
147 #else
148 #error Galois Field representation has not been set
149 #endif
150 
151 const uint_16t gf_tab[256] = DATA_256(gf_uint16_xor);
152 
153 /* BL low level Galois Field operations */
154 
155 #if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
156 
157 #if UNIT_BITS == 64
158 
159 #define f1_bl(n,r,x) r[n] = (x[n] << 1) & ~MASK(0x01) | ((x[n] >> 15) | (!n ? x[n+1] << 49 : 0)) & MASK(0x01)
160 #define f4_bl(n,r,x) r[n] = (x[n] << 4) & ~MASK(0x0f) | ((x[n] >> 12) | (!n ? x[n+1] << 52 : 0)) & MASK(0x0f)
161 #define f8_bl(n,r,x) r[n] = (x[n] >> 8) | (!n ? x[n+1] << 56 : 0)
162 
163 gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
164 { uint_16t _tt;
165  _tt = gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01];
166  rep2_u2(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
167  UNIT_PTR(r)[1] ^= ((gf_unit_t)_tt) << 48;
168 }
169 
170 gf_decl void gf_mulx4_bl(gf_t x)
171 { uint_16t _tt;
172  _tt = gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f];
173  rep2_u2(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
174  UNIT_PTR(x)[1] ^= ((gf_unit_t)_tt) << 48;
175 }
176 
177 gf_decl void gf_mulx8_bl(gf_t x)
178 { gf_unit_t _tt;
179  _tt = gf_tab[UNIT_PTR(x)[0] & 0xff];
180  rep2_u2(f8_bl, UNIT_PTR(x), UNIT_PTR(x));
181  UNIT_PTR(x)[1] ^= ((gf_unit_t)_tt) << 48;
182 }
183 
184 #elif UNIT_BITS == 32
185 
186 #define f1_bl(n,r,x) r[n] = (x[n] << 1) & ~MASK(0x01) | ((x[n] >> 15) | (n < 3 ? x[n+1] << 17 : 0)) & MASK(0x01)
187 #define f4_bl(n,r,x) r[n] = (x[n] << 4) & ~MASK(0x0f) | ((x[n] >> 12) | (n < 3 ? x[n+1] << 20 : 0)) & MASK(0x0f)
188 #define f8_bl(n,r,x) r[n] = (x[n] >> 8) | (n < 3 ? x[n+1] << 24 : 0)
189 
190 gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
191 { uint_16t _tt;
192  _tt = gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01];
193  rep2_u4(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
194  UNIT_PTR(r)[3] ^= ((gf_unit_t)_tt) << 16;
195 }
196 
197 gf_decl void gf_mulx4_bl(gf_t x)
198 { uint_16t _tt;
199  _tt = gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f];
200  rep2_u4(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
201  UNIT_PTR(x)[3] ^= ((gf_unit_t)_tt) << 16;
202 }
203 
204 gf_decl void gf_mulx8_bl(gf_t x)
205 { uint_16t _tt;
206  _tt = gf_tab[UNIT_PTR(x)[0] & 0xff];
207  rep2_u4(f8_bl, UNIT_PTR(x), UNIT_PTR(x));
208  UNIT_PTR(x)[3] ^= ((gf_unit_t)_tt) << 16;
209 }
210 
211 #else
212 
213 #define f1_bl(n,r,x) r[n] = (x[n] << 1) | (n < 15 ? x[n+1] >> 7 : 0)
214 #define f4_bl(n,r,x) r[n] = (x[n] << 4) | (n < 15 ? x[n+1] >> 4 : 0)
215 
216 gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
217 { uint_16t _tt;
218  _tt = gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01];
219  rep2_u16(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
220  UNIT_PTR(r)[15] ^= _tt >> 8;
221 }
222 
223 gf_decl void gf_mulx4_bl(gf_t x)
224 { uint_16t _tt;
225  _tt = gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f];
226  rep2_u16(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
227  UNIT_PTR(x)[14] ^= _tt & 0xff;
228  UNIT_PTR(x)[15] ^= _tt >> 8;
229 }
230 
231 gf_decl void gf_mulx8_bl(gf_t x)
232 { uint_16t _tt;
233  _tt = gf_tab[UNIT_PTR(x)[0]];
234  memmove(UNIT_PTR(x), UNIT_PTR(x) + 1, 15);
235  UNIT_PTR(x)[14] ^= _tt & 0xff;
236  UNIT_PTR(x)[15] = _tt >> 8;
237 }
238 
239 #endif
240 
241 #elif PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN
242 
243 #if UNIT_BITS == 64
244 
245 #define f1_bl(n,r,x) r[n] = (x[n] << 1) | (!n ? x[n+1] >> 63 : 0)
246 #define f4_bl(n,r,x) r[n] = (x[n] << 4) | (!n ? x[n+1] >> 60 : 0)
247 #define f8_bl(n,r,x) r[n] = (x[n] << 8) | (!n ? x[n+1] >> 56 : 0)
248 
249 gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
250 { uint_16t _tt;
251  _tt = gf_tab[(UNIT_PTR(x)[0] >> 63) & 0x01];
252  rep2_u2(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
253  UNIT_PTR(r)[1] ^= _tt;
254 }
255 
256 gf_decl void gf_mulx4_bl(gf_t x)
257 { gf_unit_t _tt;
258  _tt = gf_tab[(UNIT_PTR(x)[0] >> 60) & 0x0f];
259  rep2_u2(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
260  UNIT_PTR(x)[1] ^= _tt;
261 }
262 
263 gf_decl void gf_mulx8_bl(gf_t x)
264 { uint_16t _tt;
265  _tt = gf_tab[(UNIT_PTR(x)[0] >> 56) & 0xff];
266  rep2_u2(f8_bl, UNIT_PTR(x), UNIT_PTR(x));
267  UNIT_PTR(x)[1] ^= _tt;
268 }
269 
270 #elif UNIT_BITS == 32
271 
272 #define f1_bl(n,r,x) r[n] = (x[n] << 1) | (n < 3 ? x[n+1] >> 31 : 0)
273 #define f4_bl(n,r,x) r[n] = (x[n] << 4) | (n < 3 ? x[n+1] >> 28 : 0)
274 #define f8_bl(n,r,x) r[n] = (x[n] << 8) | (n < 3 ? x[n+1] >> 24 : 0)
275 
276 gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
277 { uint_16t _tt;
278  _tt = gf_tab[(UNIT_PTR(x)[0] >> 31) & 0x01];
279  rep2_u4(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
280  UNIT_PTR(r)[3] ^= _tt;
281 }
282 
283 gf_decl void gf_mulx4_bl(gf_t x)
284 { uint_16t _tt;
285  _tt = gf_tab[(UNIT_PTR(x)[0] >> 28) & 0x0f];
286  rep2_u4(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
287  UNIT_PTR(x)[3] ^= _tt;
288 }
289 
290 gf_decl void gf_mulx8_bl(gf_t x)
291 { uint_16t _tt;
292  _tt = gf_tab[(UNIT_PTR(x)[0] >> 24) & 0xff];
293  rep2_u4(f8_bl, UNIT_PTR(x), UNIT_PTR(x));
294  UNIT_PTR(x)[3] ^= _tt;
295 }
296 
297 #else
298 
299 #define f1_bl(n,r,x) r[n] = (x[n] << 1) | (n < 15 ? x[n+1] >> 7 : 0)
300 #define f4_bl(n,r,x) r[n] = (x[n] << 4) | (n < 15 ? x[n+1] >> 4 : 0)
301 
302 gf_decl void gf_mulx1_bl(gf_t r, const gf_t x)
303 { uint_16t _tt;
304  _tt = gf_tab[(UNIT_PTR(x)[0] >> 7) & 0x01];
305  rep2_u16(f1_bl, UNIT_PTR(r), UNIT_PTR(x));
306  UNIT_PTR(r)[15] ^= _tt & 0xff;
307 }
308 
309 gf_decl void gf_mulx4_bl(gf_t x)
310 { uint_16t _tt;
311  _tt = gf_tab[(UNIT_PTR(x)[0] >> 4) & 0x0f];
312  rep2_u16(f4_bl, UNIT_PTR(x), UNIT_PTR(x));
313  UNIT_PTR(x)[14] ^= _tt >> 8;
314  UNIT_PTR(x)[15] ^= _tt & 0xff;
315 }
316 
317 gf_decl void gf_mulx8_bl(gf_t x)
318 { uint_16t _tt;
319  _tt = gf_tab[UNIT_PTR(x)[0]];
320  memmove(UNIT_PTR(x), UNIT_PTR(x) + 1, 15);
321  UNIT_PTR(x)[14] ^= _tt >> 8;
322  UNIT_PTR(x)[15] = _tt & 0xff;
323 }
324 
325 #endif
326 
327 #else
328 # error Platform byte order has not been set.
329 #endif
330 
331 /* BB low level Galois Field operations */
332 
333 #if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
334 
335 #if UNIT_BITS == 64
336 
337 #define f1_bb(n,r,x) r[n] = (x[n] >> 1) | (!n ? x[n+1] << 63 : 0)
338 #define f4_bb(n,r,x) r[n] = (x[n] >> 4) | (!n ? x[n+1] << 60 : 0)
339 #define f8_bb(n,r,x) r[n] = (x[n] >> 8) | (!n ? x[n+1] << 56 : 0)
340 
341 gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
342 { uint_16t _tt;
343  _tt = gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80];
344  rep2_u2(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
345  UNIT_PTR(r)[1] ^= ((gf_unit_t)_tt) << 48;
346 }
347 
348 gf_decl void gf_mulx4_bb(gf_t x)
349 { gf_unit_t _tt;
350  _tt = gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0];
351  rep2_u2(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
352  UNIT_PTR(x)[1] ^= ((gf_unit_t)_tt) << 48;
353 }
354 
355 gf_decl void gf_mulx8_bb(gf_t x)
356 { gf_unit_t _tt;
357  _tt = gf_tab[UNIT_PTR(x)[0] & 0xff];
358  rep2_u2(f8_bb, UNIT_PTR(x), UNIT_PTR(x));
359  UNIT_PTR(x)[1] ^= ((gf_unit_t)_tt) << 48;
360 }
361 
362 #elif UNIT_BITS == 32
363 
364 #define f1_bb(n,r,x) r[n] = (x[n] >> 1) | (n < 3 ? x[n+1] << 31 : 0)
365 #define f4_bb(n,r,x) r[n] = (x[n] >> 4) | (n < 3 ? x[n+1] << 28 : 0)
366 #define f8_bb(n,r,x) r[n] = (x[n] >> 8) | (n < 3 ? x[n+1] << 24 : 0)
367 
368 gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
369 { gf_unit_t _tt;
370  _tt = gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80];
371  rep2_u4(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
372  UNIT_PTR(r)[3] ^= ((gf_unit_t)_tt) << 16;
373 }
374 
375 gf_decl void gf_mulx4_bb(gf_t x)
376 { gf_unit_t _tt;
377  _tt = gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0];
378  rep2_u4(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
379  UNIT_PTR(x)[3] ^= ((gf_unit_t)_tt) << 16;
380 }
381 
382 gf_decl void gf_mulx8_bb(gf_t x)
383 { gf_unit_t _tt;
384  _tt = gf_tab[UNIT_PTR(x)[0] & 0xff];
385  rep2_u4(f8_bb, UNIT_PTR(x), UNIT_PTR(x));
386  UNIT_PTR(x)[3] ^= ((gf_unit_t)_tt) << 16;
387 }
388 
389 #else
390 
391 #define f1_bb(n,r,x) r[n] = (x[n] >> 1) | (n < 15 ? x[n+1] << 7 : 0)
392 #define f4_bb(n,r,x) r[n] = (x[n] >> 4) | (n < 15 ? x[n+1] << 4 : 0)
393 
394 gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
395 { uint_16t _tt;
396  _tt = gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80];
397  rep2_u16(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
398  UNIT_PTR(r)[15] ^= _tt >> 8;
399 }
400 
401 gf_decl void gf_mulx4_bb(gf_t x)
402 { uint_16t _tt;
403  _tt = gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0];
404  rep2_u16(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
405  UNIT_PTR(x)[14] ^= _tt & 0xff;
406  UNIT_PTR(x)[15] ^= _tt >> 8;
407 }
408 
409 gf_decl void gf_mulx8_bb(gf_t x)
410 { uint_16t _tt;
411  _tt = gf_tab[UNIT_PTR(x)[0]];
412  memmove(UNIT_PTR(x), UNIT_PTR(x) + 1, 15);
413  UNIT_PTR(x)[14] ^= _tt & 0xff;
414  UNIT_PTR(x)[15] = _tt >> 8;
415 }
416 
417 #endif
418 
419 #elif PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN
420 
421 #if UNIT_BITS == 64
422 
423 #define f1_bb(n,r,x) r[n] = (x[n] >> 1) & ~MASK(0x80) | ((x[n] << 15) | (!n ? x[n+1] >> 49 : 0)) & MASK(0x80)
424 #define f4_bb(n,r,x) r[n] = (x[n] >> 4) & ~MASK(0xf0) | ((x[n] << 12) | (!n ? x[n+1] >> 52 : 0)) & MASK(0xf0)
425 #define f8_bb(n,r,x) r[n] = (x[n] >> 8) & ~MASK(0xff) | ((x[n] << 8) | (!n ? x[n+1] >> 56 : 0)) & MASK(0xff)
426 
427 gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
428 { uint_16t _tt;
429  _tt = gf_tab[(UNIT_PTR(x)[0] >> 49) & 0x80];
430  rep2_u2(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
431  UNIT_PTR(r)[1] ^= _tt;
432 }
433 
434 gf_decl void gf_mulx4_bb(gf_t x)
435 { uint_16t _tt;
436  _tt = gf_tab[(UNIT_PTR(x)[0] >> 52) & 0xf0];
437  rep2_u2(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
438  UNIT_PTR(x)[1] ^= _tt;
439 }
440 
441 gf_decl void gf_mulx8_bb(gf_t x)
442 { uint_16t _tt;
443  _tt = gf_tab[(UNIT_PTR(x)[0] >> 56) & 0xff];
444  rep2_u2(f8_bb, UNIT_PTR(x), UNIT_PTR(x));
445  UNIT_PTR(x)[1] ^= _tt;
446 }
447 
448 #elif UNIT_BITS == 32
449 
450 #define f1_bb(n,r,x) r[n] = (x[n] >> 1) & ~MASK(0x80) | ((x[n] << 15) | (n < 3 ? x[n+1] >> 17 : 0)) & MASK(0x80)
451 #define f4_bb(n,r,x) r[n] = (x[n] >> 4) & ~MASK(0xf0) | ((x[n] << 12) | (n < 3 ? x[n+1] >> 20 : 0)) & MASK(0xf0)
452 #define f8_bb(n,r,x) r[n] = (x[n] >> 8) & ~MASK(0xff) | ((x[n] << 8) | (n < 3 ? x[n+1] >> 24 : 0)) & MASK(0xff)
453 
454 gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
455 { uint_16t _tt;
456  _tt = gf_tab[(UNIT_PTR(x)[0] >> 17) & 0x80];
457  rep2_u4(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
458  UNIT_PTR(r)[3] ^= _tt;
459 }
460 
461 gf_decl void gf_mulx4_bb(gf_t x)
462 { uint_16t _tt;
463  _tt = gf_tab[(UNIT_PTR(x)[0] >> 20) & 0xf0];
464  rep2_u4(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
465  UNIT_PTR(x)[3] ^= _tt;
466 }
467 
468 gf_decl void gf_mulx8_bb(gf_t x)
469 { uint_16t _tt;
470  _tt = gf_tab[(UNIT_PTR(x)[0] >> 24) & 0xff];
471  rep2_u4(f8_bb, UNIT_PTR(x), UNIT_PTR(x));
472  UNIT_PTR(x)[3] ^= _tt;
473 }
474 
475 #else
476 
477 #define f1_bb(n,r,x) r[n] = (x[n] >> 1) | (n < 15 ? x[n+1] << 7 : 0)
478 #define f4_bb(n,r,x) r[n] = (x[n] >> 4) | (n < 15 ? x[n+1] << 4 : 0)
479 
480 gf_decl void gf_mulx1_bb(gf_t r, const gf_t x)
481 { uint_16t _tt;
482  _tt = gf_tab[(UNIT_PTR(x)[0] << 7) & 0x80];
483  rep2_u16(f1_bb, UNIT_PTR(r), UNIT_PTR(x));
484  UNIT_PTR(r)[15] ^= _tt;
485 }
486 
487 gf_decl void gf_mulx4_bb(gf_t x)
488 { uint_16t _tt;
489  _tt = gf_tab[(UNIT_PTR(x)[0] << 4) & 0xf0];
490  rep2_u16(f4_bb, UNIT_PTR(x), UNIT_PTR(x));
491  UNIT_PTR(x)[14] ^= _tt >> 8;
492  UNIT_PTR(x)[15] ^= _tt & 0xff;
493 }
494 
495 gf_decl void gf_mulx8_bb(gf_t x)
496 { uint_16t _tt;
497  _tt = gf_tab[UNIT_PTR(x)[0]];
498  memmove(UNIT_PTR(x), UNIT_PTR(x) + 1, 15);
499  UNIT_PTR(x)[14] ^= _tt >> 8;
500  UNIT_PTR(x)[15] = _tt & 0xff;
501 }
502 
503 #endif
504 
505 #else
506 # error Platform byte order has not been set.
507 #endif
508 
509 /* LL low level Galois Field operations */
510 
511 #if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
512 
513 #if UNIT_BITS == 64
514 
515 #define f1_ll(n,r,x) r[n] = (x[n] << 1) | (n ? x[n-1] >> 63 : 0)
516 #define f4_ll(n,r,x) r[n] = (x[n] << 4) | (n ? x[n-1] >> 60 : 0)
517 #define f8_ll(n,r,x) r[n] = (x[n] << 8) | (n ? x[n-1] >> 56 : 0)
518 
519 gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
520 { uint_16t _tt;
521  _tt = gf_tab[(UNIT_PTR(x)[1] >> 63) & 0x01];
522  rep2_d2(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
523  UNIT_PTR(r)[0] ^= _tt;
524 }
525 
526 gf_decl void gf_mulx4_ll(gf_t x)
527 { uint_16t _tt;
528  _tt = gf_tab[(UNIT_PTR(x)[1] >> 60) & 0x0f];
529  rep2_d2(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
530  UNIT_PTR(x)[0] ^= _tt;
531 }
532 
533 gf_decl void gf_mulx8_ll(gf_t x)
534 { uint_16t _tt;
535  _tt = gf_tab[UNIT_PTR(x)[1] >> 56];
536  rep2_d2(f8_ll, UNIT_PTR(x), UNIT_PTR(x));
537  UNIT_PTR(x)[0] ^= _tt;
538 }
539 
540 #elif UNIT_BITS == 32
541 
542 #define f1_ll(n,r,x) r[n] = (x[n] << 1) | (n ? x[n-1] >> 31 : 0)
543 #define f4_ll(n,r,x) r[n] = (x[n] << 4) | (n ? x[n-1] >> 28 : 0)
544 #define f8_ll(n,r,x) r[n] = (x[n] << 8) | (n ? x[n-1] >> 24 : 0)
545 
546 gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
547 { uint_16t _tt;
548  _tt = gf_tab[(UNIT_PTR(x)[3] >> 31) & 0x01];
549  rep2_d4(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
550  UNIT_PTR(r)[0] ^= _tt;
551 }
552 
553 gf_decl void gf_mulx4_ll(gf_t x)
554 { uint_16t _tt;
555  _tt = gf_tab[(UNIT_PTR(x)[3] >> 28) & 0x0f];
556  rep2_d4(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
557  UNIT_PTR(x)[0] ^= _tt;
558 }
559 
560 gf_decl void gf_mulx8_ll(gf_t x)
561 { uint_16t _tt;
562  _tt = gf_tab[UNIT_PTR(x)[3] >> 24];
563  rep2_d4(f8_ll, UNIT_PTR(x), UNIT_PTR(x));
564  UNIT_PTR(x)[0] ^= _tt;
565 }
566 
567 #else
568 
569 #define f1_ll(n,r,x) r[n] = (x[n] << 1) | (n ? x[n-1] >> 7 : 0)
570 #define f4_ll(n,r,x) r[n] = (x[n] << 4) | (n ? x[n-1] >> 4 : 0)
571 
572 gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
573 { uint_16t _tt;
574  _tt = gf_tab[(UNIT_PTR(x)[15] >> 7) & 0x01];
575  rep2_d16(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
576  UNIT_PTR(r)[0] ^= _tt & 0xff;
577 }
578 
579 gf_decl void gf_mulx4_ll(gf_t x)
580 { uint_16t _tt;
581  _tt = gf_tab[(UNIT_PTR(x)[15] >> 4) & 0x0f];
582  rep2_d16(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
583  UNIT_PTR(x)[1] ^= _tt >> 8;
584  UNIT_PTR(x)[0] ^= _tt & 0xff;
585 }
586 
587 gf_decl void gf_mulx8_ll(gf_t x)
588 { uint_16t _tt;
589  _tt = gf_tab[UNIT_PTR(x)[15]];
590  memmove(UNIT_PTR(x) + 1, UNIT_PTR(x), 15);
591  UNIT_PTR(x)[1] ^= _tt >> 8;
592  UNIT_PTR(x)[0] = _tt & 0xff;
593 }
594 
595 #endif
596 
597 #elif PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN
598 
599 #if UNIT_BITS == 64
600 
601 #define f1_ll(n,r,x) r[n] = (x[n] << 1) & ~MASK(0x01) | ((x[n] >> 15) | (n ? x[n-1] << 49 : 0)) & MASK(0x01)
602 #define f4_ll(n,r,x) r[n] = (x[n] << 4) & ~MASK(0x0f) | ((x[n] >> 12) | (n ? x[n-1] << 52 : 0)) & MASK(0x0f)
603 #define f8_ll(n,r,x) r[n] = (x[n] << 8) & ~MASK(0xff) | ((x[n] >> 8) | (n ? x[n-1] << 56 : 0)) & MASK(0xff)
604 
605 gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
606 { uint_16t _tt;
607  _tt = gf_tab[(UNIT_PTR(x)[1] >> 7) & 0x01];
608  rep2_d2(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
609  UNIT_PTR(r)[0] ^= ((gf_unit_t)_tt) << 48;
610 }
611 
612 gf_decl void gf_mulx4_ll(gf_t x)
613 { uint_16t _tt;
614  _tt = gf_tab[(UNIT_PTR(x)[1] >> 4) & 0x0f];
615  rep2_d2(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
616  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 48;
617 }
618 
619 gf_decl void gf_mulx8_ll(gf_t x)
620 { uint_16t _tt;
621  _tt = gf_tab[UNIT_PTR(x)[1] & 0xff];
622  rep2_d2(f8_ll, UNIT_PTR(x), UNIT_PTR(x));
623  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 48;
624 }
625 
626 #elif UNIT_BITS == 32
627 
628 #define f1_ll(n,r,x) r[n] = (x[n] << 1) & ~MASK(0x01) | ((x[n] >> 15) | (n ? x[n-1] << 17 : 0)) & MASK(0x01)
629 #define f4_ll(n,r,x) r[n] = (x[n] << 4) & ~MASK(0x0f) | ((x[n] >> 12) | (n ? x[n-1] << 20 : 0)) & MASK(0x0f)
630 #define f8_ll(n,r,x) r[n] = (x[n] << 8) & ~MASK(0xff) | ((x[n] >> 8) | (n ? x[n-1] << 24 : 0)) & MASK(0xff)
631 
632 gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
633 { uint_16t _tt;
634  _tt = gf_tab[(UNIT_PTR(x)[3] >> 7) & 0x01];
635  rep2_d4(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
636  UNIT_PTR(r)[0] ^= ((gf_unit_t)_tt) << 16;
637 }
638 
639 gf_decl void gf_mulx4_ll(gf_t x)
640 { uint_16t _tt;
641  _tt = gf_tab[(UNIT_PTR(x)[3] >> 4) & 0x0f];
642  rep2_d4(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
643  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 16;
644 }
645 
646 gf_decl void gf_mulx8_ll(gf_t x)
647 { uint_16t _tt;
648  _tt = gf_tab[UNIT_PTR(x)[3] & 0xff];
649  rep2_d4(f8_ll, UNIT_PTR(x), UNIT_PTR(x));
650  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 16;
651 }
652 
653 #else
654 
655 #define f1_ll(n,r,x) r[n] = (x[n] << 1) | (n ? x[n-1] >> 7 : 0)
656 #define f4_ll(n,r,x) r[n] = (x[n] << 4) | (n ? x[n-1] >> 4 : 0)
657 
658 gf_decl void gf_mulx1_ll(gf_t r, const gf_t x)
659 { uint_16t _tt;
660  _tt = gf_tab[(UNIT_PTR(x)[15] >> 7) & 0x01];
661  rep2_d16(f1_ll, UNIT_PTR(r), UNIT_PTR(x));
662  UNIT_PTR(r)[0] ^= _tt >> 8;
663 }
664 
665 gf_decl void gf_mulx4_ll(gf_t x)
666 { uint_16t _tt;
667  _tt = gf_tab[(UNIT_PTR(x)[15] >> 4) & 0x0f];
668  rep2_d16(f4_ll, UNIT_PTR(x), UNIT_PTR(x));
669  UNIT_PTR(x)[1] ^= _tt & 0xff;
670  UNIT_PTR(x)[0] ^= _tt >> 8;
671 }
672 
673 gf_decl void gf_mulx8_ll(gf_t x)
674 { uint_16t _tt;
675  _tt = gf_tab[UNIT_PTR(x)[15]];
676  memmove(UNIT_PTR(x) + 1, UNIT_PTR(x), 15);
677  UNIT_PTR(x)[1] ^= _tt & 0xff;
678  UNIT_PTR(x)[0] = _tt >> 8;
679 }
680 
681 #endif
682 
683 #else
684 # error Platform byte order has not been set.
685 #endif
686 
687 /* LB low level Galois Field operations */
688 
689 #if PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN
690 
691 #if UNIT_BITS == 64
692 
693 #define f1_lb(n,r,x) r[n] = (x[n] >> 1) & ~MASK(0x80) | ((x[n] << 15) | (n ? x[n-1] >> 49 : 0)) & MASK(0x80)
694 #define f4_lb(n,r,x) r[n] = (x[n] >> 4) & ~MASK(0xf0) | ((x[n] << 12) | (n ? x[n-1] >> 52 : 0)) & MASK(0xf0)
695 #define f8_lb(n,r,x) r[n] = (x[n] << 8) | (n ? x[n-1] >> 56 : 0)
696 
697 gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
698 { uint_16t _tt;
699  _tt = gf_tab[(UNIT_PTR(x)[1] >> 49) & MASK(0x80)];
700  rep2_d2(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
701  UNIT_PTR(r)[0] ^= _tt;
702 }
703 
704 gf_decl void gf_mulx4_lb(gf_t x)
705 { uint_16t _tt;
706  _tt = gf_tab[(UNIT_PTR(x)[1] >> 52) & MASK(0xf0)];
707  rep2_d2(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
708  UNIT_PTR(x)[0] ^= _tt;
709 }
710 
711 gf_decl void gf_mulx8_lb(gf_t x)
712 { uint_16t _tt;
713  _tt = gf_tab[UNIT_PTR(x)[1] >> 56];
714  rep2_d2(f8_lb, UNIT_PTR(x), UNIT_PTR(x));
715  UNIT_PTR(x)[0] ^= _tt;
716 }
717 
718 #elif UNIT_BITS == 32
719 
720 #define f1_lb(n,r,x) r[n] = (x[n] >> 1) & ~MASK(0x80) | ((x[n] << 15) | (n ? x[n-1] >> 17 : 0)) & MASK(0x80)
721 #define f4_lb(n,r,x) r[n] = (x[n] >> 4) & ~MASK(0xf0) | ((x[n] << 12) | (n ? x[n-1] >> 20 : 0)) & MASK(0xf0)
722 #define f8_lb(n,r,x) r[n] = (x[n] << 8) | (n ? x[n-1] >> 24 : 0)
723 
724 gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
725 { uint_16t _tt;
726  _tt = gf_tab[(UNIT_PTR(x)[3] >> 17) & MASK(0x80)];
727  rep2_d4(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
728  UNIT_PTR(r)[0] ^= _tt;
729 }
730 
731 gf_decl void gf_mulx4_lb(gf_t x)
732 { uint_16t _tt;
733  _tt = gf_tab[(UNIT_PTR(x)[3] >> 20) & MASK(0xf0)];
734  rep2_d4(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
735  UNIT_PTR(x)[0] ^= _tt;
736 }
737 
738 gf_decl void gf_mulx8_lb(gf_t x)
739 { uint_16t _tt;
740  _tt = gf_tab[UNIT_PTR(x)[3] >> 24];
741  rep2_d4(f8_lb, UNIT_PTR(x), UNIT_PTR(x));
742  UNIT_PTR(x)[0] ^= _tt;
743 }
744 
745 #else
746 
747 #define f1_lb(n,r,x) r[n] = (x[n] >> 1) | (n ? x[n-1] << 7 : 0)
748 #define f4_lb(n,r,x) r[n] = (x[n] >> 4) | (n ? x[n-1] << 4 : 0)
749 
750 gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
751 { uint_16t _tt;
752  _tt = gf_tab[(UNIT_PTR(x)[15] << 7) & 0x80];
753  rep2_d16(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
754  UNIT_PTR(r)[0] ^= _tt;
755 }
756 
757 gf_decl void gf_mulx4_lb(gf_t x)
758 { uint_16t _tt;
759  _tt = gf_tab[(UNIT_PTR(x)[15] << 4) & 0xf0];
760  rep2_d16(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
761  UNIT_PTR(x)[1] ^= _tt >> 8;
762  UNIT_PTR(x)[0] ^= _tt & 0xff;
763 }
764 
765 gf_decl void gf_mulx8_lb(gf_t x)
766 { uint_16t _tt;
767  _tt = gf_tab[UNIT_PTR(x)[15]];
768  memmove(UNIT_PTR(x) + 1, UNIT_PTR(x), 15);
769  UNIT_PTR(x)[1] ^= _tt >> 8;
770  UNIT_PTR(x)[0] = _tt & 0xff;
771 }
772 
773 #endif
774 
775 #elif PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN
776 
777 #if UNIT_BITS == 64
778 
779 #define f1_lb(n,r,x) r[n] = (x[n] >> 1) | (n ? x[n-1] << 63 : 0)
780 #define f4_lb(n,r,x) r[n] = (x[n] >> 4) | (n ? x[n-1] << 60 : 0)
781 #define f8_lb(n,r,x) x[n] = (x[n] >> 8) | (n ? x[n-1] << 56 : 0)
782 
783 gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
784 { uint_16t _tt;
785  _tt = gf_tab[(UNIT_PTR(x)[1] << 7) & 0xff];
786  rep2_d2(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
787  UNIT_PTR(r)[0] ^= ((gf_unit_t)_tt)<< 48;
788 }
789 
790 gf_decl void gf_mulx4_lb(gf_t x)
791 { uint_16t _tt;
792  _tt = gf_tab[(UNIT_PTR(x)[1] << 4) & 0xff];
793  rep2_d2(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
794  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 48;
795 }
796 
797 gf_decl void gf_mulx8_lb(gf_t x)
798 { uint_16t _tt;
799  _tt = gf_tab[UNIT_PTR(x)[1] & 0xff];
800  rep2_d2(f8_lb, UNIT_PTR(x), UNIT_PTR(x));
801  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 48;
802 }
803 
804 #elif UNIT_BITS == 32
805 
806 #define f1_lb(n,r,x) r[n] = (x[n] >> 1) | (n ? x[n-1] << 31 : 0)
807 #define f4_lb(n,r,x) r[n] = (x[n] >> 4) | (n ? x[n-1] << 28 : 0)
808 #define f8_lb(n,r,x) r[n] = (x[n] >> 8) | (n ? x[n-1] << 24 : 0)
809 
810 gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
811 { uint_16t _tt;
812  _tt = gf_tab[(UNIT_PTR(x)[3] << 7) & 0xff];
813  rep2_d4(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
814  UNIT_PTR(r)[0] ^= ((gf_unit_t)_tt) << 16;
815 }
816 
817 gf_decl void gf_mulx4_lb(gf_t x)
818 { uint_16t _tt;
819  _tt = gf_tab[(UNIT_PTR(x)[3] << 4) & 0xff];
820  rep2_d4(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
821  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 16;
822 }
823 
824 gf_decl void gf_mulx8_lb(gf_t x)
825 { uint_16t _tt;
826  _tt = gf_tab[UNIT_PTR(x)[3] & 0xff];
827  rep2_d4(f8_lb, UNIT_PTR(x), UNIT_PTR(x));
828  UNIT_PTR(x)[0] ^= ((gf_unit_t)_tt) << 16;
829 }
830 
831 #else
832 
833 #define f1_lb(n,r,x) r[n] = (x[n] >> 1) | (n ? x[n-1] << 7 : 0)
834 #define f4_lb(n,r,x) r[n] = (x[n] >> 4) | (n ? x[n-1] << 4 : 0)
835 
836 gf_decl void gf_mulx1_lb(gf_t r, const gf_t x)
837 { uint_16t _tt;
838  _tt = gf_tab[(UNIT_PTR(x)[15] << 7) & 0x80];
839  rep2_d16(f1_lb, UNIT_PTR(r), UNIT_PTR(x));
840  UNIT_PTR(r)[0] ^= _tt >> 8;
841 }
842 
843 gf_decl void gf_mulx4_lb(gf_t x)
844 { uint_16t _tt;
845  _tt = gf_tab[(UNIT_PTR(x)[15] << 4) & 0xff];
846  rep2_d16(f4_lb, UNIT_PTR(x), UNIT_PTR(x));
847  UNIT_PTR(x)[1] ^= _tt & 0xff;
848  UNIT_PTR(x)[0] ^= _tt >> 8;
849 }
850 
851 gf_decl void gf_mulx8_lb(gf_t x)
852 { uint_16t _tt;
853  _tt = gf_tab[UNIT_PTR(x)[15]];
854  memmove(UNIT_PTR(x) + 1, UNIT_PTR(x), 15);
855  UNIT_PTR(x)[1] ^= _tt & 0xff;
856  UNIT_PTR(x)[0] = _tt >> 8;
857 }
858 
859 #endif
860 
861 #else
862 # error Platform byte order has not been set.
863 #endif
864 
865 #endif