extensions/universalchardet/src/base/nsPkgInt.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 #ifndef nsPkgInt_h__
     7 #define nsPkgInt_h__
     8 #include "nscore.h"
    10 typedef enum {
    11   eIdxSft4bits  = 3,
    12   eIdxSft8bits  = 2,
    13   eIdxSft16bits = 1
    14 } nsIdxSft; 
    16 typedef enum {
    17   eSftMsk4bits  = 7,
    18   eSftMsk8bits  = 3,
    19   eSftMsk16bits = 1
    20 } nsSftMsk; 
    22 typedef enum {
    23   eBitSft4bits  = 2,
    24   eBitSft8bits  = 3,
    25   eBitSft16bits = 4
    26 } nsBitSft; 
    28 typedef enum {
    29   eUnitMsk4bits  = 0x0000000FL,
    30   eUnitMsk8bits  = 0x000000FFL,
    31   eUnitMsk16bits = 0x0000FFFFL
    32 } nsUnitMsk; 
    34 typedef struct nsPkgInt {
    35   nsIdxSft  idxsft;
    36   nsSftMsk  sftmsk;
    37   nsBitSft  bitsft;
    38   nsUnitMsk unitmsk;
    39   const uint32_t* const data;
    40 } nsPkgInt;
    43 #define PCK16BITS(a,b)            ((uint32_t)(((b) << 16) | (a)))
    45 #define PCK8BITS(a,b,c,d)         PCK16BITS( ((uint32_t)(((b) << 8) | (a))),  \
    46                                              ((uint32_t)(((d) << 8) | (c))))
    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))) )
    53 #define GETFROMPCK(i, c) \
    54  (((((c).data)[(i)>>(c).idxsft])>>(((i)&(c).sftmsk)<<(c).bitsft))&(c).unitmsk)
    56 #endif /* nsPkgInt_h__ */

mercurial