35 |
#endif |
#endif |
36 |
|
|
37 |
|
|
38 |
int |
static int |
39 |
ior_op(int i, int j) |
ior_op(int i, int j) |
40 |
{ |
{ |
41 |
return(i | j); |
return(i | j); |
42 |
} |
} |
43 |
|
|
44 |
int |
static int |
45 |
xor_op(int i, int j) |
xor_op(int i, int j) |
46 |
{ |
{ |
47 |
return(i ^ j); |
return(i ^ j); |
48 |
} |
} |
49 |
|
|
50 |
int |
static int |
51 |
and_op(int i, int j) |
and_op(int i, int j) |
52 |
{ |
{ |
53 |
return(i & j); |
return(i & j); |
54 |
} |
} |
55 |
|
|
56 |
int |
static int |
57 |
eqv_op(int i, int j) |
eqv_op(int i, int j) |
58 |
{ |
{ |
59 |
return(~(i ^ j)); |
return(~(i ^ j)); |
60 |
} |
} |
61 |
|
|
62 |
int |
static int |
63 |
nand_op(int i, int j) |
nand_op(int i, int j) |
64 |
{ |
{ |
65 |
return(~(i & j)); |
return(~(i & j)); |
66 |
} |
} |
67 |
|
|
68 |
int |
static int |
69 |
nor_op(int i, int j) |
nor_op(int i, int j) |
70 |
{ |
{ |
71 |
return(~(i | j)); |
return(~(i | j)); |
72 |
} |
} |
73 |
|
|
74 |
int |
static int |
75 |
andc1_op(int i, int j) |
andc1_op(int i, int j) |
76 |
{ |
{ |
77 |
return((~i) & j); |
return((~i) & j); |
78 |
} |
} |
79 |
|
|
80 |
int |
static int |
81 |
andc2_op(int i, int j) |
andc2_op(int i, int j) |
82 |
{ |
{ |
83 |
return(i & (~j)); |
return(i & (~j)); |
84 |
} |
} |
85 |
|
|
86 |
int |
static int |
87 |
orc1_op(int i, int j) |
orc1_op(int i, int j) |
88 |
{ |
{ |
89 |
return((~i) | j); |
return((~i) | j); |
90 |
} |
} |
91 |
|
|
92 |
int |
static int |
93 |
orc2_op(int i, int j) |
orc2_op(int i, int j) |
94 |
{ |
{ |
95 |
return(i | (~j)); |
return(i | (~j)); |
96 |
} |
} |
97 |
|
|
98 |
int |
static int |
99 |
b_clr_op(int i, int j) |
b_clr_op(int i, int j) |
100 |
{ |
{ |
101 |
return(0); |
return(0); |
102 |
} |
} |
103 |
|
|
104 |
int |
static int |
105 |
b_set_op(int i, int j) |
b_set_op(int i, int j) |
106 |
{ |
{ |
107 |
return(-1); |
return(-1); |
108 |
} |
} |
109 |
|
|
110 |
int |
static int |
111 |
b_1_op(int i, int j) |
b_1_op(int i, int j) |
112 |
{ |
{ |
113 |
return(i); |
return(i); |
114 |
} |
} |
115 |
|
|
116 |
int |
static int |
117 |
b_2_op(int i, int j) |
b_2_op(int i, int j) |
118 |
{ |
{ |
119 |
return(j); |
return(j); |
120 |
} |
} |
121 |
|
|
122 |
int |
static int |
123 |
b_c1_op(int i, int j) |
b_c1_op(int i, int j) |
124 |
{ |
{ |
125 |
return(~i); |
return(~i); |
126 |
} |
} |
127 |
|
|
128 |
int |
static int |
129 |
b_c2_op(int i, int j) |
b_c2_op(int i, int j) |
130 |
{ |
{ |
131 |
return(~j); |
return(~j); |
153 |
#endif |
#endif |
154 |
|
|
155 |
|
|
156 |
int |
static int |
157 |
fix_bitp(object x, int p) |
fix_bitp(object x, int p) |
158 |
{ |
{ |
159 |
if (p > 30) { /* fix = sign + bit0-30 */ |
if (p > 30) { /* fix = sign + bit0-30 */ |
165 |
return((fix(x) >> p) & 1); |
return((fix(x) >> p) & 1); |
166 |
} |
} |
167 |
|
|
168 |
int |
static int |
169 |
count_int_bits(int x) |
count_int_bits(int x) |
170 |
{ |
{ |
171 |
int i, count; |
int i, count; |
175 |
return(count); |
return(count); |
176 |
} |
} |
177 |
|
|
178 |
int |
static int |
179 |
count_bits(object x) |
count_bits(object x) |
180 |
{ |
{ |
181 |
int i, count=0; |
int i, count=0; |
221 |
} |
} |
222 |
|
|
223 |
|
|
224 |
int |
static int |
225 |
int_bit_length(int i) |
int_bit_length(int i) |
226 |
{ |
{ |
227 |
int count, j; |
int count, j; |
487 |
} |
} |
488 |
|
|
489 |
#define W_SIZE (8*sizeof(int)) |
#define W_SIZE (8*sizeof(int)) |
490 |
object |
/* static object */ |
491 |
bitand(object a, object b, object c) |
/* bitand(object a, object b, object c) */ |
492 |
{ int d= a->bv.bv_fillp; |
/* { int d= a->bv.bv_fillp; */ |
493 |
int *ap,*bp,*cp; |
/* int *ap,*bp,*cp; */ |
494 |
d=(d+W_SIZE-1)/W_SIZE; |
/* d=(d+W_SIZE-1)/W_SIZE; */ |
495 |
ap= (int *)(a->bv.bv_self); |
/* ap= (int *)(a->bv.bv_self); */ |
496 |
bp= (int *)(b->bv.bv_self); |
/* bp= (int *)(b->bv.bv_self); */ |
497 |
cp= (int *)(c->bv.bv_self); |
/* cp= (int *)(c->bv.bv_self); */ |
498 |
while (--d >= 0) |
/* while (--d >= 0) */ |
499 |
{ *cp++ = *bp++ & *ap++; |
/* { *cp++ = *bp++ & *ap++; */ |
500 |
} |
/* } */ |
501 |
return c; |
/* return c; */ |
502 |
} |
/* } */ |
503 |
|
|
504 |
object |
/* static object */ |
505 |
bitior(object a, object b, object c) |
/* bitior(object a, object b, object c) */ |
506 |
{ int *ap,*cp,*bp, d= a->bv.bv_fillp; |
/* { int *ap,*cp,*bp, d= a->bv.bv_fillp; */ |
507 |
d=(d+W_SIZE-1)/W_SIZE; |
/* d=(d+W_SIZE-1)/W_SIZE; */ |
508 |
ap= (int *)((a->bv.bv_self)); |
/* ap= (int *)((a->bv.bv_self)); */ |
509 |
bp= (int *)(b->bv.bv_self); |
/* bp= (int *)(b->bv.bv_self); */ |
510 |
cp= (int *)(c->bv.bv_self); |
/* cp= (int *)(c->bv.bv_self); */ |
511 |
while (--d >= 0) |
/* while (--d >= 0) */ |
512 |
{ *cp++ = *bp++ | *ap++; |
/* { *cp++ = *bp++ | *ap++; */ |
513 |
} |
/* } */ |
514 |
return c; |
/* return c; */ |
515 |
} |
/* } */ |
516 |
|
|
517 |
/* Note in order to be equal we assume that the part above the |
/* Note in order to be equal we assume that the part above the |
518 |
fill pointer is 0 up to the next word */ |
fill pointer is 0 up to the next word */ |
519 |
|
|
520 |
int |
/* static int */ |
521 |
bvequal(object a, object b) |
/* bvequal(object a, object b) */ |
522 |
{ int *ap,*bp, d= a->bv.bv_fillp; |
/* { int *ap,*bp, d= a->bv.bv_fillp; */ |
523 |
d=(d+W_SIZE-1)/W_SIZE; |
/* d=(d+W_SIZE-1)/W_SIZE; */ |
524 |
ap= (int *)(a->bv.bv_self); |
/* ap= (int *)(a->bv.bv_self); */ |
525 |
bp= (int *)(b->bv.bv_self); |
/* bp= (int *)(b->bv.bv_self); */ |
526 |
while (--d >= 0) |
/* while (--d >= 0) */ |
527 |
{ if (*ap++ != *bp++) return 1; |
/* { if (*ap++ != *bp++) return 1; */ |
528 |
} |
/* } */ |
529 |
return 0; |
/* return 0; */ |
530 |
} |
/* } */ |
531 |
|
|
532 |
|
|
533 |
|
|