2009-01-27 00:44:45 +01:00
|
|
|
/***
|
|
|
|
|
This file is part of PulseAudio.
|
|
|
|
|
|
|
|
|
|
Copyright 2009 Lennart Poettering
|
|
|
|
|
|
|
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2009-01-27 00:44:45 +01:00
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2014-11-26 14:14:51 +01:00
|
|
|
along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
2009-01-27 00:44:45 +01:00
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <pulse/xmalloc.h>
|
|
|
|
|
|
|
|
|
|
#include "bitset.h"
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
void pa_bitset_set(pa_bitset_t *b, unsigned k, bool v) {
|
2009-01-27 00:44:45 +01:00
|
|
|
pa_assert(b);
|
|
|
|
|
|
|
|
|
|
if (v)
|
|
|
|
|
b[k >> 5] |= 1 << (k & 31);
|
|
|
|
|
else
|
|
|
|
|
b[k >> 5] &= ~((uint32_t) (1 << (k & 31)));
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
bool pa_bitset_get(const pa_bitset_t *b, unsigned k) {
|
2009-01-27 00:44:45 +01:00
|
|
|
return !!(b[k >> 5] & (1 << (k & 31)));
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
bool pa_bitset_equals(const pa_bitset_t *b, unsigned n, ...) {
|
2009-01-27 00:44:45 +01:00
|
|
|
va_list ap;
|
|
|
|
|
pa_bitset_t *a;
|
2013-06-27 19:28:09 +02:00
|
|
|
bool equal;
|
2009-01-27 00:44:45 +01:00
|
|
|
|
|
|
|
|
a = pa_xnew0(pa_bitset_t, PA_BITSET_ELEMENTS(n));
|
|
|
|
|
|
|
|
|
|
va_start(ap, n);
|
|
|
|
|
for (;;) {
|
|
|
|
|
int j = va_arg(ap, int);
|
|
|
|
|
|
|
|
|
|
if (j < 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_bitset_set(a, j, true);
|
2009-01-27 00:44:45 +01:00
|
|
|
}
|
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
|
|
equal = memcmp(a, b, PA_BITSET_SIZE(n)) == 0;
|
|
|
|
|
pa_xfree(a);
|
|
|
|
|
|
|
|
|
|
return equal;
|
|
|
|
|
}
|