* updatesetbit_inword() -- update the given bit to 1 in a given * word. * * The given word will generate at most three new words, depending on * the position of the given bit to be updated. Make sure that the * array 'words' has the size of 3 when you call this function. All new * words will be put in this array, and the final number of new words is * stored in '*numWordsP'. The bit lo
| 302 | * We assume that word is a fill zero word. |
| 303 | */ |
| 304 | static void |
| 305 | updatesetbit_inword(BM_HRL_WORD word, uint64 updateBitLoc, |
| 306 | uint64 firstTid, BMTIDBuffer *buf) |
| 307 | { |
| 308 | uint64 numBits, usedNumBits; |
| 309 | uint16 insertingPos; |
| 310 | |
| 311 | Assert(updateBitLoc < BM_HRL_WORD_SIZE*FILL_LENGTH(word)); |
| 312 | |
| 313 | numBits = FILL_LENGTH(word) * BM_HRL_WORD_SIZE; |
| 314 | usedNumBits = 0; |
| 315 | if (updateBitLoc >= BM_HRL_WORD_SIZE) |
| 316 | { |
| 317 | firstTid += (updateBitLoc/BM_HRL_WORD_SIZE) * BM_HRL_WORD_SIZE; |
| 318 | buf->cwords[buf->curword] = |
| 319 | BM_MAKE_FILL_WORD(0, updateBitLoc/BM_HRL_WORD_SIZE); |
| 320 | buf->last_tids[buf->curword] = firstTid - 1; |
| 321 | buf->curword++; |
| 322 | buf_extend(buf); |
| 323 | buf->hwords[(buf->curword-1)/BM_HRL_WORD_SIZE] |= |
| 324 | (((BM_HRL_WORD)1)<<(BM_HRL_WORD_SIZE - buf->curword)); |
| 325 | usedNumBits += (updateBitLoc/BM_HRL_WORD_SIZE) * BM_HRL_WORD_SIZE; |
| 326 | } |
| 327 | |
| 328 | /* construct the literal word */ |
| 329 | insertingPos = updateBitLoc - usedNumBits; |
| 330 | firstTid += BM_HRL_WORD_SIZE; |
| 331 | buf->cwords[buf->curword] = |
| 332 | ((BM_HRL_WORD)0) | (((BM_HRL_WORD)1) << insertingPos); |
| 333 | buf->last_tids[buf->curword] = firstTid - 1; |
| 334 | buf->curword++; |
| 335 | buf_extend(buf); |
| 336 | usedNumBits += BM_HRL_WORD_SIZE; |
| 337 | |
| 338 | if (numBits > usedNumBits) |
| 339 | { |
| 340 | BM_HRL_WORD fill_length; |
| 341 | Assert((numBits - usedNumBits) % BM_HRL_WORD_SIZE == 0); |
| 342 | fill_length = (numBits - usedNumBits) / BM_HRL_WORD_SIZE; |
| 343 | |
| 344 | firstTid += fill_length * BM_HRL_WORD_SIZE; |
| 345 | buf->cwords[buf->curword] = BM_MAKE_FILL_WORD(0, fill_length); |
| 346 | buf->last_tids[buf->curword] = firstTid -1; |
| 347 | buf->curword++; |
| 348 | buf_extend(buf); |
| 349 | buf->hwords[(buf->curword-1)/BM_HRL_WORD_SIZE] |= |
| 350 | (((BM_HRL_WORD)1) << (BM_HRL_WORD_SIZE - buf->curword)); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /* |
| 355 | * rshift_header_bits() -- 'in-place' right-shift bits in given words |
no test coverage detected