23 |
|
|
24 |
#include "lbitset.h" |
#include "lbitset.h" |
25 |
#include "obstack.h" |
#include "obstack.h" |
26 |
|
#include <stddef.h> |
27 |
#include <stdlib.h> |
#include <stdlib.h> |
28 |
#include <stdio.h> |
#include <stdio.h> |
29 |
|
|
64 |
lbitset_elt; |
lbitset_elt; |
65 |
|
|
66 |
|
|
|
/* Head of lbitset linked list. */ |
|
|
typedef struct lbitset_struct |
|
|
{ |
|
|
lbitset_elt *head; /* First element in linked list. */ |
|
|
lbitset_elt *tail; /* Last element in linked list. */ |
|
|
} |
|
|
*lbitset; |
|
|
|
|
|
|
|
|
struct bitset_struct |
|
|
{ |
|
|
struct bbitset_struct b; |
|
|
struct lbitset_struct l; |
|
|
}; |
|
|
|
|
|
|
|
|
typedef void(*PFV)(); |
|
|
|
|
|
|
|
67 |
enum lbitset_find_mode |
enum lbitset_find_mode |
68 |
{ LBITSET_FIND, LBITSET_CREATE, LBITSET_SUBST }; |
{ LBITSET_FIND, LBITSET_CREATE, LBITSET_SUBST }; |
69 |
|
typedef int enum_lbitset_find_mode; |
70 |
|
|
71 |
static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */ |
static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */ |
72 |
|
|
81 |
static void lbitset_elt_unlink PARAMS ((bitset, lbitset_elt *)); |
static void lbitset_elt_unlink PARAMS ((bitset, lbitset_elt *)); |
82 |
static void lbitset_elt_free PARAMS ((lbitset_elt *)); |
static void lbitset_elt_free PARAMS ((lbitset_elt *)); |
83 |
static lbitset_elt *lbitset_elt_find PARAMS ((bitset, bitset_windex, |
static lbitset_elt *lbitset_elt_find PARAMS ((bitset, bitset_windex, |
84 |
enum lbitset_find_mode)); |
enum_lbitset_find_mode)); |
85 |
static int lbitset_elt_zero_p PARAMS ((lbitset_elt *)); |
static int lbitset_elt_zero_p PARAMS ((lbitset_elt *)); |
86 |
|
|
87 |
static void lbitset_prune PARAMS ((bitset, lbitset_elt *)); |
static void lbitset_prune PARAMS ((bitset, lbitset_elt *)); |
94 |
static void lbitset_reset PARAMS ((bitset, bitset_bindex)); |
static void lbitset_reset PARAMS ((bitset, bitset_bindex)); |
95 |
static int lbitset_test PARAMS ((bitset, bitset_bindex)); |
static int lbitset_test PARAMS ((bitset, bitset_bindex)); |
96 |
static bitset_bindex lbitset_size PARAMS ((bitset)); |
static bitset_bindex lbitset_size PARAMS ((bitset)); |
97 |
static int lbitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum bitset_ops)); |
static int lbitset_op3_cmp PARAMS ((bitset, bitset, bitset, enum_bitset_ops)); |
98 |
|
static void lbitset_and PARAMS ((bitset, bitset, bitset)); |
99 |
|
static int lbitset_and_cmp PARAMS ((bitset, bitset, bitset)); |
100 |
|
static void lbitset_andn PARAMS ((bitset, bitset, bitset)); |
101 |
|
static int lbitset_andn_cmp PARAMS ((bitset, bitset, bitset)); |
102 |
|
static void lbitset_or PARAMS ((bitset, bitset, bitset)); |
103 |
|
static int lbitset_or_cmp PARAMS ((bitset, bitset, bitset)); |
104 |
|
static void lbitset_xor PARAMS ((bitset, bitset, bitset)); |
105 |
|
static int lbitset_xor_cmp PARAMS ((bitset, bitset, bitset)); |
106 |
static bitset_bindex lbitset_list PARAMS ((bitset, bitset_bindex *, |
static bitset_bindex lbitset_list PARAMS ((bitset, bitset_bindex *, |
107 |
bitset_bindex, bitset_bindex *)); |
bitset_bindex, bitset_bindex *)); |
108 |
static bitset_bindex lbitset_list_reverse |
static bitset_bindex lbitset_list_reverse |
109 |
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *)); |
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *)); |
110 |
|
static int lbitset_empty_p PARAMS ((bitset)); |
111 |
|
static void lbitset_ones PARAMS ((bitset)); |
112 |
|
static void lbitset_not PARAMS ((bitset, bitset)); |
113 |
|
static int lbitset_subset_p PARAMS ((bitset, bitset)); |
114 |
|
static int lbitset_disjoint_p PARAMS ((bitset, bitset)); |
115 |
static void lbitset_free PARAMS ((bitset)); |
static void lbitset_free PARAMS ((bitset)); |
116 |
|
extern void debug_lbitset PARAMS ((bitset)); |
117 |
|
|
118 |
|
#define LBITSET_CURRENT1(X) \ |
119 |
#define LBITSET_CURRENT1(X) (lbitset_elt *)((char *)(X) + ((char *)&(((lbitset_elt *)(X))->next) - (char *)&(((lbitset_elt *)(X))->words))) |
((lbitset_elt *) (void *) ((char *) (X) - offsetof (lbitset_elt, words))) |
120 |
|
|
121 |
#define LBITSET_CURRENT(X) LBITSET_CURRENT1((X)->b.cdata) |
#define LBITSET_CURRENT(X) LBITSET_CURRENT1((X)->b.cdata) |
122 |
|
|
364 |
lbitset_elt_find (bset, windex, mode) |
lbitset_elt_find (bset, windex, mode) |
365 |
bitset bset; |
bitset bset; |
366 |
bitset_windex windex; |
bitset_windex windex; |
367 |
enum lbitset_find_mode mode; |
enum_lbitset_find_mode mode; |
368 |
{ |
{ |
369 |
lbitset_elt *elt; |
lbitset_elt *elt; |
370 |
lbitset_elt *current; |
lbitset_elt *current; |
1091 |
bitset dst; |
bitset dst; |
1092 |
bitset src1; |
bitset src1; |
1093 |
bitset src2; |
bitset src2; |
1094 |
enum bitset_ops op; |
enum_bitset_ops op; |
1095 |
{ |
{ |
1096 |
lbitset_elt *selt1 = LBITSET_HEAD (src1); |
lbitset_elt *selt1 = LBITSET_HEAD (src1); |
1097 |
lbitset_elt *selt2 = LBITSET_HEAD (src2); |
lbitset_elt *selt2 = LBITSET_HEAD (src2); |
1248 |
} |
} |
1249 |
|
|
1250 |
|
|
1251 |
|
static void |
1252 |
|
lbitset_and (dst, src1, src2) |
1253 |
|
bitset dst; |
1254 |
|
bitset src1; |
1255 |
|
bitset src2; |
1256 |
|
{ |
1257 |
|
lbitset_and_cmp (dst, src1, src2); |
1258 |
|
} |
1259 |
|
|
1260 |
|
|
1261 |
static int |
static int |
1262 |
lbitset_and_cmp (dst, src1, src2) |
lbitset_and_cmp (dst, src1, src2) |
1263 |
bitset dst; |
bitset dst; |
1286 |
} |
} |
1287 |
|
|
1288 |
|
|
1289 |
|
static void |
1290 |
|
lbitset_andn (dst, src1, src2) |
1291 |
|
bitset dst; |
1292 |
|
bitset src1; |
1293 |
|
bitset src2; |
1294 |
|
{ |
1295 |
|
lbitset_andn_cmp (dst, src1, src2); |
1296 |
|
} |
1297 |
|
|
1298 |
|
|
1299 |
static int |
static int |
1300 |
lbitset_andn_cmp (dst, src1, src2) |
lbitset_andn_cmp (dst, src1, src2) |
1301 |
bitset dst; |
bitset dst; |
1321 |
} |
} |
1322 |
|
|
1323 |
|
|
1324 |
|
static void |
1325 |
|
lbitset_or (dst, src1, src2) |
1326 |
|
bitset dst; |
1327 |
|
bitset src1; |
1328 |
|
bitset src2; |
1329 |
|
{ |
1330 |
|
lbitset_or_cmp (dst, src1, src2); |
1331 |
|
} |
1332 |
|
|
1333 |
|
|
1334 |
static int |
static int |
1335 |
lbitset_or_cmp (dst, src1, src2) |
lbitset_or_cmp (dst, src1, src2) |
1336 |
bitset dst; |
bitset dst; |
1352 |
} |
} |
1353 |
|
|
1354 |
|
|
1355 |
|
static void |
1356 |
|
lbitset_xor (dst, src1, src2) |
1357 |
|
bitset dst; |
1358 |
|
bitset src1; |
1359 |
|
bitset src2; |
1360 |
|
{ |
1361 |
|
lbitset_xor_cmp (dst, src1, src2); |
1362 |
|
} |
1363 |
|
|
1364 |
|
|
1365 |
static int |
static int |
1366 |
lbitset_xor_cmp (dst, src1, src2) |
lbitset_xor_cmp (dst, src1, src2) |
1367 |
bitset dst; |
bitset dst; |
1400 |
lbitset_equal_p, |
lbitset_equal_p, |
1401 |
lbitset_not, |
lbitset_not, |
1402 |
lbitset_subset_p, |
lbitset_subset_p, |
1403 |
(PFV) lbitset_and_cmp, |
lbitset_and, |
1404 |
lbitset_and_cmp, |
lbitset_and_cmp, |
1405 |
(PFV) lbitset_andn_cmp, |
lbitset_andn, |
1406 |
lbitset_andn_cmp, |
lbitset_andn_cmp, |
1407 |
(PFV) lbitset_or_cmp, |
lbitset_or, |
1408 |
lbitset_or_cmp, |
lbitset_or_cmp, |
1409 |
(PFV) lbitset_xor_cmp, |
lbitset_xor, |
1410 |
lbitset_xor_cmp, |
lbitset_xor_cmp, |
1411 |
(PFV) bitset_and_or_cmp_, |
bitset_and_or_, |
1412 |
bitset_and_or_cmp_, |
bitset_and_or_cmp_, |
1413 |
(PFV) bitset_andn_or_cmp_, |
bitset_andn_or_, |
1414 |
bitset_andn_or_cmp_, |
bitset_andn_or_cmp_, |
1415 |
(PFV) bitset_or_and_cmp_, |
bitset_or_and_, |
1416 |
bitset_or_and_cmp_, |
bitset_or_and_cmp_, |
1417 |
lbitset_list, |
lbitset_list, |
1418 |
lbitset_list_reverse, |
lbitset_list_reverse, |
1426 |
lbitset_bytes (n_bits) |
lbitset_bytes (n_bits) |
1427 |
bitset_bindex n_bits ATTRIBUTE_UNUSED; |
bitset_bindex n_bits ATTRIBUTE_UNUSED; |
1428 |
{ |
{ |
1429 |
return sizeof (struct bitset_struct); |
return sizeof (struct lbitset_struct); |
1430 |
} |
} |
1431 |
|
|
1432 |
|
|