1 |
/* Array bitsets. |
/* Array bitsets. |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2003 Free Software Foundation, Inc. |
3 |
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). |
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
123 |
|
|
124 |
|
|
125 |
/* Test bit BITNO in bitset SRC. */ |
/* Test bit BITNO in bitset SRC. */ |
126 |
static int |
static bool |
127 |
abitset_test (bitset src ATTRIBUTE_UNUSED, |
abitset_test (bitset src ATTRIBUTE_UNUSED, |
128 |
bitset_bindex bitno ATTRIBUTE_UNUSED) |
bitset_bindex bitno ATTRIBUTE_UNUSED) |
129 |
{ |
{ |
130 |
/* This should never occur for abitsets since we should always |
/* This should never occur for abitsets since we should always |
131 |
hit the cache. */ |
hit the cache. */ |
132 |
abort (); |
abort (); |
133 |
return 0; |
return false; |
134 |
} |
} |
135 |
|
|
136 |
|
|
336 |
} |
} |
337 |
|
|
338 |
|
|
339 |
static int |
static bool |
340 |
abitset_empty_p (bitset dst) |
abitset_empty_p (bitset dst) |
341 |
{ |
{ |
342 |
bitset_windex i; |
bitset_windex i; |
344 |
|
|
345 |
for (i = 0; i < dst->b.csize; i++) |
for (i = 0; i < dst->b.csize; i++) |
346 |
if (dstp[i]) |
if (dstp[i]) |
347 |
return 0; |
return false; |
348 |
|
|
349 |
return 1; |
return true; |
350 |
} |
} |
351 |
|
|
352 |
|
|
377 |
} |
} |
378 |
|
|
379 |
|
|
380 |
static int |
static bool |
381 |
abitset_equal_p (bitset dst, bitset src) |
abitset_equal_p (bitset dst, bitset src) |
382 |
{ |
{ |
383 |
bitset_windex i; |
bitset_windex i; |
387 |
|
|
388 |
for (i = 0; i < size; i++) |
for (i = 0; i < size; i++) |
389 |
if (*srcp++ != *dstp++) |
if (*srcp++ != *dstp++) |
390 |
return 0; |
return false; |
391 |
return 1; |
return true; |
392 |
} |
} |
393 |
|
|
394 |
|
|
395 |
static int |
static bool |
396 |
abitset_subset_p (bitset dst, bitset src) |
abitset_subset_p (bitset dst, bitset src) |
397 |
{ |
{ |
398 |
bitset_windex i; |
bitset_windex i; |
402 |
|
|
403 |
for (i = 0; i < size; i++, dstp++, srcp++) |
for (i = 0; i < size; i++, dstp++, srcp++) |
404 |
if (*dstp != (*srcp | *dstp)) |
if (*dstp != (*srcp | *dstp)) |
405 |
return 0; |
return false; |
406 |
return 1; |
return true; |
407 |
} |
} |
408 |
|
|
409 |
|
|
410 |
static int |
static bool |
411 |
abitset_disjoint_p (bitset dst, bitset src) |
abitset_disjoint_p (bitset dst, bitset src) |
412 |
{ |
{ |
413 |
bitset_windex i; |
bitset_windex i; |
417 |
|
|
418 |
for (i = 0; i < size; i++) |
for (i = 0; i < size; i++) |
419 |
if (*srcp++ & *dstp++) |
if (*srcp++ & *dstp++) |
420 |
return 0; |
return false; |
421 |
|
|
422 |
return 1; |
return true; |
423 |
} |
} |
424 |
|
|
425 |
|
|
437 |
} |
} |
438 |
|
|
439 |
|
|
440 |
static int |
static bool |
441 |
abitset_and_cmp (bitset dst, bitset src1, bitset src2) |
abitset_and_cmp (bitset dst, bitset src1, bitset src2) |
442 |
{ |
{ |
443 |
bitset_windex i; |
bitset_windex i; |
444 |
int changed = 0; |
bool changed = false; |
445 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
446 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
447 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
453 |
|
|
454 |
if (*dstp != tmp) |
if (*dstp != tmp) |
455 |
{ |
{ |
456 |
changed = 1; |
changed = true; |
457 |
*dstp = tmp; |
*dstp = tmp; |
458 |
} |
} |
459 |
} |
} |
475 |
} |
} |
476 |
|
|
477 |
|
|
478 |
static int |
static bool |
479 |
abitset_andn_cmp (bitset dst, bitset src1, bitset src2) |
abitset_andn_cmp (bitset dst, bitset src1, bitset src2) |
480 |
{ |
{ |
481 |
bitset_windex i; |
bitset_windex i; |
482 |
int changed = 0; |
bool changed = false; |
483 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
484 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
485 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
491 |
|
|
492 |
if (*dstp != tmp) |
if (*dstp != tmp) |
493 |
{ |
{ |
494 |
changed = 1; |
changed = true; |
495 |
*dstp = tmp; |
*dstp = tmp; |
496 |
} |
} |
497 |
} |
} |
513 |
} |
} |
514 |
|
|
515 |
|
|
516 |
static int |
static bool |
517 |
abitset_or_cmp (bitset dst, bitset src1, bitset src2) |
abitset_or_cmp (bitset dst, bitset src1, bitset src2) |
518 |
{ |
{ |
519 |
bitset_windex i; |
bitset_windex i; |
520 |
int changed = 0; |
bool changed = false; |
521 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
522 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
523 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
529 |
|
|
530 |
if (*dstp != tmp) |
if (*dstp != tmp) |
531 |
{ |
{ |
532 |
changed = 1; |
changed = true; |
533 |
*dstp = tmp; |
*dstp = tmp; |
534 |
} |
} |
535 |
} |
} |
551 |
} |
} |
552 |
|
|
553 |
|
|
554 |
static int |
static bool |
555 |
abitset_xor_cmp (bitset dst, bitset src1, bitset src2) |
abitset_xor_cmp (bitset dst, bitset src1, bitset src2) |
556 |
{ |
{ |
557 |
bitset_windex i; |
bitset_windex i; |
558 |
int changed = 0; |
bool changed = false; |
559 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
560 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
561 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
567 |
|
|
568 |
if (*dstp != tmp) |
if (*dstp != tmp) |
569 |
{ |
{ |
570 |
changed = 1; |
changed = true; |
571 |
*dstp = tmp; |
*dstp = tmp; |
572 |
} |
} |
573 |
} |
} |
590 |
} |
} |
591 |
|
|
592 |
|
|
593 |
static int |
static bool |
594 |
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) |
abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) |
595 |
{ |
{ |
596 |
bitset_windex i; |
bitset_windex i; |
597 |
int changed = 0; |
bool changed = false; |
598 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
599 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
600 |
bitset_word *src3p = ABITSET_WORDS (src3); |
bitset_word *src3p = ABITSET_WORDS (src3); |
607 |
|
|
608 |
if (*dstp != tmp) |
if (*dstp != tmp) |
609 |
{ |
{ |
610 |
changed = 1; |
changed = true; |
611 |
*dstp = tmp; |
*dstp = tmp; |
612 |
} |
} |
613 |
} |
} |
630 |
} |
} |
631 |
|
|
632 |
|
|
633 |
static int |
static bool |
634 |
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) |
abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3) |
635 |
{ |
{ |
636 |
bitset_windex i; |
bitset_windex i; |
637 |
int changed = 0; |
bool changed = false; |
638 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
639 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
640 |
bitset_word *src3p = ABITSET_WORDS (src3); |
bitset_word *src3p = ABITSET_WORDS (src3); |
647 |
|
|
648 |
if (*dstp != tmp) |
if (*dstp != tmp) |
649 |
{ |
{ |
650 |
changed = 1; |
changed = true; |
651 |
*dstp = tmp; |
*dstp = tmp; |
652 |
} |
} |
653 |
} |
} |
670 |
} |
} |
671 |
|
|
672 |
|
|
673 |
static int |
static bool |
674 |
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3) |
abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3) |
675 |
{ |
{ |
676 |
bitset_windex i; |
bitset_windex i; |
677 |
int changed = 0; |
bool changed = false; |
678 |
bitset_word *src1p = ABITSET_WORDS (src1); |
bitset_word *src1p = ABITSET_WORDS (src1); |
679 |
bitset_word *src2p = ABITSET_WORDS (src2); |
bitset_word *src2p = ABITSET_WORDS (src2); |
680 |
bitset_word *src3p = ABITSET_WORDS (src3); |
bitset_word *src3p = ABITSET_WORDS (src3); |
687 |
|
|
688 |
if (*dstp != tmp) |
if (*dstp != tmp) |
689 |
{ |
{ |
690 |
changed = 1; |
changed = true; |
691 |
*dstp = tmp; |
*dstp = tmp; |
692 |
} |
} |
693 |
} |
} |