extensions/universalchardet/src/base/nsPkgInt.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:f1fa74fbff4d
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsPkgInt_h__
7 #define nsPkgInt_h__
8 #include "nscore.h"
9
10 typedef enum {
11 eIdxSft4bits = 3,
12 eIdxSft8bits = 2,
13 eIdxSft16bits = 1
14 } nsIdxSft;
15
16 typedef enum {
17 eSftMsk4bits = 7,
18 eSftMsk8bits = 3,
19 eSftMsk16bits = 1
20 } nsSftMsk;
21
22 typedef enum {
23 eBitSft4bits = 2,
24 eBitSft8bits = 3,
25 eBitSft16bits = 4
26 } nsBitSft;
27
28 typedef enum {
29 eUnitMsk4bits = 0x0000000FL,
30 eUnitMsk8bits = 0x000000FFL,
31 eUnitMsk16bits = 0x0000FFFFL
32 } nsUnitMsk;
33
34 typedef struct nsPkgInt {
35 nsIdxSft idxsft;
36 nsSftMsk sftmsk;
37 nsBitSft bitsft;
38 nsUnitMsk unitmsk;
39 const uint32_t* const data;
40 } nsPkgInt;
41
42
43 #define PCK16BITS(a,b) ((uint32_t)(((b) << 16) | (a)))
44
45 #define PCK8BITS(a,b,c,d) PCK16BITS( ((uint32_t)(((b) << 8) | (a))), \
46 ((uint32_t)(((d) << 8) | (c))))
47
48 #define PCK4BITS(a,b,c,d,e,f,g,h) PCK8BITS( ((uint32_t)(((b) << 4) | (a))), \
49 ((uint32_t)(((d) << 4) | (c))), \
50 ((uint32_t)(((f) << 4) | (e))), \
51 ((uint32_t)(((h) << 4) | (g))) )
52
53 #define GETFROMPCK(i, c) \
54 (((((c).data)[(i)>>(c).idxsft])>>(((i)&(c).sftmsk)<<(c).bitsft))&(c).unitmsk)
55
56 #endif /* nsPkgInt_h__ */
57

mercurial