diff options
| author | dh142964 <David.Hollister@Sun.COM> | 2009-09-30 13:40:27 -0600 |
|---|---|---|
| committer | dh142964 <David.Hollister@Sun.COM> | 2009-09-30 13:40:27 -0600 |
| commit | 4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6 (patch) | |
| tree | 17ba947a21901975bb128b8c535cb0575d4c9a4a /usr/src/uts/common/os/bitset.c | |
| parent | 7b57f05abb8796d3c91c8d4d4c75dcafb5af6b69 (diff) | |
| download | illumos-joyent-4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6.tar.gz | |
PSARC 2008/672 thebe SAS/SATA driver
PSARC 2008/755 ddi_ssoft_state(9F) and ddi_isoft_state(9F)
PSARC 2008/764 Cfgadm SCSI-Plugin MPxIO Support
PSARC 2009/125 scsi_device property interfaces
6726110 pmcs driver (driver for thebe)
6726867 SCSAv3
Diffstat (limited to 'usr/src/uts/common/os/bitset.c')
| -rw-r--r-- | usr/src/uts/common/os/bitset.c | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/usr/src/uts/common/os/bitset.c b/usr/src/uts/common/os/bitset.c index 175b7f5f14..3277b4efa6 100644 --- a/usr/src/uts/common/os/bitset.c +++ b/usr/src/uts/common/os/bitset.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -260,3 +260,80 @@ bitset_find(bitset_t *b) return (elt); } + +/* + * AND, OR, and XOR bitset computations + * Returns 1 if resulting bitset has any set bits + */ +int +bitset_and(bitset_t *bs1, bitset_t *bs2, bitset_t *res) +{ + int i, anyset; + + for (anyset = 0, i = 0; i < bs1->bs_words; i++) { + if ((res->bs_set[i] = (bs1->bs_set[i] & bs2->bs_set[i])) != 0) + anyset = 1; + } + return (anyset); +} + +int +bitset_or(bitset_t *bs1, bitset_t *bs2, bitset_t *res) +{ + int i, anyset; + + for (anyset = 0, i = 0; i < bs1->bs_words; i++) { + if ((res->bs_set[i] = (bs1->bs_set[i] | bs2->bs_set[i])) != 0) + anyset = 1; + } + return (anyset); +} + +int +bitset_xor(bitset_t *bs1, bitset_t *bs2, bitset_t *res) +{ + int i; + int anyset = 0; + + for (i = 0; i < bs1->bs_words; i++) { + if ((res->bs_set[i] = (bs1->bs_set[i] ^ bs2->bs_set[i])) != 0) + anyset = 1; + } + return (anyset); +} + +/* + * return 1 if bitmaps are identical + */ +int +bitset_match(bitset_t *bs1, bitset_t *bs2) +{ + int i; + + if (bs1->bs_words != bs2->bs_words) + return (0); + + for (i = 0; i < bs1->bs_words; i++) + if (bs1->bs_set[i] != bs2->bs_set[i]) + return (0); + return (1); +} + +/* + * Zero a bitset_t + */ +void +bitset_zero(bitset_t *b) +{ + bzero(b->bs_set, sizeof (ulong_t) * b->bs_words); +} + + +/* + * Copy a bitset_t + */ +void +bitset_copy(bitset_t *src, bitset_t *dest) +{ + bcopy(src->bs_set, dest->bs_set, sizeof (ulong_t) * src->bs_words); +} |
