michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsPkgInt_h__ michael@0: #define nsPkgInt_h__ michael@0: #include "nscore.h" michael@0: michael@0: typedef enum { michael@0: eIdxSft4bits = 3, michael@0: eIdxSft8bits = 2, michael@0: eIdxSft16bits = 1 michael@0: } nsIdxSft; michael@0: michael@0: typedef enum { michael@0: eSftMsk4bits = 7, michael@0: eSftMsk8bits = 3, michael@0: eSftMsk16bits = 1 michael@0: } nsSftMsk; michael@0: michael@0: typedef enum { michael@0: eBitSft4bits = 2, michael@0: eBitSft8bits = 3, michael@0: eBitSft16bits = 4 michael@0: } nsBitSft; michael@0: michael@0: typedef enum { michael@0: eUnitMsk4bits = 0x0000000FL, michael@0: eUnitMsk8bits = 0x000000FFL, michael@0: eUnitMsk16bits = 0x0000FFFFL michael@0: } nsUnitMsk; michael@0: michael@0: typedef struct nsPkgInt { michael@0: nsIdxSft idxsft; michael@0: nsSftMsk sftmsk; michael@0: nsBitSft bitsft; michael@0: nsUnitMsk unitmsk; michael@0: const uint32_t* const data; michael@0: } nsPkgInt; michael@0: michael@0: michael@0: #define PCK16BITS(a,b) ((uint32_t)(((b) << 16) | (a))) michael@0: michael@0: #define PCK8BITS(a,b,c,d) PCK16BITS( ((uint32_t)(((b) << 8) | (a))), \ michael@0: ((uint32_t)(((d) << 8) | (c)))) michael@0: michael@0: #define PCK4BITS(a,b,c,d,e,f,g,h) PCK8BITS( ((uint32_t)(((b) << 4) | (a))), \ michael@0: ((uint32_t)(((d) << 4) | (c))), \ michael@0: ((uint32_t)(((f) << 4) | (e))), \ michael@0: ((uint32_t)(((h) << 4) | (g))) ) michael@0: michael@0: #define GETFROMPCK(i, c) \ michael@0: (((((c).data)[(i)>>(c).idxsft])>>(((i)&(c).sftmsk)<<(c).bitsft))&(c).unitmsk) michael@0: michael@0: #endif /* nsPkgInt_h__ */ michael@0: