/[bison]/bison/lib/ebitset.c
ViewVC logotype

Diff of /bison/lib/ebitset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by eggert, Mon Aug 12 14:20:35 2002 UTC revision 1.6 by akim, Mon Sep 30 12:50:49 2002 UTC
# Line 77  typedef struct ebitset_struct Line 77  typedef struct ebitset_struct
77  *ebitset;  *ebitset;
78    
79    
80    typedef void(*PFV)();
81    
82    
83  /* Number of elements to initially allocate.  */  /* Number of elements to initially allocate.  */
84    
85  #ifndef EBITSET_INITIAL_SIZE  #ifndef EBITSET_INITIAL_SIZE
# Line 118  static int ebitset_elt_zero_p PARAMS ((e Line 121  static int ebitset_elt_zero_p PARAMS ((e
121    
122  static int ebitset_weed PARAMS ((bitset));  static int ebitset_weed PARAMS ((bitset));
123  static void ebitset_zero PARAMS ((bitset));  static void ebitset_zero PARAMS ((bitset));
124  static int ebitset_equal_p PARAMS ((bitset, bitset));  static void ebitset_copy_ PARAMS ((bitset, bitset));
125  static void ebitset_copy PARAMS ((bitset, bitset));  static int ebitset_copy_cmp PARAMS ((bitset, bitset));
 static int ebitset_copy_compare PARAMS ((bitset, bitset));  
