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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/*
* Copyright (C) 1998 NCSA
* All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
* Wednesday, June 10, 1998
*
* Purpose: Operations on bit vectors. A bit vector is an array of bytes
* with the least-significant bits in the first byte. That is,
* the bytes are in little-endian order.
*/
#define H5T_PACKAGE
#include <H5private.h>
#include <H5Tpkg.h>
/*-------------------------------------------------------------------------
* Function: H5T_bit_copy
*
* Purpose: Copies bits from one vector to another.
*
* Return: void
*
* Programmer: Robb Matzke
* Wednesday, June 10, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
H5T_bit_copy (uint8 *dst, size_t dst_offset, const uint8 *src,
size_t src_offset, size_t size)
{
uintn shift;
uintn mask_lo, mask_hi;
intn s_idx, d_idx;
/*
* Calculate shifts and masks. See diagrams below. MASK_LO in this
* example is 0x1f (the low five bits) and MASK_HI is 0xe0 (the high three
* bits). SHIFT is three since the source must be shifted right three bits
* to line up with the destination.
*/
shift = (dst_offset%8)-(src_offset%8);
mask_lo = (1<<(8-shift))-1;
mask_hi = ((1<<shift)-1) << (8-shift);
s_idx = src_offset / 8;
d_idx = dst_offset / 8;
/*
* Get things rolling. This means copying bits until we're aligned on a
* source byte. This the following example, four bits are copied to the
* destination.
*
* src[s_idx]
* +---------------+---------------+
* |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
* +---------------+---------------+
* ... : : : : : | | | | |
* ... v v v v v V V V V V
* ...+---------------+---------------+
* ...|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
* ...+---------------+---------------+
* dst[d_idx+1] dst[d_idx]
*/
if (src_offset%8 && size>0) {
}
/*
* The middle bits. We are aligned on a source byte which needs to be
* copied to two (or one in the degenerate case) destination bytes.
*
* src[s_idx]
* +---------------+
* |7 6 5 4 3 2 1 0|
* +---------------+
* | | | | | | | |
* V V V V V V V V
* +---------------+---------------+
* |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
* +---------------+---------------+
* dst[d_idx+1] dst[d_idx]
*
*/
for (/*void*/; size>8; size-=8, d_idx++, s_idx++) {
if (shift) {
dst[d_idx+0] &= mask_lo;
dst[d_idx+0] |= (src[s_idx] << shift) & mask_hi;
dst[d_idx+1] &= mask_hi;
dst[d_idx+1] |= (src[s_idx] >> (8-shift)) & mask_lo;
} else {
dst[d_idx] = src[s_idx];
}
}
/* Finish up */
}
/*-------------------------------------------------------------------------
* Function: H5T_bit_set
*
* Purpose: Sets or clears bits in a contiguous region of a vector
* beginning at bit OFFSET and continuing for SIZE bits.
*
* Return: void
*
* Programmer: Robb Matzke
* Wednesday, June 10, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
H5T_bit_set (uint8 *buf, size_t offset, size_t size, hbool_t value)
{
}
/*-------------------------------------------------------------------------
* Function: H5T_bit_find
*
* Purpose: Finds the first bit with the specified VALUE within a region
* of a bit vector. The region begins at OFFSET and continues
* for SIZE bits, but the region can be searched from the least
* significat end toward the most significant end with
*
* Return: Success: The position of the bit found, relative to
* the offset.
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, June 10, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
ssize_t
H5T_bit_find (uint8 *buf, size_t offset, size_t size, H5T_sdir_t direction,
hbool_t value)
{
return -1;
}
|