summaryrefslogtreecommitdiffstats
path: root/src/usr/pore/poreve/model/bebits.H
blob: 5d87efb83ef932ce4145ff97bea85d479663526f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/usr/pore/poreve/model/bebits.H $
 *
 *  IBM CONFIDENTIAL
 *
 *  COPYRIGHT International Business Machines Corp. 2012
 *
 *  p1
 *
 *  Object Code Only (OCO) source materials
 *  Licensed Internal Code Source Materials
 *  IBM HostBoot Licensed Internal Code
 *
 *  The source code for this program is not published or other-
 *  wise divested of its trade secrets, irrespective of what has
 *  been deposited with the U.S. Copyright Office.
 *
 *  Origin: 30
 *
 *  IBM_PROLOG_END_TAG
 */
#ifndef __VSBE_BEBITS_H
#define __VSBE_BEBITS_H

// $Id: bebits.H,v 1.3 2011/06/30 03:34:58 bcbrock Exp $

/// \file bebits.H
/// \brief Bit manipulation for Big-Endian data

/// A bit mask for a range of bits in a big-endian uint64_t
#define BE64_MASK(begin, end) \
    ((0xffffffffffffffffull >> (64 - ((end) - (begin) + 1))) << (63 - (end)))

/// A single bit mask for a big-endian uint64_t
#define BE64_BIT(n) (BE64_MASK((n), (n)))

/// Extract an unsigned field from a uint64_t
#define BE64_GET_FIELD(x, begin, end) \
    (((x) & BE64_MASK((begin), (end))) >> (63 - (end)))

/// Update an unsigned field in a uint64_t from a right-justified uint64_t value
#define BE64_SET_FIELD(x, begin, end, val)                      \
    ((((val) << (63 - (end))) &  BE64_MASK((begin), (end))) |   \
     ((x) & ~BE64_MASK((begin), (end))))

#endif // __VSBE_BEBITS_H
OpenPOWER on IntegriCloud