126  static void ebitset_set PARAMS ((bitset, bitset_bindex));  static void ebitset_set PARAMS ((bitset, bitset_bindex));
127  static void ebitset_reset PARAMS ((bitset, bitset_bindex));  static void ebitset_reset PARAMS ((bitset, bitset_bindex));
128  static int ebitset_test PARAMS ((bitset, bitset_bindex));  static int ebitset_test PARAMS ((bitset, bitset_bindex));
129  static int ebitset_size PARAMS ((bitset));  static int ebitset_size PARAMS ((bitset));
130  static int ebitset_op1 PARAMS ((bitset, enum bitset_ops));  static int ebitset_disjoint_p PARAMS ((bitset, bitset));
131  static int ebitset_op2 PARAMS ((bitset, bitset, enum bitset_ops));  static int ebitset_equal_p PARAMS ((bitset, bitset));
132  static int ebitset_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops));  static void ebitset_not PARAMS ((bitset, bitset));
133    static int ebitset_subset_p PARAMS ((bitset, bitset));
134    static int ebitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum bitset_ops));
135    static int ebitset_and_cmp PARAMS ((bitset, bitset, bitset));
136    static int ebitset_andn_cmp PARAMS ((bitset, bitset, bitset));
137    static int ebitset_or_cmp PARAMS ((bitset, bitset, bitset));
138    static int ebitset_xor_cmp PARAMS ((bitset, bitset, bitset));
139  static int ebitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,  static int ebitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
140                                   bitset_bindex *));                                   bitset_bindex *));
141  static int ebitset_reverse_list  static int ebitset_list_reverse
142  PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));  PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
143  static void ebitset_free PARAMS ((bitset));  static void ebitset_free PARAMS ((bitset));
144    
# Line 141  static void ebitset_free PARAMS ((bitset Line 149  static void ebitset_free PARAMS ((bitset
149  #define EBITSET_WORDS(ELT) ((ELT)->u.words)  #define EBITSET_WORDS(ELT) ((ELT)->u.words)
150    
151  /* Disable bitset cache and mark BSET as being zero.  */  /* Disable bitset cache and mark BSET as being zero.  */
152  #define EBITSET_OP_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_INDEX_MAX, \  #define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_INDEX_MAX, \
153          (BSET)->b.cdata = 0)          (BSET)->b.cdata = 0)
154    
155  #define EBITSET_CACHE_DISABLE(BSET)  ((BSET)->b.cindex = BITSET_INDEX_MAX)  #define EBITSET_CACHE_DISABLE(BSET)  ((BSET)->b.cindex = BITSET_INDEX_MAX)
# Line 152  static void ebitset_free PARAMS ((bitset Line 160  static void ebitset_free PARAMS ((bitset
160    
161  /* A conservative estimate of whether the bitset is zero.  /* A conservative estimate of whether the bitset is zero.
162     This is non-zero only if we know for sure that the bitset is zero.  */     This is non-zero only if we know for sure that the bitset is zero.  */
163  #define EBITSET_OP_ZERO_P(BSET) ((BSET)->b.cdata == 0)  #define EBITSET_ZERO_P(BSET) ((BSET)->b.cdata == 0)
164    
165  /* Enable cache to point to element with table index EINDEX.  /* Enable cache to point to element with table index EINDEX.
166     The element must exist.  */     The element must exist.  */
# Line 395  ebitset_weed (bset) Line 403  ebitset_weed (bset)
403    bitset_windex j;    bitset_windex j;
404    int count;    int count;
405    
406    if (EBITSET_OP_ZERO_P (bset))    if (EBITSET_ZERO_P (bset))
407      return 0;      return 0;
408    
409    elts = EBITSET_ELTS (bset);    elts = EBITSET_ELTS (bset);
# Line 421  ebitset_weed (bset) Line 429  ebitset_weed (bset)
429      {      {
430        /* All the bits are zero.  We could shrink the elts.        /* All the bits are zero.  We could shrink the elts.
431           For now just mark BSET as known to be zero.  */           For now just mark BSET as known to be zero.  */
432        EBITSET_OP_ZERO_SET (bset);        EBITSET_ZERO_SET (bset);
433      }      }
434    else    else
435      EBITSET_NONZERO_SET (bset);      EBITSET_NONZERO_SET (bset);
# Line 438  ebitset_zero (bset) Line 446  ebitset_zero (bset)
446    ebitset_elts *elts;    ebitset_elts *elts;
447    bitset_windex j;    bitset_windex j;
448    
449    if (EBITSET_OP_ZERO_P (bset))    if (EBITSET_ZERO_P (bset))
450      return;      return;
451    
452    elts = EBITSET_ELTS (bset);    elts = EBITSET_ELTS (bset);
# Line 452  ebitset_zero (bset) Line 460  ebitset_zero (bset)
460    
461    /* All the bits are zero.  We could shrink the elts.    /* All the bits are zero.  We could shrink the elts.
462       For now just mark BSET as known to be zero.  */       For now just mark BSET as known to be zero.  */
463    EBITSET_OP_ZERO_SET (bset);    EBITSET_ZERO_SET (bset);
464  }  }
465    
466    
# Line 498  ebitset_equal_p (dst, src) Line 506  ebitset_equal_p (dst, src)
506    
507  /* Copy bits from bitset SRC to bitset DST.  */  /* Copy bits from bitset SRC to bitset DST.  */
508  static inline void  static inline void
509  ebitset_copy (dst, src)  ebitset_copy_ (dst, src)
510       bitset dst;       bitset dst;
511       bitset src;       bitset src;
512  {  {
# Line 537  ebitset_copy (dst, src) Line 545  ebitset_copy (dst, src)
545  /* Copy bits from bitset SRC to bitset DST.  Return non-zero if  /* Copy bits from bitset SRC to bitset DST.  Return non-zero if
546     bitsets different.  */     bitsets different.  */
547  static inline int  static inline int
548  ebitset_copy_compare (dst, src)  ebitset_copy_cmp (dst, src)
549       bitset dst;       bitset dst;
550       bitset src;       bitset src;
551  {  {
552    if (src == dst)    if (src == dst)
553      return 0;      return 0;
554    
555    if (EBITSET_OP_ZERO_P (dst))    if (EBITSET_ZERO_P (dst))
556      {      {
557        ebitset_copy (dst, src);        ebitset_copy_ (dst, src);
558        return !EBITSET_OP_ZERO_P (src);        return !EBITSET_ZERO_P (src);
559      }      }
560    
561    if (ebitset_equal_p (dst, src))    if (ebitset_equal_p (dst, src))
562      return 0;      return 0;
563    
564    ebitset_copy (dst, src);    ebitset_copy_ (dst, src);
565    return 1;    return 1;
566  }  }
567    
# Line 632  ebitset_free (bset) Line 640  ebitset_free (bset)
640   *NEXT and store in array LIST.  Return with actual number of bits   *NEXT and store in array LIST.  Return with actual number of bits
641   found and with *NEXT indicating where search stopped.  */   found and with *NEXT indicating where search stopped.  */
642  static int  static int
643  ebitset_reverse_list (bset, list, num, next)  ebitset_list_reverse (bset, list, num, next)
644       bitset bset;       bitset bset;
645       bitset_bindex *list;       bitset_bindex *list;
646       bitset_bindex num;       bitset_bindex num;
# Line 650  ebitset_reverse_list (bset, list, num, n Line 658  ebitset_reverse_list (bset, list, num, n
658    bitset_windex size;    bitset_windex size;
659    ebitset_elts *elts;    ebitset_elts *elts;
660    
661    if (EBITSET_OP_ZERO_P (bset))    if (EBITSET_ZERO_P (bset))
662      return 0;      return 0;
663    
664    size = EBITSET_SIZE (bset);    size = EBITSET_SIZE (bset);
# Line 678  ebitset_reverse_list (bset, list, num, n Line 686  ebitset_reverse_list (bset, list, num, n
686    do    do
687      {      {
688        ebitset_elt *elt;        ebitset_elt *elt;
689          bitset_word *srcp;
690          
691        elt = elts[eindex];        elt = elts[eindex];
692        if (elt)        if (elt)
693          {          {      
           bitset_word *srcp;  
   
694            srcp = EBITSET_WORDS (elt);            srcp = EBITSET_WORDS (elt);
695              
696            do            do
697              {              {
698                bitset_word word;                bitset_word word;
699                  
700                word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);                word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
701                  
702                for (; word; bcount--)                for (; word; bcount--)
703                  {                  {
704                    if (word & BITSET_MSB)                    if (word & BITSET_MSB)
# Line 705  ebitset_reverse_list (bset, list, num, n Line 712  ebitset_reverse_list (bset, list, num, n
712                      }                      }
713                    word <<= 1;                    word <<= 1;
714                  }                  }
   
715                boffset -= BITSET_WORD_BITS;                boffset -= BITSET_WORD_BITS;
716                bcount = BITSET_WORD_BITS - 1;                bcount = BITSET_WORD_BITS - 1;      
717              }              }
718            while (woffset--);            while (woffset--);
   
           woffset = EBITSET_ELT_WORDS;  
719          }          }
720    
721          woffset = EBITSET_ELT_WORDS - 1;
722        boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;        boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
723      }      }
724    while (eindex--);    while (eindex--);
# Line 742  ebitset_list (bset, list, num, next) Line 747  ebitset_list (bset, list, num, next)
747    bitset_word word;    bitset_word word;
748    ebitset_elts *elts;    ebitset_elts *elts;
749    
750    if (EBITSET_OP_ZERO_P (bset))    if (EBITSET_ZERO_P (bset))
751      return 0;      return 0;
752    
753    bitno = *next;    bitno = *next;
# Line 866  ebitset_list (bset, list, num, next) Line 871  ebitset_list (bset, list, num, next)
871  }  }
872    
873    
874  static int  static void
875  ebitset_op1 (dst, op)  ebitset_ones (dst)
876       bitset dst;       bitset dst;
      enum bitset_ops op;  
