1 #include "cc.h" 2 3 Bits 4 bor(Bits a, Bits b) 5 { 6 Bits c; 7 int i; 8 9 for(i=0; i<BITS; i++) 10 c.b[i] = a.b[i] | b.b[i]; 11 return c; 12 } 13 14 Bits 15 band(Bits a, Bits b) 16 { 17 Bits c; 18 int i; 19 20 for(i=0; i<BITS; i++) 21 c.b[i] = a.b[i] & b.b[i]; 22 return c; 23 } 24 25 /* 26 Bits 27 bnot(Bits a) 28 { 29 Bits c; 30 int i; 31 32 for(i=0; i<BITS; i++) 33 c.b[i] = ~a.b[i]; 34 return c; 35 } 36 */ 37 38 int 39 bany(Bits *a) 40 { 41 int i; 42 43 for(i=0; i<BITS; i++) 44 if(a->b[i]) 45 return 1; 46 return 0; 47 } 48 49 int 50 beq(Bits a, Bits b) 51 { 52 int i; 53 54 for(i=0; i<BITS; i++) 55 if(a.b[i] != b.b[i]) 56 return 0; 57 return 1; 58 } 59 60 int 61 bnum(Bits a) 62 { 63 int i; 64 long b; 65 66 for(i=0; i<BITS; i++) 67 if(b = a.b[i]) 68 return 32*i + bitno(b); 69 diag(Z, "bad in bnum"); 70 return 0; 71 } 72 73 Bits 74 blsh(uint n) 75 { 76 Bits c; 77 78 c = zbits; 79 c.b[n/32] = 1L << (n%32); 80 return c; 81 } 82 83 int 84 bset(Bits a, uint n) 85 { 86 if(a.b[n/32] & (1L << (n%32))) 87 return 1; 88 return 0; 89 } 90