51 |
static void abitset_reset PARAMS ((bitset, bitset_bindex)); |
static void abitset_reset PARAMS ((bitset, bitset_bindex)); |
52 |
static int abitset_test PARAMS ((bitset, bitset_bindex)); |
static int abitset_test PARAMS ((bitset, bitset_bindex)); |
53 |
static int abitset_size PARAMS ((bitset)); |
static int abitset_size PARAMS ((bitset)); |
|
static int abitset_op1 PARAMS ((bitset, enum bitset_ops)); |
|
|
static int abitset_op2 PARAMS ((bitset, bitset, enum bitset_ops)); |
|
|
static int abitset_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops)); |
|
|
static int abitset_op4 PARAMS ((bitset, bitset, bitset, bitset, |
|
|
enum bitset_ops)); |
|
54 |
static int abitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex, |
static int abitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex, |
55 |
bitset_bindex *)); |
bitset_bindex *)); |
56 |
static int abitset_reverse_list |
static int abitset_list_reverse |
57 |
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *)); |
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *)); |
58 |
|
|
59 |
#define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) |
#define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) |
138 |
bitset dst ATTRIBUTE_UNUSED; |
bitset dst ATTRIBUTE_UNUSED; |
139 |
bitset_bindex bitno ATTRIBUTE_UNUSED; |
bitset_bindex bitno ATTRIBUTE_UNUSED; |
140 |
{ |
{ |
141 |
/* This should never occur for abitsets. */ |
/* This should never occur for abitsets since we should always |
142 |
|
hit the cache. */ |
143 |
abort (); |
abort (); |
144 |
} |
} |
145 |
|
|
150 |
bitset dst ATTRIBUTE_UNUSED; |
bitset dst ATTRIBUTE_UNUSED; |
151 |
bitset_bindex bitno ATTRIBUTE_UNUSED; |
bitset_bindex bitno ATTRIBUTE_UNUSED; |
152 |
{ |
{ |
153 |
/* This should never occur for abitsets. */ |
/* This should never occur for abitsets since we should always |
154 |
|
hit the cache. */ |
155 |
abort (); |
abort (); |
156 |
} |
} |
157 |
|
|
162 |
bitset src ATTRIBUTE_UNUSED; |
bitset src ATTRIBUTE_UNUSED; |
163 |
bitset_bindex bitno ATTRIBUTE_UNUSED; |
bitset_bindex bitno ATTRIBUTE_UNUSED; |
164 |
{ |
{ |
165 |
/* This should never occur for abitsets. */ |
/* This should never occur for abitsets since we should always |
166 |
|
hit the cache. */ |
167 |
abort (); |
abort (); |
168 |
return 0; |
return 0; |
169 |
} |
} |
174 |
actual number of bits found and with *NEXT indicating where search |
actual number of bits found and with *NEXT indicating where search |
175 |
stopped. */ |
stopped. */ |
176 |
static int |
static int |
177 |
abitset_reverse_list (src, list, num, next) |
abitset_list_reverse (src, list, num, next) |
178 |
bitset src; |
bitset src; |
179 |
bitset_bindex *list; |
bitset_bindex *list; |
180 |
bitset_bindex num; |
bitset_bindex num; |
186 |
bitset_windex windex; |
bitset_windex windex; |
187 |
unsigned int bitcnt; |
unsigned int bitcnt; |
188 |
bitset_bindex bitoff; |
bitset_bindex bitoff; |
|
bitset_word word; |
|
189 |
bitset_word *srcp = ABITSET_WORDS (src); |
bitset_word *srcp = ABITSET_WORDS (src); |
190 |
bitset_bindex n_bits = ABITSET_N_BITS (src); |
bitset_bindex n_bits = ABITSET_N_BITS (src); |
191 |
|
|
207 |
|
|
208 |
do |
do |
209 |
{ |
{ |
210 |
|
bitset_word word; |
211 |
|
|
212 |
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt); |
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt); |
213 |
for (; word; bitcnt--) |
for (; word; bitcnt--) |
214 |
{ |
{ |
353 |
} |
} |
354 |
|
|
355 |
|
|
356 |
static int |
static void |
357 |
abitset_op1 (dst, op) |
abitset_ones (dst) |
358 |
bitset dst; |
bitset dst; |
|
enum bitset_ops op; |
|
359 |
{ |
{ |
|
unsigned int i; |
|
360 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
361 |
unsigned int bytes; |
unsigned int bytes; |
362 |
|
|
363 |
bytes = sizeof (bitset_word) * dst->b.csize; |
bytes = sizeof (bitset_word) * dst->b.csize; |
364 |
|
|
365 |
switch (op) |
memset (dstp, -1, bytes); |
366 |
{ |
abitset_unused_clear (dst); |
367 |
case BITSET_OP_ZERO: |
} |
368 |
memset (dstp, 0, bytes); |
|
369 |
break; |
|
370 |
|
static void |
371 |
case BITSET_OP_ONES: |
abitset_zero (dst) |
372 |
memset (dstp, -1, bytes); |
bitset dst; |
373 |
abitset_unused_clear (dst); |
{ |
374 |
break; |
bitset_word *dstp = ABITSET_WORDS (dst); |
375 |
|
unsigned int bytes; |
376 |
case BITSET_OP_EMPTY_P: |
|
377 |
for (i = 0; i < dst->b.csize; i++) |
bytes = sizeof (bitset_word) * dst->b.csize; |
378 |
if (dstp[i]) |
|
379 |
return 0; |
memset (dstp, 0, bytes); |
380 |
break; |
} |
381 |
|
|
382 |
default: |
|
383 |
abort (); |
static int |
384 |
} |
abitset_empty_p (dst) |
385 |
|
bitset dst; |
386 |
|
{ |
387 |
|
unsigned int i; |
388 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
389 |
|
|
390 |
|
for (i = 0; i < dst->b.csize; i++) |
391 |
|
if (dstp[i]) |
392 |
|
return 0; |
393 |
|
|
394 |
return 1; |
return 1; |
395 |
} |
} |
396 |
|
|
397 |
|
|
398 |
|
static void |
399 |
|
abitset_copy1 (dst, src) |
400 |
|
bitset dst; |
401 |
|
bitset src; |
402 |
|
{ |
403 |
|
bitset_word *srcp = ABITSET_WORDS (src); |
404 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
405 |
|
bitset_windex size = dst->b.csize; |
406 |
|
|
407 |
|
if (srcp == dstp) |
408 |
|
return; |
409 |
|
memcpy (dstp, srcp, sizeof (bitset_word) * size); |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
|
static void |
414 |
|
abitset_not (dst, src) |
415 |
|
bitset dst; |
416 |
|
bitset src; |
417 |
|
{ |
418 |
|
unsigned int i; |
419 |
|
bitset_word *srcp = ABITSET_WORDS (src); |
420 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
421 |
|
bitset_windex size = dst->b.csize; |
422 |
|
|
423 |
|
for (i = 0; i < size; i++) |
424 |
|
*dstp++ = ~(*srcp++); |
425 |
|
abitset_unused_clear (dst); |
426 |
|
} |
427 |
|
|
428 |
|
|
429 |
static int |
static int |
430 |
abitset_op2 (dst, src, op) |
abitset_equal_p (dst, src) |
431 |
bitset dst; |
bitset dst; |
432 |
bitset src; |
bitset src; |
|
enum bitset_ops op; |
|
433 |
{ |
{ |
434 |
unsigned int i; |
unsigned int i; |
435 |
bitset_word *srcp = ABITSET_WORDS (src); |
bitset_word *srcp = ABITSET_WORDS (src); |
436 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
437 |
bitset_windex size = dst->b.csize; |
bitset_windex size = dst->b.csize; |
438 |
|
|
439 |
switch (op) |
for (i = 0; i < size; i++) |
440 |
{ |
if (*srcp++ != *dstp++) |
|
case BITSET_OP_COPY: |
|
|
if (srcp == dstp) |
|
|
break; |
|
|
memcpy (dstp, srcp, sizeof (bitset_word) * size); |
|
|
break; |
|
|
|
|
|
case BITSET_OP_NOT: |
|
|
for (i = 0; i < size; i++) |
|
|
*dstp++ = ~(*srcp++); |
|
|
abitset_unused_clear (dst); |
|
|
break; |
|
|
|
|
|
case BITSET_OP_EQUAL_P: |
|
|
for (i = 0; i < size; i++) |
|
|
if (*srcp++ != *dstp++) |
|
441 |
return 0; |
return 0; |
442 |
break; |
return 1; |
443 |
|
} |
444 |
case BITSET_OP_SUBSET_P: |
|
445 |
for (i = 0; i < size; i++, dstp++, srcp++) |
|
446 |
if (*dstp != (*srcp | *dstp)) |
static int |
447 |
|
abitset_subset_p (dst, src) |
448 |
|
bitset dst; |
449 |
|
bitset src; |
450 |
|
{ |
451 |
|
unsigned int i; |
452 |
|
bitset_word *srcp = ABITSET_WORDS (src); |
453 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
454 |
|
bitset_windex size = dst->b.csize; |
455 |
|
|
456 |
|
for (i = 0; i < size; i++, dstp++, srcp++) |
457 |
|
if (*dstp != (*srcp | *dstp)) |
458 |
return 0; |
return 0; |
459 |
break; |
return 1; |
460 |
|
} |
461 |
case BITSET_OP_DISJOINT_P: |
|
462 |
for (i = 0; i < size; i++) |
|
463 |
if (*srcp++ & *dstp++) |
static int |
464 |
|
abitset_disjoint_p (dst, src) |
465 |
|
bitset dst; |
466 |
|
bitset src; |
467 |
|
{ |
468 |
|
unsigned int i; |
469 |
|
bitset_word *srcp = ABITSET_WORDS (src); |
470 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
471 |
|
bitset_windex size = dst->b.csize; |
472 |
|
|
473 |
|
for (i = 0; i < size; i++) |
474 |
|
if (*srcp++ & *dstp++) |
475 |
return 0; |
return 0; |
|
break; |
|
|
|
|
|
default: |
|
|
abort (); |
|
|
} |
|
476 |
|
|
477 |
return 1; |
return 1; |
478 |
} |
} |
479 |
|
|
480 |
|
|
481 |
|
static void |
482 |
|
abitset_and (dst, src1, src2) |
483 |
|
bitset dst; |
484 |
|
bitset src1; |
485 |
|
bitset src2; |
486 |
|
{ |
487 |
|
unsigned int i; |
488 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
489 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
490 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
491 |
|
bitset_windex size = dst->b.csize; |
492 |
|
|
493 |
|
for (i = 0; i < size; i++) |
494 |
|
*dstp++ = *src1p++ & *src2p++; |
495 |
|
} |
496 |
|
|
497 |
|
|
498 |
static int |
static int |
499 |
abitset_op3 (dst, src1, src2, op) |
abitset_and_cmp (dst, src1, src2) |
500 |
bitset dst; |
bitset dst; |
501 |
bitset src1; |
bitset src1; |
502 |
bitset src2; |
bitset src2; |
|
enum bitset_ops op; |
|
503 |
{ |
{ |
504 |
unsigned int i; |
unsigned int i; |
505 |
int changed = 0; |
int changed = 0; |
508 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
509 |
bitset_windex size = dst->b.csize; |
bitset_windex size = dst->b.csize; |
510 |
|
|
511 |
switch (op) |
for (i = 0; i < size; i++, dstp++) |
512 |
{ |
{ |
513 |
case BITSET_OP_OR: |
bitset_word tmp = *src1p++ & *src2p++; |
514 |
for (i = 0; i < size; i++, dstp++) |
|
515 |
|
if (*dstp != tmp) |
516 |
{ |
{ |
517 |
bitset_word tmp = *src1p++ | *src2p++; |
changed = 1; |
518 |
|
*dstp = tmp; |
|
if (*dstp != tmp) |
|
|
{ |
|
|
changed = 1; |
|
|
*dstp = tmp; |
|
|
} |
|
519 |
} |
} |
520 |
break; |
} |
521 |
|
return changed; |
522 |
|
} |
523 |
|
|
|
case BITSET_OP_AND: |
|
|
for (i = 0; i < size; i++, dstp++) |
|
|
{ |
|
|
bitset_word tmp = *src1p++ & *src2p++; |
|
524 |
|
|
525 |
if (*dstp != tmp) |
static void |
526 |
{ |
abitset_andn (dst, src1, src2) |
527 |
changed = 1; |
bitset dst; |
528 |
*dstp = tmp; |
bitset src1; |
529 |
} |
bitset src2; |
530 |
} |
{ |
531 |
break; |
unsigned int i; |
532 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
533 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
534 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
535 |
|
bitset_windex size = dst->b.csize; |
536 |
|
|
537 |
case BITSET_OP_XOR: |
for (i = 0; i < size; i++) |
538 |
for (i = 0; i < size; i++, dstp++) |
*dstp++ = *src1p++ & ~(*src2p++); |
539 |
{ |
} |
|
bitset_word tmp = *src1p++ ^ *src2p++; |
|
540 |
|
|
|
if (*dstp != tmp) |
|
|
{ |
|
|
changed = 1; |
|
|
*dstp = tmp; |
|
|
} |
|
|
} |
|
|
break; |
|
541 |
|
|
542 |
case BITSET_OP_ANDN: |
static int |
543 |
for (i = 0; i < size; i++, dstp++) |
abitset_andn_cmp (dst, src1, src2) |
544 |
|
bitset dst; |
545 |
|
bitset src1; |
546 |
|
bitset src2; |
547 |
|
{ |
548 |
|
unsigned int i; |
549 |
|
int changed = 0; |
550 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
551 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
552 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
553 |
|
bitset_windex size = dst->b.csize; |
554 |
|
|
555 |
|
for (i = 0; i < size; i++, dstp++) |
556 |
|
{ |
557 |
|
bitset_word tmp = *src1p++ & ~(*src2p++); |
558 |
|
|
559 |
|
if (*dstp != tmp) |
560 |
{ |
{ |
561 |
bitset_word tmp = *src1p++ & ~(*src2p++); |
changed = 1; |
562 |
|
*dstp = tmp; |
|
if (*dstp != tmp) |
|
|
{ |
|
|
changed = 1; |
|
|
*dstp = tmp; |
|
|
} |
|
563 |
} |
} |
564 |
break; |
} |
565 |
|
return changed; |
566 |
|
} |
567 |
|
|
568 |
|
|
569 |
|
static void |
570 |
|
abitset_or (dst, src1, src2) |
571 |
|
bitset dst; |
572 |
|
bitset src1; |
573 |
|
bitset src2; |
574 |
|
{ |
575 |
|
unsigned int i; |
576 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
577 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
578 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
579 |
|
bitset_windex size = dst->b.csize; |
580 |
|
|
581 |
|
for (i = 0; i < size; i++) |
582 |
|
*dstp++ = *src1p++ | *src2p++; |
583 |
|
} |
584 |
|
|
585 |
|
|
586 |
default: |
static int |
587 |
abort (); |
abitset_or_cmp (dst, src1, src2) |
588 |
|
bitset dst; |
589 |
|
bitset src1; |
590 |
|
bitset src2; |
591 |
|
{ |
592 |
|
unsigned int i; |
593 |
|
int changed = 0; |
594 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
595 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
596 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
597 |
|
bitset_windex size = dst->b.csize; |
598 |
|
|
599 |
|
for (i = 0; i < size; i++, dstp++) |
600 |
|
{ |
601 |
|
bitset_word tmp = *src1p++ | *src2p++; |
602 |
|
|
603 |
|
if (*dstp != tmp) |
604 |
|
{ |
605 |
|
changed = 1; |
606 |
|
*dstp = tmp; |
607 |
|
} |
608 |
} |
} |
609 |
|
return changed; |
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
|
static void |
614 |
|
abitset_xor (dst, src1, src2) |
615 |
|
bitset dst; |
616 |
|
bitset src1; |
617 |
|
bitset src2; |
618 |
|
{ |
619 |
|
unsigned int i; |
620 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
621 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
622 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
623 |
|
bitset_windex size = dst->b.csize; |
624 |
|
|
625 |
|
for (i = 0; i < size; i++) |
626 |
|
*dstp++ = *src1p++ ^ *src2p++; |
627 |
|
} |
628 |
|
|
629 |
|
|
630 |
|
static int |
631 |
|
abitset_xor_cmp (dst, src1, src2) |
632 |
|
bitset dst; |
633 |
|
bitset src1; |
634 |
|
bitset src2; |
635 |
|
{ |
636 |
|
unsigned int i; |
637 |
|
int changed = 0; |
638 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
639 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
640 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
641 |
|
bitset_windex size = dst->b.csize; |
642 |
|
|
643 |
|
for (i = 0; i < size; i++, dstp++) |
644 |
|
{ |
645 |
|
bitset_word tmp = *src1p++ ^ *src2p++; |
646 |
|
|
647 |
|
if (*dstp != tmp) |
648 |
|
{ |
649 |
|
changed = 1; |
650 |
|
*dstp = tmp; |
651 |
|
} |
652 |
|
} |
653 |
return changed; |
return changed; |
654 |
} |
} |
655 |
|
|
656 |
|
|
657 |
|
static void |
658 |
|
abitset_and_or (dst, src1, src2, src3) |
659 |
|
bitset dst; |
660 |
|
bitset src1; |
661 |
|
bitset src2; |
662 |
|
bitset src3; |
663 |
|
{ |
664 |
|
unsigned int i; |
665 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
666 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
667 |
|
bitset_word *src3p = ABITSET_WORDS (src3); |
668 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
669 |
|
bitset_windex size = dst->b.csize; |
670 |
|
|
671 |
|
for (i = 0; i < size; i++) |
672 |
|
*dstp++ = (*src1p++ & *src2p++) | *src3p++; |
673 |
|
} |
674 |
|
|
675 |
|
|
676 |
static int |
static int |
677 |
abitset_op4 (dst, src1, src2, src3, op) |
abitset_and_or_cmp (dst, src1, src2, src3) |
678 |
bitset dst; |
bitset dst; |
679 |
bitset src1; |
bitset src1; |
680 |
bitset src2; |
bitset src2; |
681 |
bitset src3; |
bitset src3; |
|
enum bitset_ops op; |
|
682 |
{ |
{ |
683 |
unsigned int i; |
unsigned int i; |
684 |
int changed = 0; |
int changed = 0; |
687 |
bitset_word *src3p = ABITSET_WORDS (src3); |
bitset_word *src3p = ABITSET_WORDS (src3); |
688 |
bitset_word *dstp = ABITSET_WORDS (dst); |
bitset_word *dstp = ABITSET_WORDS (dst); |
689 |
bitset_windex size = dst->b.csize; |
bitset_windex size = dst->b.csize; |
690 |
|
|
691 |
switch (op) |
for (i = 0; i < size; i++, dstp++) |
692 |
{ |
{ |
693 |
case BITSET_OP_OR_AND: |
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++; |
694 |
for (i = 0; i < size; i++, dstp++) |
|
695 |
|
if (*dstp != tmp) |
696 |
{ |
{ |
697 |
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++; |
changed = 1; |
698 |
|
*dstp = tmp; |
|
if (*dstp != tmp) |
|
|
{ |
|
|
changed = 1; |
|
|
*dstp = tmp; |
|
|
} |
|
699 |
} |
} |
700 |
break; |
} |
701 |
|
return changed; |
702 |
|
} |
703 |
|
|
|
case BITSET_OP_AND_OR: |
|
|
for (i = 0; i < size; i++, dstp++) |
|
|
{ |
|
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++; |
|
704 |
|
|
705 |
if (*dstp != tmp) |
static void |
706 |
{ |
abitset_andn_or (dst, src1, src2, src3) |
707 |
changed = 1; |
bitset dst; |
708 |
*dstp = tmp; |
bitset src1; |
709 |
} |
bitset src2; |
710 |
} |
bitset src3; |
711 |
break; |
{ |
712 |
|
unsigned int i; |
713 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
714 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
715 |
|
bitset_word *src3p = ABITSET_WORDS (src3); |
716 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
717 |
|
bitset_windex size = dst->b.csize; |
718 |
|
|
719 |
|
for (i = 0; i < size; i++) |
720 |
|
*dstp++ = (*src1p++ & ~(*src2p++)) | *src3p++; |
721 |
|
} |
722 |
|
|
|
case BITSET_OP_ANDN_OR: |
|
|
for (i = 0; i < size; i++, dstp++) |
|
|
{ |
|
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++; |
|
723 |
|
|
724 |
if (*dstp != tmp) |
static int |
725 |
{ |
abitset_andn_or_cmp (dst, src1, src2, src3) |
726 |
changed = 1; |
bitset dst; |
727 |
*dstp = tmp; |
bitset src1; |
728 |
} |
bitset src2; |
729 |
|
bitset src3; |
730 |
|
{ |
731 |
|
unsigned int i; |
732 |
|
int changed = 0; |
733 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
734 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
735 |
|
bitset_word *src3p = ABITSET_WORDS (src3); |
736 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
737 |
|
bitset_windex size = dst->b.csize; |
738 |
|
|
739 |
|
for (i = 0; i < size; i++, dstp++) |
740 |
|
{ |
741 |
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++; |
742 |
|
|
743 |
|
if (*dstp != tmp) |
744 |
|
{ |
745 |
|
changed = 1; |
746 |
|
*dstp = tmp; |
747 |
} |
} |
|
break; |
|
|
|
|
|
default: |
|
|
abort (); |
|
748 |
} |
} |
749 |
|
return changed; |
750 |
|
} |
751 |
|
|
752 |
|
|
753 |
|
static void |
754 |
|
abitset_or_and (dst, src1, src2, src3) |
755 |
|
bitset dst; |
756 |
|
bitset src1; |
757 |
|
bitset src2; |
758 |
|
bitset src3; |
759 |
|
{ |
760 |
|
unsigned int i; |
761 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
762 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
763 |
|
bitset_word *src3p = ABITSET_WORDS (src3); |
764 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
765 |
|
bitset_windex size = dst->b.csize; |
766 |
|
|
767 |
|
for (i = 0; i < size; i++) |
768 |
|
*dstp++ = (*src1p++ | *src2p++) & *src3p++; |
769 |
|
} |
770 |
|
|
771 |
|
|
772 |
|
static int |
773 |
|
abitset_or_and_cmp (dst, src1, src2, src3) |
774 |
|
bitset dst; |
775 |
|
bitset src1; |
776 |
|
bitset src2; |
777 |
|
bitset src3; |
778 |
|
{ |
779 |
|
unsigned int i; |
780 |
|
int changed = 0; |
781 |
|
bitset_word *src1p = ABITSET_WORDS (src1); |
782 |
|
bitset_word *src2p = ABITSET_WORDS (src2); |
783 |
|
bitset_word *src3p = ABITSET_WORDS (src3); |
784 |
|
bitset_word *dstp = ABITSET_WORDS (dst); |
785 |
|
bitset_windex size = dst->b.csize; |
786 |
|
|
787 |
|
for (i = 0; i < size; i++, dstp++) |
788 |
|
{ |
789 |
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++; |
790 |
|
|
791 |
|
if (*dstp != tmp) |
792 |
|
{ |
793 |
|
changed = 1; |
794 |
|
*dstp = tmp; |
795 |
|
} |
796 |
|
} |
797 |
return changed; |
return changed; |
798 |
} |
} |
799 |
|
|
800 |
|
|
801 |
|
void |
802 |
|
abitset_copy (dst, src) |
803 |
|
bitset dst; |
804 |
|
bitset src; |
805 |
|
{ |
806 |
|
if (BITSET_COMPATIBLE_ (dst, src)) |
807 |
|
abitset_copy1 (dst, src); |
808 |
|
else |
809 |
|
bitset_copy_ (dst, src); |
810 |
|
} |
811 |
|
|
812 |
|
|
813 |
/* Vector of operations for single word bitsets. */ |
/* Vector of operations for single word bitsets. */ |
814 |
struct bitset_ops_struct abitset_small_ops = { |
struct bitset_vtable abitset_small_vtable = { |
815 |
abitset_set, |
abitset_set, |
816 |
abitset_reset, |
abitset_reset, |
817 |
|
bitset_toggle_, |
818 |
abitset_test, |
abitset_test, |
819 |
abitset_size, |
abitset_size, |
820 |
abitset_op1, |
bitset_count_, |
821 |
abitset_op2, |
abitset_empty_p, |
822 |
abitset_op3, |
abitset_ones, |
823 |
abitset_op4, |
abitset_zero, |
824 |
|
abitset_copy, |
825 |
|
abitset_disjoint_p, |
826 |
|
abitset_equal_p, |
827 |
|
abitset_not, |
828 |
|
abitset_subset_p, |
829 |
|
abitset_and, |
830 |
|
abitset_and_cmp, |
831 |
|
abitset_andn, |
832 |
|
abitset_andn_cmp, |
833 |
|
abitset_or, |
834 |
|
abitset_or_cmp, |
835 |
|
abitset_xor, |
836 |
|
abitset_xor_cmp, |
837 |
|
abitset_and_or, |
838 |
|
abitset_and_or_cmp, |
839 |
|
abitset_andn_or, |
840 |
|
abitset_andn_or_cmp, |
841 |
|
abitset_or_and, |
842 |
|
abitset_or_and_cmp, |
843 |
abitset_small_list, |
abitset_small_list, |
844 |
abitset_reverse_list, |
abitset_list_reverse, |
845 |
NULL, |
NULL, |
846 |
BITSET_ARRAY |
BITSET_ARRAY |
847 |
}; |
}; |
848 |
|
|
849 |
|
|
850 |
/* Vector of operations for multiple word bitsets. */ |
/* Vector of operations for multiple word bitsets. */ |
851 |
struct bitset_ops_struct abitset_ops = { |
struct bitset_vtable abitset_vtable = { |
852 |
abitset_set, |
abitset_set, |
853 |
abitset_reset, |
abitset_reset, |
854 |
|
bitset_toggle_, |
855 |
abitset_test, |
abitset_test, |
856 |
abitset_size, |
abitset_size, |
857 |
abitset_op1, |
bitset_count_, |
858 |
abitset_op2, |
abitset_empty_p, |
859 |
abitset_op3, |
abitset_ones, |
860 |
abitset_op4, |
abitset_zero, |
861 |
|
abitset_copy, |
862 |
|
abitset_disjoint_p, |
863 |
|
abitset_equal_p, |
864 |
|
abitset_not, |
865 |
|
abitset_subset_p, |
866 |
|
abitset_and, |
867 |
|
abitset_and_cmp, |
868 |
|
abitset_andn, |
869 |
|
abitset_andn_cmp, |
870 |
|
abitset_or, |
871 |
|
abitset_or_cmp, |
872 |
|
abitset_xor, |
873 |
|
abitset_xor_cmp, |
874 |
|
abitset_and_or, |
875 |
|
abitset_and_or_cmp, |
876 |
|
abitset_andn_or, |
877 |
|
abitset_andn_or_cmp, |
878 |
|
abitset_or_and, |
879 |
|
abitset_or_and_cmp, |
880 |
abitset_list, |
abitset_list, |
881 |
abitset_reverse_list, |
abitset_list_reverse, |
882 |
NULL, |
NULL, |
883 |
BITSET_ARRAY |
BITSET_ARRAY |
884 |
}; |
}; |
910 |
There is probably little merit if using caching since |
There is probably little merit if using caching since |
911 |
the small bitset will always fit in the cache. */ |
the small bitset will always fit in the cache. */ |
912 |
if (size == 1) |
if (size == 1) |
913 |
bset->b.ops = &abitset_small_ops; |
bset->b.vtable = &abitset_small_vtable; |
914 |
else |
else |
915 |
bset->b.ops = &abitset_ops; |
bset->b.vtable = &abitset_vtable; |
916 |
|
|
917 |
bset->b.cindex = 0; |
bset->b.cindex = 0; |
918 |
bset->b.csize = size; |
bset->b.csize = size; |