877  {  {
878    bitset_windex j;    bitset_windex j;
879    ebitset_elt *elt;    ebitset_elt *elt;
880    
   switch (op)  
     {  
     case BITSET_OP_ZERO:  
       ebitset_zero (dst);  
       return 1;  
   
     case BITSET_OP_ONES:  
       for (j = 0; j < EBITSET_SIZE (dst); j++)  
         {  
           /* Create new elements if they cannot be found.  Perhaps  
              we should just add pointers to a ones element.  */  
           elt =  
             ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);  
           memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));  
         }  
       break;  
   
     case BITSET_OP_EMPTY_P:  
       return !ebitset_weed (dst);  
881    
882      default:    for (j = 0; j < EBITSET_SIZE (dst); j++)
883        abort ();      {
884          /* Create new elements if they cannot be found.  Perhaps
885             we should just add pointers to a ones element.  */
886          elt =
887            ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);
888          memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
889      }      }
   
890    EBITSET_NONZERO_SET (dst);    EBITSET_NONZERO_SET (dst);
   return 1;  
891  }  }
892    
893    
894  static int  static int
895  ebitset_op2 (dst, src, op)  ebitset_empty_p (dst)
896         bitset dst;
897    {
898      return !ebitset_weed (dst);
899    }
900    
901    
902    static void
903    ebitset_not (dst, src)
904       bitset dst;       bitset dst;
905       bitset src;       bitset src;
      enum bitset_ops op;  
906  {  {
907      unsigned int i;
908    ebitset_elt *selt;    ebitset_elt *selt;
909    ebitset_elt *delt;    ebitset_elt *delt;
   unsigned int i;  
910    bitset_windex j;    bitset_windex j;
911    
912    switch (op)    for (j = 0; j < EBITSET_SIZE (src); j++)
913      {      {
914      case BITSET_OP_COPY:        /* Create new elements for dst if they cannot be found
       ebitset_copy (dst, src);  
       break;  
   
     case BITSET_OP_NOT:  
       for (j = 0; j < EBITSET_SIZE (src); j++)  
         {  
           /* Create new elements for dst if they cannot be found  
915               or substitute zero elements if src elements not found.  */               or substitute zero elements if src elements not found.  */
916            selt =        selt =
917              ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_SUBST);          ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_SUBST);
918            delt =        delt =
919              ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);          ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);
920    
921            for (i = 0; i < EBITSET_ELT_WORDS; i++)        for (i = 0; i < EBITSET_ELT_WORDS; i++)
922              EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];          EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
923          }      }
924        break;    EBITSET_NONZERO_SET (dst);
925    }  
926    
       /* Return 1 if DST == SRC.  */  
     case BITSET_OP_EQUAL_P:  
       return ebitset_equal_p (dst, src);  
   
       /* Return 1 if DST == DST | SRC.  */  
     case BITSET_OP_SUBSET_P:  
       {  
         ebitset_elts *selts;  
         ebitset_elts *delts;  
         bitset_windex ssize;  
         bitset_windex dsize;  
   
         selts = EBITSET_ELTS (src);  
         delts = EBITSET_ELTS (dst);  
   
         ssize = EBITSET_SIZE (src);  
         dsize = EBITSET_SIZE (dst);  
   
         for (j = 0; j < ssize; j++)  
           {  
             selt = j < ssize ? selts[j] : 0;  
             delt = j < dsize ? delts[j] : 0;  
   
             if (!selt && !delt)  
               continue;  
   
             if (!selt)  
               selt = &ebitset_zero_elts[0];  
             if (!delt)  
               delt = &ebitset_zero_elts[0];  
   
             for (i = 0; i < EBITSET_ELT_WORDS; i++)  
               if (EBITSET_WORDS (delt)[i]  
                   != (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))  
                 return 0;  
           }  
         return 1;  
       }  
       break;  
   
       /* Return 1 if DST & SRC == 0.  */  
     case BITSET_OP_DISJOINT_P:  
       {  
         ebitset_elts *selts;  
         ebitset_elts *delts;  
         bitset_windex ssize;  
         bitset_windex dsize;  
   
         selts = EBITSET_ELTS (src);  
         delts = EBITSET_ELTS (dst);  
   
         ssize = EBITSET_SIZE (src);  
         dsize = EBITSET_SIZE (dst);  
   
         for (j = 0; j < ssize; j++)  
           {  
             selt = j < ssize ? selts[j] : 0;  
             delt = j < dsize ? delts[j] : 0;  
   
             if (!selt || !delt)  
               continue;  
   
             for (i = 0; i < EBITSET_ELT_WORDS; i++)  
               if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))  
                 return 0;  
           }  
         return 1;  
       }  
       break;  
927    
928      default:  /* Return 1 if DST == DST | SRC.  */
929        abort ();  static int
930    ebitset_subset_p (dst, src)
931         bitset dst;
932         bitset src;
933    {
934      bitset_windex j;
935      ebitset_elts *selts;
936      ebitset_elts *delts;
937      bitset_windex ssize;
938      bitset_windex dsize;
939      
940      selts = EBITSET_ELTS (src);
941      delts = EBITSET_ELTS (dst);
942      
943      ssize = EBITSET_SIZE (src);
944      dsize = EBITSET_SIZE (dst);
945      
946      for (j = 0; j < ssize; j++)
947        {
948          unsigned int i;
949          ebitset_elt *selt;
950          ebitset_elt *delt;
951    
952          selt = j < ssize ? selts[j] : 0;
953          delt = j < dsize ? delts[j] : 0;
954          
955          if (!selt && !delt)
956            continue;
957          
958          if (!selt)
959            selt = &ebitset_zero_elts[0];
960          if (!delt)
961            delt = &ebitset_zero_elts[0];
962          
963          for (i = 0; i < EBITSET_ELT_WORDS; i++)
964            if (EBITSET_WORDS (delt)[i]
965                != (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
966              return 0;
967      }      }
968      return 1;
969    }
970    
971    EBITSET_NONZERO_SET (dst);  
972    /* Return 1 if DST & SRC == 0.  */
973    static int
974    ebitset_disjoint_p (dst, src)
975         bitset dst;
976         bitset src;
977    {
978      bitset_windex j;
979      ebitset_elts *selts;
980      ebitset_elts *delts;
981      bitset_windex ssize;
982      bitset_windex dsize;
983      
984      selts = EBITSET_ELTS (src);
985      delts = EBITSET_ELTS (dst);
986      
987      ssize = EBITSET_SIZE (src);
988      dsize = EBITSET_SIZE (dst);
989      
990      for (j = 0; j < ssize; j++)
991        {
992          unsigned int i;
993          ebitset_elt *selt;
994          ebitset_elt *delt;
995    
996          selt = j < ssize ? selts[j] : 0;
997          delt = j < dsize ? delts[j] : 0;
998          
999          if (!selt || !delt)
1000            continue;
1001          
1002          for (i = 0; i < EBITSET_ELT_WORDS; i++)
1003            if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
1004              return 0;
1005        }
1006    return 1;    return 1;
1007  }  }
1008    
1009    
1010    
1011  static int  static int
1012  ebitset_op3 (dst, src1, src2, op)  ebitset_op3_cmp (dst, src1, src2, op)
1013       bitset dst;       bitset dst;
1014       bitset src1;       bitset src1;
1015       bitset src2;       bitset src2;
# Line 1035  ebitset_op3 (dst, src1, src2, op) Line 1029  ebitset_op3 (dst, src1, src2, op)
1029    unsigned int i;    unsigned int i;
1030    bitset_windex j;    bitset_windex j;
1031    
   /* Fast track common, simple cases.  */  
   if (EBITSET_OP_ZERO_P (src2))  
     {  
       if (op == BITSET_OP_AND)  
         {  
           ebitset_weed (dst);  
           changed = EBITSET_OP_ZERO_P (dst);  
           ebitset_zero (dst);  
           return changed;  
         }  
       else if (op == BITSET_OP_ANDN || op == BITSET_OP_OR  
                || op == BITSET_OP_XOR)  
         {  
           return ebitset_copy_compare (dst, src1);  
         }  
     }  
   else if (EBITSET_OP_ZERO_P (src1))  
     {  
       if (op == BITSET_OP_AND || op == BITSET_OP_ANDN)  
         {  
           ebitset_weed (dst);  
           changed = EBITSET_OP_ZERO_P (dst);  
           ebitset_zero (dst);  
           return changed;  
         }  
       else if (op == BITSET_OP_OR || op == BITSET_OP_XOR)  
         {  
           return ebitset_copy_compare (dst, src2);  
         }  
     }  
   
1032    ssize1 = EBITSET_SIZE (src1);    ssize1 = EBITSET_SIZE (src1);
1033    ssize2 = EBITSET_SIZE (src2);    ssize2 = EBITSET_SIZE (src2);
1034    dsize = EBITSET_SIZE (dst);    dsize = EBITSET_SIZE (dst);
# Line 1198  ebitset_op3 (dst, src1, src2, op) Line 1161  ebitset_op3 (dst, src1, src2, op)
1161  }  }
1162    
1163    
1164    static int
1165    ebitset_and_cmp (dst, src1, src2)
1166         bitset dst;
1167         bitset src1;
1168         bitset src2;
1169    {
1170      int changed;
1171    
1172      if (EBITSET_ZERO_P (src2))
1173        {
1174          ebitset_weed (dst);
1175          changed = EBITSET_ZERO_P (dst);
1176          ebitset_zero (dst);
1177          return changed;
1178        }
1179      else if (EBITSET_ZERO_P (src1))
1180        {
1181          ebitset_weed (dst);
1182          changed = EBITSET_ZERO_P (dst);
1183          ebitset_zero (dst);
1184          return changed;
1185        }
1186      return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
1187    }
1188    
1189    
1190    static int
1191    ebitset_andn_cmp (dst, src1, src2)
1192         bitset dst;
1193         bitset src1;
1194         bitset src2;
1195    {
1196      int changed;
1197    
1198      if (EBITSET_ZERO_P (src2))
1199        {
1200          return ebitset_copy_cmp (dst, src1);
1201        }
1202      else if (EBITSET_ZERO_P (src1))
1203        {
1204          ebitset_weed (dst);
1205          changed = EBITSET_ZERO_P (dst);
1206          ebitset_zero (dst);
1207          return changed;
1208        }
1209      return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
1210    }
1211    
1212    
1213    static int
1214    ebitset_or_cmp (dst, src1, src2)
1215         bitset dst;
1216         bitset src1;
1217         bitset src2;
1218    {
1219      if (EBITSET_ZERO_P (src2))
1220        {
1221          return ebitset_copy_cmp (dst, src1);
1222        }
1223      else if (EBITSET_ZERO_P (src1))
1224        {
1225          return ebitset_copy_cmp (dst, src2);
1226        }
1227      return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
1228    }
1229    
1230    
1231    static int
1232    ebitset_xor_cmp (dst, src1, src2)
1233         bitset dst;
1234         bitset src1;
1235         bitset src2;
1236    {
1237      if (EBITSET_ZERO_P (src2))
1238        {
1239          return ebitset_copy_cmp (dst, src1);
1240        }
1241      else if (EBITSET_ZERO_P (src1))
1242        {
1243          return ebitset_copy_cmp (dst, src2);
1244        }
1245      return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
1246    }
1247    
1248    
1249    static void
1250    ebitset_copy (dst, src)
1251         bitset dst;
1252         bitset src;
1253    {
1254      if (BITSET_COMPATIBLE_ (dst, src))
1255          ebitset_copy_ (dst, src);
1256      else
1257          bitset_copy_ (dst, src);
1258    }
1259    
1260    
1261  /* Vector of operations for linked-list bitsets.  */  /* Vector of operations for linked-list bitsets.  */
1262  struct bitset_ops_struct ebitset_ops = {  struct bitset_vtable ebitset_vtable = {
1263    ebitset_set,    ebitset_set,
1264    ebitset_reset,    ebitset_reset,
1265      bitset_toggle_,
1266    ebitset_test,    ebitset_test,
1267    ebitset_size,    ebitset_size,
1268    ebitset_op1,    bitset_count_,
1269    ebitset_op2,    ebitset_empty_p,
1270    ebitset_op3,    ebitset_ones,
1271    bitset_op4,    ebitset_zero,
1272      ebitset_copy,
1273      ebitset_disjoint_p,
1274      ebitset_equal_p,
1275      ebitset_not,
1276      ebitset_subset_p,
1277      (PFV) ebitset_and_cmp,
1278      ebitset_and_cmp,
1279      (PFV) ebitset_andn_cmp,
1280      ebitset_andn_cmp,
1281      (PFV) ebitset_or_cmp,
1282      ebitset_or_cmp,
1283      (PFV) ebitset_xor_cmp,
1284      ebitset_xor_cmp,
1285      (PFV) bitset_and_or_cmp_,
1286      bitset_and_or_cmp_,
1287      (PFV) bitset_andn_or_cmp_,
1288      bitset_andn_or_cmp_,
1289      (PFV) bitset_or_and_cmp_,
1290      bitset_or_and_cmp_,
1291    ebitset_list,    ebitset_list,
1292    ebitset_reverse_list,    ebitset_list_reverse,
1293    ebitset_free,    ebitset_free,
1294    BITSET_TABLE    BITSET_TABLE
1295  };  };
# Line 1233  ebitset_init (bset, n_bits) Line 1313  ebitset_init (bset, n_bits)
1313  {  {
1314    unsigned int size;    unsigned int size;
1315    
1316    bset->b.ops = &ebitset_ops;    bset->b.vtable = &ebitset_vtable;
1317    
1318    bset->b.csize = EBITSET_ELT_WORDS;    bset->b.csize = EBITSET_ELT_WORDS;
1319    
1320    EBITSET_OP_ZERO_SET (bset);    EBITSET_ZERO_SET (bset);
1321    
1322    size = n_bits ? (n_bits + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS    size = n_bits ? (n_bits + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS
1323      : EBITSET_INITIAL_SIZE;      : EBITSET_INITIAL_SIZE;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26